Esempio n. 1
0
 /**
  * Generates handles response. This is were we would pass stuff to cli or gui, etc
  *
  * @param n the processed policy object
  * @return the policyObjected as accepted by user (potentially modified
  */
 public PolicyObject userResponse(PolicyObject n) {
   if ((parseAct(genProps.getProperty("userResponse", null)) == null)
       && !Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
     return userInterface.userResponse(n);
   } else {
     if (Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
       return n.setAction(n.getAction().setOverride(true));
     } else {
       return n.setAction(parseAct(genProps.getProperty("userResponse", null)));
     }
   }
 }
Esempio n. 2
0
  /**
   * A constructor permitting a user interface class to launch everything and be in control.
   *
   * @param args any commandline arguements
   * @param ui the known UserIO object
   * @throws Exception Mostly from loadWeights, but should also happen for loadFromConfig
   */
  public Gio(String[] args, UserIO ui) throws Exception {

    userInterface = ui;
    genProps = loadFromConfig("./PrivacyAdviser.cfg");
    loadCLO(args);
    // TODO add method to check validity of genProps (after each file load, clo load, and ui load).

    if ((genProps.getProperty("genConfig") != null)
        && (genProps.getProperty("genConfig") != "./PrivacyAdvisor.cfg")) {
      System.err.println("clo config call");
      genProps = loadFromConfig(genProps.getProperty("genConfig")); // TODO merge, not override
      loadCLO(args);
    }

    // start the logger
    logger =
        startLogger(
            genProps.getProperty("loglocation", "./LOG.txt"),
            genProps.getProperty("loglevel", "INFO"));
    if (userInterface == null) {
      selectUI(genProps.getProperty("userIO"));
    }
    selectPDB(genProps.getProperty("policyDB"));

    // load the weights configuration file
    origWeights = new Properties();
    origWeights = loadWeights();
    if (Boolean.parseBoolean(genProps.getProperty("useNet", "false"))) {
      startNetwork();
    } else {
      nr = null;
    }
  }
Esempio n. 3
0
 /**
  * Loads the case history into cache. This is where the background database chosen.
  *
  * @param dLoc the location of the database
  */
 public void loadDB() {
   try {
     // TODO what about if we want to create a new db?
     if (!Boolean.parseBoolean(genProps.getProperty("newDB"))) {
       pdb.loadDB();
     }
   } catch (Exception e) {
     System.err.println("Something wrong with loading DB");
   }
   try {
     loadCLPolicies();
   } catch (Exception e) {
     System.err.println("Error. Probably wrong path to P3P folder");
   }
 }
Esempio n. 4
0
  private static Params parse(String[] args) {
    Options options = generateCommandlineOptions();
    CommandLineParser parser = new PosixParser();
    Params params = new Params();

    try {
      CommandLine cmd = parser.parse(options, args);
      String value;
      if (cmd.hasOption("input")) {
        params.input = cmd.getOptionValue("input");
      }
      if (cmd.hasOption("maxIter")) {
        value = cmd.getOptionValue("maxIter");
        params.maxIter = Integer.parseInt(value);
      }
      if (cmd.hasOption("tol")) {
        value = cmd.getOptionValue("tol");
        params.tol = Double.parseDouble(value);
      }
      if (cmd.hasOption("fitIntercept")) {
        value = cmd.getOptionValue("fitIntercept");
        params.fitIntercept = Boolean.parseBoolean(value);
      }
      if (cmd.hasOption("regParam")) {
        value = cmd.getOptionValue("regParam");
        params.regParam = Double.parseDouble(value);
      }
      if (cmd.hasOption("elasticNetParam")) {
        value = cmd.getOptionValue("elasticNetParam");
        params.elasticNetParam = Double.parseDouble(value);
      }
      if (cmd.hasOption("testInput")) {
        value = cmd.getOptionValue("testInput");
        params.testInput = value;
      }
      if (cmd.hasOption("fracTest")) {
        value = cmd.getOptionValue("fracTest");
        params.fracTest = Double.parseDouble(value);
      }

    } catch (ParseException e) {
      printHelpAndQuit(options);
    }
    return params;
  }
Esempio n. 5
0
 /**
  * call the user interface's general configuration method if the userInit option is true, and a
  * user interface exists
  */
 public void configUI() {
   if (Boolean.parseBoolean(genProps.getProperty("userInit", "false"))
       && !(userInterface == null)) {
     userInterface.user_init(genProps);
   }
 }
  /** 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);
  }