コード例 #1
0
 private void buildMainFrame() {
   DesktopContext context = getDesktopContext();
   mainFrame = new JFrame(PRIDE_GUI + " " + context.getProperty("pride.inspector.version"));
   ImageIcon icon =
       GUIUtilities.loadImageIcon(context.getProperty("pride.inspector.logo.medium.icon"));
   mainFrame.setIconImage(icon.getImage());
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
     logger.error("Failed to set the look and feel", e);
   }
   // ToDo: proper exit hooke
   mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
コード例 #2
0
  /** make menu bar a separate component */
  private void buildMenuToolBar() {
    // get property manager
    PrideInspectorContext context = (PrideInspectorContext) getDesktopContext();

    // create all the actions
    // file open action
    Icon openFileIcon = GUIUtilities.loadIcon(context.getProperty("open.file.icon.small"));
    String openFileDesc = context.getProperty("open.file.title");
    String openFileTooltip = context.getProperty("open.file.tooltip");
    PrideAction openFileAction = new OpenFileAction(openFileDesc, openFileIcon);

    // database open action
    Icon openDbIcon = GUIUtilities.loadIcon(context.getProperty("open.database.icon.small"));
    String openDbDesc = context.getProperty("open.database.title");
    String openDbTooltip = context.getProperty("open.database.tooltip");
    PrideAction openDbAction = new OpenDatabaseAction(openDbDesc, openDbIcon);

    // open reviewer
    Icon openReviewerIcon =
        GUIUtilities.loadIcon(context.getProperty("reviewer.download.icon.small"));
    String openReviewerDesc = context.getProperty("reviewer.download.title");
    String openReviewerTooltip = context.getProperty("reviewer.download.tooltip");
    PrideAction openReviewerAction = new OpenReviewAction(openReviewerDesc, openReviewerIcon);

    // close
    String closeDesc = context.getProperty("close.source.title");
    String closeAllDesc = context.getProperty("close.all.soruce.title");
    PrideAction closeAction = new CloseControllerAction(closeDesc, null);
    PrideAction closeAllAction = new CloseAllControllersAction(closeAllDesc, null);
    context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) closeAction);
    context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) closeAllAction);

    // try pride xml sample
    String openPrideXmlExampleDesc = context.getProperty("open.pride.xml.example.title");
    File prideXmlExampleFile =
        getExampleFiles(context.getProperty("pride.inspector.pride.example.file"));
    java.util.List<File> prideXmlFiles = new ArrayList<File>();
    if (prideXmlExampleFile != null) {
      prideXmlFiles.add(prideXmlExampleFile);
    }
    PrideAction openPrideXmlExampleAction =
        new OpenFileAction(openPrideXmlExampleDesc, null, prideXmlFiles);
    openPrideXmlExampleAction.setEnabled(
        prideXmlExampleFile != null && prideXmlExampleFile.exists());

    // try mzml sample
    String openMzMLExampleDesc = context.getProperty("open.mzml.example.title");
    File mzMLExampleFile =
        getExampleFiles(context.getProperty("pride.inspector.mzml.example.file"));
    java.util.List<File> mzMLFiles = new ArrayList<File>();
    if (mzMLExampleFile != null) {
      mzMLFiles.add(mzMLExampleFile);
    }
    PrideAction openMzMLExampleAction = new OpenFileAction(openMzMLExampleDesc, null, mzMLFiles);
    openMzMLExampleAction.setEnabled(mzMLExampleFile != null && mzMLExampleFile.exists());

    // help
    Icon helpIcon = GUIUtilities.loadIcon(context.getProperty("help.icon.small"));
    String helpDesc = context.getProperty("help.title");
    String helpTooltip = context.getProperty("help.tooltip");
    PrideAction helpAction = new OpenHelpAction(helpDesc, helpIcon);

    // faq
    String faqDesc = context.getProperty("faq.title");
    PrideAction faqAction = new OpenFAQAction(faqDesc, null);

    // pride website
    String prideWeb = context.getProperty("open.pride.website.title");
    String prideWebUrl = context.getProperty("pride.website");
    PrideAction prideWebAction = new OpenUrlAction(prideWeb, null, prideWebUrl);

    // pride website
    String inspectorWeb = context.getProperty("open.pride.inspector.website.title");
    String inspectorWebUrl = context.getProperty("pride.inspector.website");
    PrideAction inspectorWebAction = new OpenUrlAction(inspectorWeb, null, inspectorWebUrl);

    // feedback
    String feedbackDesc = context.getProperty("feedback.title");
    PrideAction feedBackAction = new FeedbackAction(feedbackDesc, null);

    // export
    String exportDesc = context.getProperty("export.title");
    PrideAction exportAction = new ExportSpectrumAction(exportDesc, null);
    context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) exportAction);

    // export identification
    String exportIdentDesc = context.getProperty("export.identification.title");
    PrideAction exportIdentAction = new ExportIdentificationPeptideAction(exportIdentDesc, null);

    // export spectrum description
    String exportSpectrumDesc = context.getProperty("export.spectrum.desc.title");
    PrideAction exportSpectrumDescAction = new ExportSpectrumDescAction(exportSpectrumDesc, null);

    // export identification description
    String exportIdentDescTitle = context.getProperty("export.identification.desc.title");
    PrideAction exportIdentDescAction =
        new ExportIdentificationDescAction(exportIdentDescTitle, null);

    // export peptide description
    String exportPeptideDescTitle = context.getProperty("export.peptide.desc.title");
    PrideAction exportPeptideAction = new ExportPeptideDescAction(exportPeptideDescTitle, null);

    // make experiment public
    String makeExpPublicTitle = context.getProperty("make.experiment.public.title");
    PrideAction makeExpPublicAction = new MakeExperimentPublicAction(makeExpPublicTitle, null);

    String createReviewerTitle = context.getProperty("create.reviewer.title");
    PrideAction createReviewerAction = new CreateReviewerAction(createReviewerTitle, null);

    // check update
    String updateDescTitle = context.getProperty("check.update.desc.title");
    PrideAction updateAction = new UpdateAction(updateDescTitle, null);

    // about
    String aboutDesc = context.getProperty("about.title");
    PrideAction aboutAction = new AboutAction(aboutDesc, null);

    // exit
    String exitDesc = context.getProperty("exit.title");
    PrideAction exitAction = new ExitAction(exitDesc, null);

    // menu items
    menuBar = new JMenuBar();

    // file menu
    JMenu fileMenu =
        MenuFactory.createMenu(
            "File",
            openFileAction,
            openDbAction,
            openReviewerAction,
            MenuFactory.ACTION_SEPARATOR,
            closeAction,
            closeAllAction,
            MenuFactory.ACTION_SEPARATOR,
            exitAction);
    fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);
    menuBar.add(fileMenu);

    // try samples
    JMenu trySampleMenu =
        MenuFactory.createMenu("Examples", openPrideXmlExampleAction, openMzMLExampleAction);
    trySampleMenu.setMnemonic(java.awt.event.KeyEvent.VK_X);
    menuBar.add(trySampleMenu);

    // export menu
    JMenu exportMenu =
        MenuFactory.createMenu(
            "Export",
            exportAction,
            exportSpectrumDescAction,
            exportIdentAction,
            exportIdentDescAction,
            exportPeptideAction);
    exportMenu.setMnemonic(java.awt.event.KeyEvent.VK_E);
    menuBar.add(exportMenu);

    // curation menu
    boolean showCurationMenu = Boolean.parseBoolean(context.getProperty("include.curation.menu"));
    if (showCurationMenu) {
      JMenu curationMenu =
          MenuFactory.createMenu("Curation", makeExpPublicAction, createReviewerAction);
      curationMenu.setMnemonic(java.awt.event.KeyEvent.VK_C);
      menuBar.add(curationMenu);
    }

    // help menu
    JMenu helpMenu =
        MenuFactory.createMenu(
            "Help",
            helpAction,
            faqAction,
            MenuFactory.ACTION_SEPARATOR,
            prideWebAction,
            inspectorWebAction,
            MenuFactory.ACTION_SEPARATOR,
            feedBackAction,
            MenuFactory.ACTION_SEPARATOR,
            updateAction,
            aboutAction);
    helpMenu.setMnemonic(java.awt.event.KeyEvent.VK_H);
    menuBar.add(helpMenu);

    // add menus
    mainFrame.setJMenuBar(menuBar);

    // tool bar
    toolBar = new JToolBar();

    // open file
    JButton openFileButton = new JButton();
    openFileButton.setAction(openFileAction);
    openFileButton.setText("");
    openFileButton.setToolTipText(openFileTooltip);
    openFileButton.setFocusable(false);
    toolBar.add(openFileButton);
    // open database
    JButton openDbButton = new JButton();
    openDbButton.setAction(openDbAction);
    openDbButton.setText("");
    openDbButton.setToolTipText(openDbTooltip);
    openDbButton.setFocusable(false);
    toolBar.add(openDbButton);
    // open reviewer download
    JButton openReviewerButton = new JButton();
    openReviewerButton.setAction(openReviewerAction);
    openReviewerButton.setText("");
    openReviewerButton.setToolTipText(openReviewerTooltip);
    openReviewerButton.setFocusable(false);
    toolBar.add(openReviewerButton);
    // separator
    toolBar.addSeparator();
    // help
    JButton helpButton = new JButton(helpIcon);
    helpButton.setAction(helpAction);
    helpButton.setText("");
    helpButton.setToolTipText(helpTooltip);
    helpButton.setFocusable(false);
    toolBar.add(helpButton);
    mainFrame.getContentPane().add(toolBar, BorderLayout.PAGE_START);
  }