示例#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();
 }
示例#2
0
 @Override
 public void setValueAt(Object value, int rowIndex, int columnIndex) {
   if ((columnIndex == 0) && (value instanceof Boolean)) {
     Entry e = data.get(rowIndex);
     e.enabled = (Boolean) value;
     fireTableCellUpdated(rowIndex, columnIndex);
   }
 }
 private void getParents(List<Entry> list) {
   for (Entry entry : parents) {
     if (entry.install && !list.contains(entry)) {
       list.add(entry);
       entry.getParents(list);
     }
   }
 }
示例#4
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();
 }
    // {{{ setSelectAll() method
    public void setSelectAll(boolean b) {
      if (isDownloadingList()) return;

      int length = getRowCount();
      for (int i = 0; i < length; i++) {
        if (b) setValueAt(Boolean.TRUE, i, 0);
        else {
          Entry entry = (Entry) filteredEntries.get(i);
          entry.parents = new LinkedList<Entry>();
          entry.install = false;
        }
      }
      fireTableChanged(new TableModelEvent(this));
    } // }}}
    // {{{ setValueAt() method
    @Override
    public void setValueAt(Object aValue, int row, int column) {
      if (column != 0) return;

      Object obj = filteredEntries.get(row);
      if (obj instanceof String) return;

      Entry entry = (Entry) obj;
      boolean before = entry.install;
      entry.install = Boolean.TRUE.equals(aValue);
      if (before == entry.install) return;
      if (!entry.install) deselectParents(entry);

      List<PluginList.Dependency> deps = entry.plugin.getCompatibleBranch().deps;

      for (int i = 0; i < deps.size(); i++) {
        PluginList.Dependency dep = deps.get(i);
        if ("plugin".equals(dep.what)) {
          boolean found = false;
          for (int j = 0; j < filteredEntries.size(); j++) {
            Entry temp = (Entry) filteredEntries.get(j);
            if (temp.plugin == dep.plugin) {
              found = true;
              if (entry.install) {
                temp.parents.add(entry);
                setValueAt(Boolean.TRUE, j, 0);
              } else temp.parents.remove(entry);

              break;
            }
          }
          if (!found) {
            // the dependency was not found in the filtered list so we search in
            // global list.
            for (int a = 0; a < entries.size(); a++) {
              Entry temp = (Entry) entries.get(a);
              if (temp.plugin == dep.plugin) {
                if (entry.install) {
                  temp.parents.add(entry);
                  temp.install = true;
                } else temp.parents.remove(entry);
                break;
              }
            }
          }
        }
      }
      updateFilteredEntries();
    } // }}}
    // {{{ deselectParents() method
    private void deselectParents(Entry entry) {
      Entry[] parents = entry.getParents();

      if (parents.length == 0) return;

      String[] args = {entry.name};
      int result = GUIUtilities.listConfirm(window, "plugin-manager.dependency", args, parents);
      if (result != JOptionPane.OK_OPTION) {
        entry.install = true;
        return;
      }

      for (int i = 0; i < parents.length; i++) parents[i].install = false;

      fireTableRowsUpdated(0, getRowCount() - 1);
    } // }}}
示例#8
0
    /**
     * Include row if each matcher succeeds in at least one column. In other words all the
     * conditions are combined with "and"
     *
     * @param value
     * @return
     */
    @Override
    public boolean include(Entry value) {

      for (Pair<String, Matcher> entry : matchers) {
        String column = entry.getFirst();
        Matcher matcher = entry.getSecond();

        // Search for a match in at least one column.  The first column is the checkbox.
        boolean found = false; // Pessimistic
        int nColumns = table.getColumnCount();
        for (int index = 1; index < nColumns; index++) {

          // Include column headings in search.  This is to prevent premature filtering when
          // entering a
          // specific column condition (e.g. cataType=ChipSeq)
          matcher.reset(table.getColumnName(index).toLowerCase());
          if (matcher.find()) {
            found = true;
            break;
          }

          boolean wildcard = column.equals("*");
          if (wildcard || column.equalsIgnoreCase(table.getColumnName(index))) {
            matcher.reset(value.getStringValue(index));
            if (matcher.find()) {
              found = true;
              break;
            }
          }
        }
        if (!found) return false;
      }
      return true; // If we get here we matched them all
    }
示例#9
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;
  }
示例#10
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);
    }
  }
示例#11
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");
      }
    }
  }