示例#1
2
  public MainPanel() {
    super(new BorderLayout());

    InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke stab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK);
    KeyStroke senter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
    im.put(tab, im.get(enter));
    im.put(stab, im.get(senter));

    final Color orgColor = table.getSelectionBackground();
    final Color tflColor = this.getBackground();
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            table.setSelectionForeground(Color.WHITE);
            table.setSelectionBackground(orgColor);
          }

          @Override
          public void focusLost(FocusEvent e) {
            table.setSelectionForeground(Color.BLACK);
            table.setSelectionBackground(tflColor);
          }
        });

    table.setComponentPopupMenu(new TablePopupMenu());
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }
  private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
示例#3
0
  /**
   * Set the current open DarwinCSV. You should really, really, really setCurrentCSV(null) before
   * you load a new DarwinCSV.
   *
   * @param csv The new DarwinCSV object.
   */
  private void setCurrentCSV(DarwinCSV csv) {
    // Clear the old currentCSV object and matchAgainst object.
    currentCSV = null;
    matchAgainst(null);

    // Load the new currentCSV object.
    currentCSV = csv;
    table.removeAll();
    table.setDefaultRenderer(Name.class, this);

    // Set the currentCSV
    // TODO: This causes an exception occasionally, because we shouldn't
    // be calling setModel outside of the Event Queue thread; however, we're
    // currently in a worker thread, so dipping back into the Event thread
    // would just cause more problems. Sorry!
    if (csv != null) {
      table.setModel(currentCSV.getRowIndex());
    } else {
      table.setModel(blankDataModel);
    }

    columnInfoPanel.loadedFileChanged(csv);
    columnInfoPanel.columnChanged(-1);
    table.repaint();
  }
示例#4
0
  public JointPriorDialog(JFrame frame, BeautiOptions options) {
    this.frame = frame;

    this.options = options;

    priorSettingsPanel = new PriorSettingsPanel(frame);

    nameField.setColumns(30);

    parametersTableModel = new ParametersTableModel();
    //        TableSorter sorter = new TableSorter(traitsTableModel);
    //        traitsTable = new JTable(sorter);
    //        sorter.setTableHeader(traitsTable.getTableHeader());
    parametersTable = new JTable(parametersTableModel);

    parametersTable.getTableHeader().setReorderingAllowed(false);
    parametersTable.getTableHeader().setResizingAllowed(false);
    //        traitsTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    parametersTable
        .getSelectionModel()
        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    parametersTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                parametersSelectionChanged();
              }
            });
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
 private static void drawSelection(JTable table, int column, Graphics g, final int width) {
   int y = 0;
   final int[] rows = table.getSelectedRows();
   final int height = table.getRowHeight();
   for (int row : rows) {
     final TableCellRenderer renderer = table.getCellRenderer(row, column);
     final Component component =
         renderer.getTableCellRendererComponent(
             table, table.getValueAt(row, column), false, false, row, column);
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
示例#8
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof String) {

        String pubType = (String) value;

        if (pubType.equals(IInfoModel.PUBLISHED_TYPE_GLOBAL)) {
          setIcon(WEB_ICON);
        } else {
          setIcon(HOME_ICON);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
示例#9
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // Object o = table.getModel().getValueAt(table.getSelectedRow(), 0);
   int row = table.convertRowIndexToModel(table.getEditingRow());
   Object o = table.getModel().getValueAt(row, 0);
   JOptionPane.showMessageDialog(table, "Editing: " + o);
 }
示例#10
0
    /**
     * Create a Transferable to use as the source for a data transfer.
     *
     * @param c The component holding the data to be transfered. This argument is provided to enable
     *     sharing of TransferHandlers by multiple components.
     * @return The representation of the data to be transfered.
     */
    protected Transferable createTransferable(JComponent c) {
      Object[] values = null;
      if (c instanceof JList) {
        values = ((JList) c).getSelectedValues();
      } else if (c instanceof JTable) {
        JTable table = (JTable) c;
        int[] rows = table.getSelectedRows();
        if (rows != null) {
          values = new Object[rows.length];
          for (int i = 0; i < rows.length; i++) {
            values[i] = table.getValueAt(rows[i], 0);
          }
        }
      }
      if (values == null || values.length == 0) {
        return null;
      }

      StringBuffer plainBuf = new StringBuffer();
      StringBuffer htmlBuf = new StringBuffer();

      htmlBuf.append("<html>\n<body>\n<ul>\n");

      for (Object obj : values) {
        String val = ((obj == null) ? "" : obj.toString());
        plainBuf.append(val + "\n");
        htmlBuf.append("  <li>" + val + "\n");
      }

      // remove the last newline
      plainBuf.deleteCharAt(plainBuf.length() - 1);
      htmlBuf.append("</ul>\n</body>\n</html>");

      return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
    }
示例#11
0
  public void update() {
    infoPanel.update();

    Object[][] history = new Object[account.getHistory().size()][5];
    int i = 0;
    for (Transaction t : account.getHistory()) {
      history[i][0] = t.getType();
      BigDecimal amount;
      BigDecimal balance;
      if (account.getType().isLoan()) {
        amount = (t.getType().isPositive() ? t.getAmount().negate() : t.getAmount());
        balance = t.getBalance().negate();
      } else {
        amount = (t.getType().isPositive() ? t.getAmount() : t.getAmount().negate());
        balance = t.getBalance();
      }
      history[i][1] = FORMATTER.valueToString(amount);
      history[i][2] = FORMATTER.valueToString(balance);
      history[i][3] = t.getTimestamp();
      history[i][4] = t.getFraudStatus();
      i++;
    }
    historyTable.setModel(
        new javax.swing.table.DefaultTableModel(
            history, new String[] {"Type", "Amount", "Balance", "Month", "Flag"}) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        });
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable.revalidate();
  }
  // Fees update method
  private void updateFeesData(long id) {
    String columns[] = {"Course", "Fees Payed", "Total fees", "Installments"};
    try {
      Database db = new Database();

      panel_7.removeAll();

      feestablemodel = new MyTableModel(db.getFeeData(id), columns);

      feestable = new JTable(feestablemodel);
      feestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      feestable.getSelectionModel().addListSelectionListener(this);

      feesscrollpane = new JScrollPane(feestable);
      panel_7.add(feesscrollpane);

      // change fees payed label
      feespayedlabel.setText("Fees Payed");
      feesduelabel.setText("Fees Due");
      totalfeeslabel.setText("Total Fees");

      panel_7.revalidate();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
  // Implementation of valueChanged
  public void valueChanged(ListSelectionEvent e) {
    if (e.getSource() == table.getSelectionModel()) {
      ListSelectionModel ls = table.getSelectionModel();

      int index = ls.getMinSelectionIndex();
      long id = (long) table.getValueAt(index, 0);

      updateFeesData(id);
    } else {
      ListSelectionModel ls = feestable.getSelectionModel();

      int index = ls.getMinSelectionIndex();

      float feespayed = (float) feestable.getValueAt(index, 1);
      float totalfees = (float) feestable.getValueAt(index, 2);

      feespayedlabel.setText("Fees Payed: " + feespayed);
      totalfeeslabel.setText("Total Fees: " + totalfees);

      if (totalfees - feespayed > 0) {
        feesduelabel.setText("Fees Due: " + (totalfees - feespayed));
      }

      panel_6.revalidate();
    }
  }
 private static void setupTable(JTable table, Project project) {
   new TableSpeedSearch(table);
   table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   table.addMouseListener(new MetricTableMouseListener(project, table));
   final JTableHeader tableHeader = table.getTableHeader();
   tableHeader.addMouseListener(new MetricTableHeaderMouseListener(project, table));
 }
 public void setMetricsResults(MetricDisplaySpecification displaySpecification, MetricsRun run) {
   final MetricCategory[] categories = MetricCategory.values();
   for (final MetricCategory category : categories) {
     final JTable table = tables.get(category);
     final String type = MetricsCategoryNameUtil.getShortNameForCategory(category);
     final MetricTableSpecification tableSpecification =
         displaySpecification.getSpecification(category);
     final MetricsResult results = run.getResultsForCategory(category);
     final MetricTableModel model = new MetricTableModel(results, type, tableSpecification);
     table.setModel(model);
     final Container tab = table.getParent().getParent();
     if (model.getRowCount() == 0) {
       tabbedPane.remove(tab);
       continue;
     }
     final String longName = MetricsCategoryNameUtil.getLongNameForCategory(category);
     tabbedPane.add(tab, longName);
     final MyColumnListener columnListener = new MyColumnListener(tableSpecification, table);
     final TableColumnModel columnModel = table.getColumnModel();
     columnModel.addColumnModelListener(columnListener);
     final int columnCount = columnModel.getColumnCount();
     for (int i = 0; i < columnCount; i++) {
       final TableColumn column = columnModel.getColumn(i);
       column.addPropertyChangeListener(columnListener);
     }
     setRenderers(table, type);
     setColumnWidths(table, tableSpecification);
   }
 }
    @Override
    public void valueChanged(ListSelectionEvent e) {

      if (!e.getValueIsAdjusting()) {
        int rowNum = table.getSelectedRow();
        if (rowNum >= 0) {
          // get table model
          PeptideSpeciesPSMTableModel pepTableModel =
              (PeptideSpeciesPSMTableModel) table.getModel();

          // get spectrum reference column
          int identColNum =
              pepTableModel.getColumnIndex(PeptideTableHeader.IDENTIFICATION_ID.getHeader());
          int peptideColNum =
              pepTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_ID.getHeader());

          // get spectrum id
          int modelRowIndex = table.convertRowIndexToModel(rowNum);
          Comparable identId = (Comparable) pepTableModel.getValueAt(modelRowIndex, identColNum);
          Comparable peptideId =
              (Comparable) pepTableModel.getValueAt(modelRowIndex, peptideColNum);

          logger.debug(
              "Peptide table selection:  Protein id: " + identId + " Peptide Id: " + peptideId);

          // fire a background task to retrieve peptide
          if (peptideId != null && identId != null) {
            // publish the event to local event bus
            EventService eventBus =
                ContainerEventServiceFinder.getEventService(PeptidePSMPane.this);
            eventBus.publish(new PSMEvent(PeptidePSMPane.this, controller, identId, peptideId));
          }
        }
      }
    }
 TableToolbarDecorator(@NotNull JTable table, @Nullable final ElementProducer<?> producer) {
   myTable = table;
   myProducer = producer;
   myAddActionEnabled =
       myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = isModelEditable();
   if (isModelEditable()) {
     createDefaultTableActions(producer);
   }
   myTable
       .getSelectionModel()
       .addListSelectionListener(
           new ListSelectionListener() {
             @Override
             public void valueChanged(ListSelectionEvent e) {
               updateButtons();
             }
           });
   myTable.addPropertyChangeListener(
       "enabled",
       new PropertyChangeListener() {
         @Override
         public void propertyChange(PropertyChangeEvent evt) {
           updateButtons();
         }
       });
 }
示例#18
0
    BusinessPane() {
      setLayout(null);
      add(info_label);
      info_label.setBounds(10, 10, 300, 20);
      info_label.setFont(new Font("TimesRoman", Font.BOLD, 12));
      add(info_scroll);
      info_scroll.setBounds(5, 35, 615, 400);
      info_name.add(columnName[0]);
      info_name.add(columnName[1]);
      info_name.add(columnName[2]);
      info_name.add(columnName[3]);
      DefaultTableModel info_model = new DefaultTableModel(info_data, info_name);
      info_table.setModel(info_model);
      info_table.getColumnModel().getColumn(0).setWidth(25);
      info_table.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 1) { // click to trigger the event
                // show_selected();
                // System.out.print(table_selected(0));
              }
            }
          });

      add(B_refresh);
      B_refresh.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_refresh.setBounds(530, 440, 90, 25);
      B_refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              update_table();
            }
          });
    }
示例#19
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof Boolean) {

        Boolean imported = (Boolean) value;

        if (imported.booleanValue()) {
          this.setIcon(FLAG_ICON);
        } else {
          this.setIcon(null);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
    public void popuniSaPodacima(long idSelektiranogKlijenta) {
        // Isprazni tabelu dostava
        //obracuniJTable.setModel(new ObracuniTableModel());

        // Uzmi sve klijente iz baze
        Baza baza = Baza.getBaza();
        List<Klijent> sviKlijenti = baza.dajSve(Klijent.class);
        // izfiltriraj one klijente koji su obrisani
        ukloniObrisaneKlijenteIz(sviKlijenti);

        // Napravi jComboBoxItem-ove sa svim klijentima
        List<JComboBoxItem> sviKlijentiJComboBoxItemi = new ArrayList<JComboBoxItem>();
        for (Klijent k : sviKlijenti) {
            sviKlijentiJComboBoxItemi.add(new JComboBoxItem(k.getId(), k.getIme()));
        }
        // Popuni obracunZaJComboBox sa JComboBoxItem-ovima
        GuiUtilities.popuniJComboBoxSa(sviKlijentiJComboBoxItemi, obracunZaJComboBox, idSelektiranogKlijenta);

        // Popuni tabelu obracuni sa obracunima za klijenta koji ima idSelektiranogKlijenta
        Klijent selektiraniKlijent = baza.dajPoId(Klijent.class, idSelektiranogKlijenta);
        popuniObracuniJTableSaPodacimaOKlijentu(selektiraniKlijent);
        // Oznaci prvi red u tabeli za dostave
        if (obracuniJTable.getRowCount() > 0) {
            ListSelectionModel selectionModel = obracuniJTable.getSelectionModel();
            selectionModel.setSelectionInterval(0, 0);

            // Uzmi oznaceni obracun iz tabele Racun
            Racun oznaceniRacun = ((ObracuniTableModel) obracuniJTable.getModel()).getRacuniZaKlijenta()
                    .get(obracuniJTable.getSelectedRow());
        }

        // Refreshati panel
        osvjeziJPanel();
    }
示例#21
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      NLaboImportSummary summary = (NLaboImportSummary) tableModel.getObject(row);

      if (isSelected) {
        this.setBackground(table.getSelectionBackground());
        this.setForeground(table.getSelectionForeground());

      } else {
        if (summary != null && summary.getKarteId() == null) {

          this.setBackground(UNCONSTRAINED_COLOR);

        } else {

          if ((row & (1)) == 0) {
            this.setBackground(EVEN_COLOR);
          } else {
            this.setBackground(ODD_COLOR);
          }
        }

        this.setForeground(table.getForeground());
      }

      if (value != null && value instanceof String) {
        this.setText((String) value);
      } else {
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
示例#22
0
  private Vector<String> getColumnNames() {
    Vector<String> columnNames = new Vector<String>();

    for (int i = 0; i < jTable1.getColumnCount(); i++) columnNames.add(jTable1.getColumnName(i));

    return columnNames;
  }
      @SuppressWarnings("unchecked")
      private Object initDynamicDefinitionComponent() {
        final String selectedPrimitiveFormName =
            _dotDefinitionDialogFrame.getSelectedPrimitiveForm();
        final DOTProperty currentProperty = _dotDefinitionDialogFrame.getSelectedProperty();
        PrimitiveFormPropertyPair pfpPair =
            new PrimitiveFormPropertyPair(selectedPrimitiveFormName, currentProperty);
        final JTable workWithThisTable = _dynamicTables.get(pfpPair);

        int selectedRow = workWithThisTable.getSelectedRow();
        if (selectedRow == -1) {
          if (workWithThisTable.getModel().getRowCount() > 0) {
            selectedRow = 0;
          } else {
            return null;
          }
        }
        selectedRow = workWithThisTable.convertRowIndexToModel(selectedRow);
        final TableModel model = workWithThisTable.getModel();
        DynamicDOTItemManager dynamicDOTItemManager = (DynamicDOTItemManager) model;
        final DisplayObjectTypeItemWithInterval dotItemWithInterval =
            dynamicDOTItemManager.get(selectedRow);
        _dynamicDefinitionComponent.fillComponents(dotItemWithInterval);
        return dotItemWithInterval.getItem().getPropertyValue();
      }
示例#24
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
示例#25
0
 /**
  * This method initializes ActiveAggTable
  *
  * @return javax.swing.JTable
  */
 private JTable getActiveAggTable() {
   if (ActiveAggTable == null) {
     ActiveAggTable = new JTable();
     controller.activeAgg_ = new ActiveAggTableModel();
     controller.activeAgg_.init(controller);
     ActiveAggTable.setModel(controller.activeAgg_);
     ActiveAggTable.addMouseListener(
         new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent e) {
             if (e.getClickCount() == 2) {
               int row = ActiveAggTable.getSelectedRow();
               if (row >= 0) {
                 aggEditorFrame =
                     new AggEditorFrame(
                         (jAudioFeatureExtractor.Aggregators.Aggregator)
                             controller.activeAgg_.getAggregator(row),
                         controller);
                 aggEditorFrame.setVisible(true);
                 ((ActiveAggTableModel) ActiveAggTable.getModel())
                     .setAggregator(
                         row, aggEditorFrame.getAggregator(), aggEditorFrame.isEdited());
               }
             }
           }
         });
   }
   return ActiveAggTable;
 }
  @Override
  protected void customizeCellRenderer(
      JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
    if (!(value instanceof String)) {
      return;
    }

    String s = (String) value;
    if (shouldClip(s)) {
      s = clip(s);
    }

    SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    String problem = ((StringResourceTableModel) table.getModel()).getCellProblem(row, column);
    if (problem != null) {
      if (ConstantColumn.KEY.ordinal() == column) {
        attributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
      } else {
        attributes = CELL_ERROR_ATTRIBUTES;
      }
    }

    Font currentFont = table.getFont();
    Font f = FontUtil.getFontAbleToDisplay(s, currentFont);
    if (currentFont != f) {
      setFont(f);
    }

    setToolTipText(problem);
    append(s, attributes);
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
示例#28
0
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
  private void createUIComponents() {
    mainPanel = new DollarPanel();

    graphicOfPayments = new JTable();
    JTableHeader header = graphicOfPayments.getTableHeader();
    header.setPreferredSize(new Dimension(graphicOfPayments.getWidth(), HEADERS_HEIGHT));
  }
  public CombatViewer() {
    super("Combat Tracker");
    setLookAndFeel();
    setSize(500, 400);
    FlowLayout layout = new FlowLayout(FlowLayout.CENTER, 10, 10);
    setLayout(layout);

    String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};

    Object[][] data = {
      {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)},
      {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)},
      {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)},
      {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)},
      {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)}
    };

    JTable table = new JTable(data, columnNames);

    JScrollPane scrollPane = new JScrollPane(table);
    table.setFillsViewportHeight(true);

    panel1.setLayout(new BorderLayout());
    panel1.add(table.getTableHeader(), BorderLayout.PAGE_START);
    panel1.add(table, BorderLayout.CENTER);
    add(panel1);

    panel2.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
    panel2.add(testBox);
    add(panel2);

    setVisible(true);
  }