コード例 #1
0
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
   StartupModel model = this.manager.getActions(rowIndex);
   switch (columnIndex) {
     case -1: // tooltip
       return model.getName();
     case 0:
       return model;
     case 1:
       return InstanceManager.getDefault(StartupActionsManager.class)
           .getFactories(model.getClass())
           .getDescription();
     default:
       return null;
   }
 }
コード例 #2
0
 /** Creates new form StartupActionsPreferencesPanel */
 public StartupActionsPreferencesPanel() {
   initComponents();
   this.actionsTbl
       .getSelectionModel()
       .addListSelectionListener(
           (ListSelectionEvent e) -> {
             int row = this.actionsTbl.getSelectedRow();
             this.upBtn.setEnabled(row != 0 && row != -1);
             this.downBtn.setEnabled(row != this.actionsTbl.getRowCount() - 1 && row != -1);
             this.removeBtn.setEnabled(row != -1);
           });
   ArrayList<JMenuItem> items = new ArrayList<>();
   InstanceManager.getDefault(StartupActionsManager.class)
       .getFactories()
       .values()
       .stream()
       .forEach(
           (factory) -> {
             JMenuItem item = new JMenuItem(factory.getActionText());
             item.addActionListener(
                 (ActionEvent e) -> {
                   StartupModel model = factory.newModel();
                   factory.editModel(model, this.getTopLevelAncestor());
                   if (model.getName() != null && !model.getName().isEmpty()) {
                     InstanceManager.getDefault(StartupActionsManager.class).addAction(model);
                   }
                 });
             items.add(item);
           });
   items.sort((JMenuItem o1, JMenuItem o2) -> o1.getText().compareTo(o2.getText()));
   items
       .stream()
       .forEach(
           (item) -> {
             this.actionsMenu.add(item);
           });
 }