Ejemplo n.º 1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
Ejemplo n.º 2
0
 private String generateOverviewText() throws InsufficientDataException {
   StringBuilder sb = new StringBuilder();
   final String team = config.getTeam();
   double total = checkTotal();
   final String nl = System.getProperty("line.separator");
   for (Entry<String, Row> entry : rows.entrySet()) {
     double hours = Double.parseDouble(entry.getValue().hoursTF.getText());
     double fraction = hours / total;
     if (fraction < 0.004) continue;
     String line = team + ", " + decimalFormat.format(fraction) + ", " + entry.getKey();
     sb.append(line + nl);
   }
   return sb.toString();
 }
Ejemplo n.º 3
0
  /** Make an EntryEdit component from the given Entry. */
  public static EntryEdit makeEntryEdit(final Entry entry) {
    final Bases bases = entry.getBases();
    final EntryGroup entry_group = new SimpleEntryGroup(bases);
    entry_group.add(entry);
    final EntryEdit entry_edit = new EntryEdit(entry_group);

    return entry_edit;
  }
Ejemplo n.º 4
0
  /** Code completion. */
  private void complete() {
    if (selected()) return;

    // find first character
    final int caret = editor.pos(), startPos = editor.completionStart();
    final String prefix = string(substring(editor.text(), startPos, caret));
    if (prefix.isEmpty()) return;

    // find insertion candidates
    final TreeMap<String, String> tmp = new TreeMap<>();
    for (final Entry<String, String> entry : REPLACE.entrySet()) {
      final String key = entry.getKey();
      if (key.startsWith(prefix)) tmp.put(key, entry.getValue());
    }

    if (tmp.size() == 1) {
      // insert single candidate
      complete(tmp.values().iterator().next(), startPos);
    } else if (!tmp.isEmpty()) {
      // show popup menu
      final JPopupMenu pm = new JPopupMenu();
      final ActionListener al =
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
              complete(ae.getActionCommand().replaceAll("^.*?\\] ", ""), startPos);
            }
          };

      for (final Entry<String, String> entry : tmp.entrySet()) {
        final JMenuItem mi = new JMenuItem("[" + entry.getKey() + "] " + entry.getValue());
        pm.add(mi);
        mi.addActionListener(al);
      }
      pm.addSeparator();
      final JMenuItem mi = new JMenuItem(Text.INPUT + Text.COLS + prefix);
      mi.setEnabled(false);
      pm.add(mi);

      final int[] cursor = rend.cursor();
      pm.show(this, cursor[0], cursor[1]);

      // highlight first entry
      final MenuElement[] me = {pm, (JMenuItem) pm.getComponent(0)};
      MenuSelectionManager.defaultManager().setSelectedPath(me);
    }
  }
Ejemplo n.º 5
0
  /** Read the entries given in the uk.ac.sanger.artemis.ini file. */
  private void readDefaultEntries() {
    final EntryInformation artemis_entry_information = Options.getArtemisEntryInformation();

    final String default_sequence_file_name = Options.getOptions().getDefaultSequenceFileName();

    final String default_feature_file_name = Options.getOptions().getDefaultFeatureFileName();

    if (default_sequence_file_name != null) {
      final String default_sequence_file_name_embl = default_sequence_file_name + "_embl";

      uk.ac.sanger.artemis.io.Entry new_embl_entry = null;

      // try opening the default sequence file with "_embl" added to the name
      // if that fails try the plain sequence file name

      final Document entry_document = DocumentFactory.makeDocument(default_sequence_file_name_embl);

      final InputStreamProgressListener progress_listener = getInputStreamProgressListener();

      entry_document.addInputStreamProgressListener(progress_listener);

      if (entry_document.readable()) {
        new_embl_entry =
            EntryFileDialog.getEntryFromFile(
                this, entry_document, artemis_entry_information, false);
      }

      if (new_embl_entry == null
          || new_embl_entry.getSequence() == null
          || new_embl_entry.getSequence().length() == 0) {
        final File entry_file = new File(default_sequence_file_name);

        if (entry_file.exists()) {
          new_embl_entry =
              EntryFileDialog.getEntryFromFile(
                  this, entry_document, artemis_entry_information, false);
        } else {
          // read failed
          System.err.println(
              "file does not exist: " + default_sequence_file_name + "(given in options files)");
          return;
        }
      }

      if (new_embl_entry == null
          || new_embl_entry.getSequence() == null
          || new_embl_entry.getSequence().length() == 0) {
        // read failed
        System.err.println(
            "failed to read " + default_sequence_file_name + "(given in options files)");
        return;
      }

      getStatusLabel().setText("");

      try {
        final Entry entry = new Entry(new_embl_entry);

        final EntryEdit new_entry_edit = makeEntryEdit(entry);

        new_entry_edit.setVisible(true);

        if (default_feature_file_name != null) {
          final Document feature_document = DocumentFactory.makeDocument(default_feature_file_name);

          final uk.ac.sanger.artemis.io.Entry new_embl_table_entry =
              EntryFileDialog.getEntryFromFile(
                  this, feature_document, artemis_entry_information, false);

          if (new_embl_table_entry == null) // open failed
          return;

          final EntryGroup entry_group = new_entry_edit.getEntryGroup();

          final Entry new_table_entry = new Entry(entry.getBases(), new_embl_table_entry);

          entry_group.add(new_table_entry);
        }
      } catch (OutOfRangeException e) {
        new MessageDialog(
            this,
            "read failed: one of the features in "
                + default_feature_file_name
                + " has an out of range location: "
                + e.getMessage());
      } catch (NoSequenceException e) {
        new MessageDialog(
            this, "read failed: " + new_embl_entry.getName() + " contains no sequence");
      }
    }
  }