Esempio 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();
 }
Esempio n. 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);
   }
 }
Esempio n. 3
0
 private void getParents(List<Entry> list) {
   for (Entry entry : parents) {
     if (entry.install && !list.contains(entry)) {
       list.add(entry);
       entry.getParents(list);
     }
   }
 }
Esempio n. 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();
 }
Esempio n. 5
0
    // {{{ 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));
    } // }}}
Esempio n. 6
0
    // {{{ 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();
    } // }}}
Esempio n. 7
0
    // {{{ 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);
    } // }}}
Esempio n. 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
    }
Esempio n. 9
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);
    }
  }