コード例 #1
0
  BindToNewBeanStep(@NotNull final WizardData data) {
    myData = data;
    myTableModel = new MyTableModel();
    myTable.setModel(myTableModel);
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myScrollPane.getViewport().setBackground(myTable.getBackground());
    myTable.setSurrendersFocusOnKeystroke(true);

    // Customize "Form Property" column
    {
      final TableColumn column = myTable.getColumnModel().getColumn(0 /*Form Property*/);
      column.setCellRenderer(new FormPropertyTableCellRenderer(myData.myProject));
    }

    // Customize "Bean Property" column
    {
      final TableColumn column = myTable.getColumnModel().getColumn(1 /*Bean Property*/);
      column.setCellRenderer(new BeanPropertyTableCellRenderer());
      column.setCellEditor(new BeanPropertyTableCellEditor());

      final DefaultCellEditor editor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
      editor.setClickCountToStart(1);
    }

    myChkGetData.setSelected(true);
    myChkGetData.setEnabled(false);
    myChkSetData.setSelected(true);
    myChkSetData.setEnabled(false);
    myChkIsModified.setSelected(myData.myGenerateIsModified);
  }
コード例 #2
0
ファイル: EditorPane.java プロジェクト: hencjo/jOOQ
 @Override
 public TableCellEditor getCellEditor(int row, int column) {
   TableCellEditor editor = super.getCellEditor(row, column);
   if (editor instanceof DefaultCellEditor) {
     DefaultCellEditor defaultEditor = (DefaultCellEditor) editor;
     defaultEditor.setClickCountToStart(2);
   }
   return editor;
 }
コード例 #3
0
 @Override
 public TableCellEditor getColumnEditor(int col) {
   if (col == 1) {
     DefaultCellEditor editor = new DefaultCellEditor(deviceButtonBox);
     editor.setClickCountToStart(RMConstants.ClickCountToStart);
     return editor;
   } else if (col == 2) {
     return keyEditor;
   }
   return null;
 }
コード例 #4
0
 @Override
 public boolean stopCellEditing() {
   try {
     return myProxiedEditor.stopCellEditing();
   } catch (ValidationException e) {
     myProxiedEditor
         .getComponent()
         .setBackground(TreeTableCellEditorImpl.INVALID_VALUE_BACKGROUND);
     return false;
   }
 }
コード例 #5
0
ファイル: FileNameEditor.java プロジェクト: twagniws/JetSwing
 /**
  * 入力の制限されたテキストフィールドを返します.
  *
  * @return
  * @throws IllegalArgumentException {@link FileNameEditor#createTreeCellEditorForText()
  *     }で作成されたセルエディタの{@link DefaultCellEditor#getComponent() }が{@link JTextComponent}でないとき
  */
 @Override
 protected final TreeCellEditor createTreeCellEditor() {
   DefaultCellEditor cellEditor = createTreeCellEditorForText();
   if (!(cellEditor.getComponent() instanceof JTextComponent)) {
     throw new IllegalStateException();
   }
   JTextComponent editor = (JTextComponent) cellEditor.getComponent();
   String value = editor.getText();
   editor.setDocument(new FileNameDocument());
   editor.setText(value);
   return cellEditor;
 }
コード例 #6
0
ファイル: USDialog.java プロジェクト: kidaa30/sscctd
  /** Create the dialog. */
  public USDialog(ActionListener listener) {
    setIconImages(Simulator.makeIcons());
    setBounds(100, 100, 450, 300);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JComboBox typeBox = new JComboBox(new DefaultComboBoxModel(Relationship.values()));
      typeEditor = new DefaultCellEditor(typeBox);

      table =
          new JTable(new USValuesTableModel()) {
            // Overridden to return a combobox for duration type
            @Override
            public TableCellEditor getCellEditor(int row, int column) {
              int modelColumn = convertColumnIndexToModel(column);

              if (modelColumn == 0) return typeEditor;
              else return super.getCellEditor(row, column);
            }
          };
      // Make window close on second enter press
      InputMap map = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
      map.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
      table.getColumnModel().getColumn(1).setPreferredWidth(10);
      table.getColumnModel().getColumn(1).setMaxWidth(10);
      table.doLayout();
      // Make single click start editing instead of needing double
      DefaultCellEditor singleClickEditor = new DefaultCellEditor(new JTextField());
      singleClickEditor.setClickCountToStart(1);
      table.setDefaultEditor(Object.class, singleClickEditor);
      table.setCellSelectionEnabled(false);

      JScrollPane scrollPane = new JScrollPane(table);
      contentPanel.add(scrollPane);
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("OK");
        okButton.setActionCommand("OK");
        okButton.addActionListener(listener);
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
コード例 #7
0
 @Override
 public boolean isCellEditable(EventObject event) {
   if (event instanceof MouseEvent) {
     MouseEvent mouseEvent = (MouseEvent) event;
     if (mouseEvent.getClickCount() == 2) {
       return false;
     }
     if (mouseEvent.getClickCount() == 1
         && myTable.rowAtPoint(mouseEvent.getPoint()) == myTable.getSelectedRow()
         && myTable.columnAtPoint(mouseEvent.getPoint()) == myTable.getSelectedColumn()) {
       return myProxiedEditor.isCellEditable(null);
     }
   }
   return myProxiedEditor.isCellEditable(event);
 }
コード例 #8
0
  /**
   * This method is for firing a time out notice for cell editing. It notifies the table that
   * editing on the cell has actually stopped and the resultant value on the editor is to be
   * returned to the table cell.
   */
  protected void fireEditingStopped() {

    super.fireEditingStopped();

    assignEditorValue(table2Edit);

    System.out.println("Editing stopped!");
  }
コード例 #9
0
ファイル: ListEditor.java プロジェクト: codesman/josm
  @Override
  protected final JPanel build() {
    JPanel p = new JPanel(new GridBagLayout());
    p.add(new JLabel(tr("Key: {0}", entry.getKey())), GBC.eol().insets(0, 0, 5, 0));
    ListSettingTableModel listModel = new ListSettingTableModel();
    JTable table = new JTable(listModel);
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    table.setTableHeader(null);

    DefaultCellEditor editor = new DefaultCellEditor(new JosmTextField());
    editor.setClickCountToStart(1);
    table.setDefaultEditor(table.getColumnClass(0), editor);

    JScrollPane pane = new JScrollPane(table);
    p.add(pane, GBC.eol().insets(5, 10, 0, 0).fill());
    return p;
  }
コード例 #10
0
ファイル: ParameterTable.java プロジェクト: sunghoon/Other
  /** Create a new component. */
  public ParameterTable() {
    super(new ParameterTableModel());
    final JTable table = this.getTable();

    this.model = (ParameterTableModel) this.getModel();

    DefaultCellEditor textEditor = new DefaultCellEditor(new JTextField());
    textEditor.setClickCountToStart(1);
    table.setDefaultEditor(String.class, textEditor);

    TableColumn nameColumn = table.getColumnModel().getColumn(this.model.getIndex(Column.NAME));
    nameColumn.setCellEditor(textEditor);
    TableColumn typeColumn = table.getColumnModel().getColumn(this.model.getIndex(Column.TYPE));
    typeColumn.setCellEditor(new DefaultCellEditor(new JComboBox<Type>(Type.values())));

    // commit editor on focus lost
    this.getTable().putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  }
コード例 #11
0
 @Override
 public Component getTableCellEditorComponent(
     JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {
   final Component result =
       myProxiedEditor.getTableCellEditorComponent(arg0, arg1, arg2, arg3, arg4);
   if (result instanceof JTextComponent) {
     ((JTextComponent) result).selectAll();
     myFocusCommand = createSelectAllCommand((JTextComponent) result);
   }
   return result;
 }
コード例 #12
0
  @Override
  public boolean stopCellEditing() {

    try {
      if (editGeo.isIndependent()) {
        editGeo.setValue(checkBox.isSelected());
        editGeo.updateCascade();
      }
      // app.storeUndoInfo();

    } catch (Exception ex) {
      ex.printStackTrace();
      super.stopCellEditing();
      editing = false;
      return false;
    }

    editing = false;
    return super.stopCellEditing();
  }
コード例 #13
0
  public LazyCellEditor(final JTextField tf) {
    super(tf);
    super.setClickCountToStart(1);
    delegate =
        new EditorDelegate() {

          boolean isMousePressed = false;

          @Override
          public void setValue(Object value) {
            if (isMousePressed && value != null) {
              SwingUtilities.invokeLater(
                  new Runnable() {

                    public void run() {
                      tf.selectAll();
                    }
                  });
              tf.setText(value.toString());
            } else {
              tf.setText("");
            }
          }

          @Override
          public Object getCellEditorValue() {
            return tf.getText();
          }

          @Override
          public boolean isCellEditable(EventObject anEvent) {
            if (anEvent instanceof MouseEvent) {
              isMousePressed = true;
              return ((MouseEvent) anEvent).getClickCount() >= clickCountToStart;
            }
            isMousePressed = false;
            return true;
          }
        };
  }
コード例 #14
0
ファイル: JBeanEditor.java プロジェクト: fommil/common-utils
        @Override
        public TableCellEditor getCellEditor(int row, int column) {
          MyTableModel model = (MyTableModel) getModel();
          if (column == 0) {
            return null;
          }

          // code repetition with getCellRenderer because of TableCell{Renderer, Editor}
          // non-inheritance
          Class<?> klass = model.getClassAt(row, column);
          PropertyEditorTableAdapter javaBeansEditor = PropertyEditorTableAdapter.forClass(klass);
          if (javaBeansEditor != null) {
            return javaBeansEditor;
          }
          TableCellEditor defaultEditor = getDefaultEditor(klass);
          if (defaultEditor == null) {
            log.warning("No TableCellEditor for " + klass.getName());
          }
          if (defaultEditor instanceof DefaultCellEditor) {
            // default double-click is bad user interaction
            ((DefaultCellEditor) defaultEditor).setClickCountToStart(0);
          }
          return defaultEditor;
        }
コード例 #15
0
 @Override
 public Object getCellEditorValue() {
   return myProxiedEditor.getCellEditorValue();
 }
コード例 #16
0
 @Override
 public void removeCellEditorListener(CellEditorListener arg0) {
   myProxiedEditor.removeCellEditorListener(arg0);
 }
コード例 #17
0
 @Override
 public void addCellEditorListener(CellEditorListener arg0) {
   myProxiedEditor.addCellEditorListener(arg0);
 }
コード例 #18
0
ファイル: GenerateRuleDialog.java プロジェクト: sdnnfv/vCRIB
 @Override
 protected void fireEditingStopped() {
   super.fireEditingStopped();
   System.out.println("ttttttttt");
 }
コード例 #19
0
  public ParameterTablePanel(
      Project project, VariableData[] variableData, final PsiElement... scopeElements) {
    super(new BorderLayout());
    myProject = project;
    myVariableData = variableData;

    myTableModel = new MyTableModel();
    myTable = new JBTable(myTableModel);
    DefaultCellEditor defaultEditor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
    defaultEditor.setClickCountToStart(1);

    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myTable.setCellSelectionEnabled(true);
    TableColumn checkboxColumn = myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN);
    TableUtil.setupCheckboxColumn(checkboxColumn);
    checkboxColumn.setCellRenderer(new CheckBoxTableCellRenderer());
    myTable
        .getColumnModel()
        .getColumn(MyTableModel.PARAMETER_NAME_COLUMN)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
                VariableData data = getVariableData()[row];
                setText(data.name);
                return this;
              }
            });

    myParameterTypeSelectors = new TypeSelector[getVariableData().length];
    for (int i = 0; i < myParameterTypeSelectors.length; i++) {
      final PsiVariable variable = getVariableData()[i].variable;
      final PsiExpression[] occurrences = findVariableOccurrences(scopeElements, variable);
      final TypeSelectorManager manager =
          new TypeSelectorManagerImpl(
              myProject, getVariableData()[i].type, occurrences, areTypesDirected()) {
            @Override
            protected boolean isUsedAfter() {
              return ParameterTablePanel.this.isUsedAfter(variable);
            }
          };
      myParameterTypeSelectors[i] = manager.getTypeSelector();
      getVariableData()[i].type = myParameterTypeSelectors[i].getSelectedType(); // reverse order
    }

    myTypeRendererCombo = new JComboBox(getVariableData());
    myTypeRendererCombo.setOpaque(true);
    myTypeRendererCombo.setBorder(null);
    myTypeRendererCombo.setRenderer(
        new ListCellRendererWrapper<VariableData>() {
          @Override
          public void customize(
              JList list, VariableData value, int index, boolean selected, boolean hasFocus) {
            if (value != null) {
              setText(value.type.getPresentableText());
            }
          }
        });

    final TableColumn typeColumn =
        myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN);
    typeColumn.setCellEditor(
        new AbstractTableCellEditor() {
          TypeSelector myCurrentSelector;
          final JBComboBoxTableCellEditorComponent myEditorComponent =
              new JBComboBoxTableCellEditorComponent();

          @Nullable
          public Object getCellEditorValue() {
            return myEditorComponent.getEditorValue();
          }

          public Component getTableCellEditorComponent(
              final JTable table,
              final Object value,
              final boolean isSelected,
              final int row,
              final int column) {
            myEditorComponent.setCell(table, row, column);
            myEditorComponent.setOptions(myParameterTypeSelectors[row].getTypes());
            myEditorComponent.setDefaultValue(getVariableData()[row].type);
            myEditorComponent.setToString(
                new Function<Object, String>() {
                  @Override
                  public String fun(Object o) {
                    return ((PsiType) o).getPresentableText();
                  }
                });

            myCurrentSelector = myParameterTypeSelectors[row];
            return myEditorComponent;
          }
        });

    myTable
        .getColumnModel()
        .getColumn(MyTableModel.PARAMETER_TYPE_COLUMN)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              private JBComboBoxLabel myLabel = new JBComboBoxLabel();

              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                myLabel.setText(String.valueOf(value));
                myLabel.setBackground(
                    isSelected ? table.getSelectionBackground() : table.getBackground());
                myLabel.setForeground(
                    isSelected ? table.getSelectionForeground() : table.getForeground());
                if (isSelected) {
                  myLabel.setSelectionIcon();
                } else {
                  myLabel.setRegularIcon();
                }
                return myLabel;
              }
            });

    myTable.setPreferredScrollableViewportSize(new Dimension(250, myTable.getRowHeight() * 5));
    myTable.setShowGrid(false);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    @NonNls final InputMap inputMap = myTable.getInputMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
    @NonNls final ActionMap actionMap = myTable.getActionMap();
    actionMap.put(
        "enable_disable",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (myTable.isEditing()) return;
            int[] rows = myTable.getSelectedRows();
            if (rows.length > 0) {
              boolean valueToBeSet = false;
              for (int row : rows) {
                if (!getVariableData()[row].passAsParameter) {
                  valueToBeSet = true;
                  break;
                }
              }
              for (int row : rows) {
                getVariableData()[row].passAsParameter = valueToBeSet;
              }
              myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]);
              TableUtil.selectRows(myTable, rows);
            }
          }
        });
    //// F2 should edit the name
    // inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name");
    // actionMap.put("edit_parameter_name", new AbstractAction() {
    //  public void actionPerformed(ActionEvent e) {
    //    if (!myTable.isEditing()) {
    //      int row = myTable.getSelectedRow();
    //      if (row >= 0 && row < myTableModel.getRowCount()) {
    //        TableUtil.editCellAt(myTable, row, MyTableModel.PARAMETER_NAME_COLUMN);
    //      }
    //    }
    //  }
    // });

    //// make ENTER work when the table has focus
    // inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl");
    // actionMap.put("invokeImpl", new AbstractAction() {
    //  public void actionPerformed(ActionEvent e) {
    //    TableCellEditor editor = myTable.getCellEditor();
    //    if (editor != null) {
    //      editor.stopCellEditing();
    //    }
    //    else {
    //      doEnterAction();
    //    }
    //  }
    // });

    // make ESCAPE work when the table has focus
    actionMap.put(
        "doCancel",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            TableCellEditor editor = myTable.getCellEditor();
            if (editor != null) {
              editor.stopCellEditing();
            } else {
              doCancelAction();
            }
          }
        });

    JPanel listPanel =
        ToolbarDecorator.createDecorator(myTable)
            .disableAddAction()
            .disableRemoveAction()
            .createPanel();
    add(listPanel, BorderLayout.CENTER);

    if (getVariableData().length > 1) {
      myTable.getSelectionModel().setSelectionInterval(0, 0);
    }
  }
コード例 #20
0
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton8 = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jButton4 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jPanel3 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jButton6 = new javax.swing.JButton();
    jPanel5 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jScrollPane3 = new javax.swing.JScrollPane();
    jTextArea2 = new javax.swing.JTextArea();
    jLabel2 = new javax.swing.JLabel();
    jButton9 = new javax.swing.JButton();
    jButton10 = new javax.swing.JButton();
    jComboBox1 = new javax.swing.JComboBox<String>();
    jPanel7 = new javax.swing.JPanel();
    jButton11 = new javax.swing.JButton();
    jButton12 = new javax.swing.JButton();
    jButton13 = new javax.swing.JButton();
    jButton14 = new javax.swing.JButton();

    setResizable(false);
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
          }
        });
    getContentPane().setLayout(new java.awt.CardLayout());

    jPanel1.setLayout(new java.awt.BorderLayout());

    jButton1.setText("Edit Info Pelanggan");
    jButton1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
          }
        });

    jButton2.setText("Edit Komentar");
    jButton2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
          }
        });

    jButton7.setText("Keluar");
    jButton7.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton7ActionPerformed(evt);
          }
        });

    jButton8.setText("Edit Penerima");
    jButton8.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton8ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel4Layout
                    .createSequentialGroup()
                    .addGap(127, 127, 127)
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(
                                jButton8,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButton1,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButton2,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButton7,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                223,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(126, Short.MAX_VALUE)));
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel4Layout
                    .createSequentialGroup()
                    .addGap(35, 35, 35)
                    .addComponent(
                        jButton1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        43,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jButton2,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        40,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jButton8,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        41,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jButton7,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        39,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(47, Short.MAX_VALUE)));

    jPanel1.add(jPanel4, java.awt.BorderLayout.CENTER);

    getContentPane().add(jPanel1, "card5");

    jTable1.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {}, new String[] {"Info Pelanggan"}));

    jScrollPane1.setViewportView(jTable1);
    DefaultCellEditor dce = new DefaultCellEditor(new JTextField());
    dce.setClickCountToStart(1);
    jTable1.setCellEditor(dce);

    jButton4.setText("Save");
    jButton4.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
          }
        });

    jButton3.setText("+");
    jButton3.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
          }
        });

    jButton5.setText("-");
    jButton5.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(
                jPanel2Layout
                    .createSequentialGroup()
                    .addGap(0, 24, Short.MAX_VALUE)
                    .addComponent(
                        jScrollPane1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(
                jPanel2Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jButton3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton5)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addComponent(jButton4)));
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel2Layout
                    .createSequentialGroup()
                    .addComponent(
                        jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                    .addGap(11, 11, 11)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                jButton4,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                35,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton3)
                            .addComponent(jButton5))));

    getContentPane().add(jPanel2, "card2");

    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane2.setViewportView(jTextArea1);

    jButton6.setText("Save");
    jButton6.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton6ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                jScrollPane2,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                456,
                                Short.MAX_VALUE)
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel3Layout
                                    .createSequentialGroup()
                                    .addGap(0, 0, Short.MAX_VALUE)
                                    .addComponent(jButton6)))
                    .addContainerGap()));
    jPanel3Layout.setVerticalGroup(
        jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addGap(86, 86, 86)
                    .addComponent(
                        jScrollPane2,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jButton6)
                    .addContainerGap(83, Short.MAX_VALUE)));

    getContentPane().add(jPanel3, "card2");

    jLabel1.setText("Pengirim & Alamat");

    jTextArea2.setColumns(20);
    jTextArea2.setRows(5);
    jScrollPane3.setViewportView(jTextArea2);

    jLabel2.setText("Kontak");

    jButton9.setText("Save");
    jButton9.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton9ActionPerformed(evt);
          }
        });

    jButton10.setText("Cancel");
    jButton10.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton10ActionPerformed(evt);
          }
        });

    jComboBox1.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jComboBox1ItemStateChanged(evt);
          }
        });

    jPanel7.setLayout(new java.awt.CardLayout());

    jButton11.setText("+");
    jButton11.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton11ActionPerformed(evt);
          }
        });

    jButton12.setText("-");
    jButton12.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton12ActionPerformed(evt);
          }
        });

    jButton13.setText("-");
    jButton13.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton13ActionPerformed(evt);
          }
        });

    jButton14.setText("+");
    jButton14.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton14ActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
        jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel5Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanel5Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel5Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(
                                        jLabel1,
                                        javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        91,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(
                                        jPanel5Layout
                                            .createSequentialGroup()
                                            .addGroup(
                                                jPanel5Layout
                                                    .createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(
                                                        jComboBox1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        161,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel2)
                                                    .addGroup(
                                                        jPanel5Layout
                                                            .createSequentialGroup()
                                                            .addComponent(jButton14)
                                                            .addPreferredGap(
                                                                javax.swing.LayoutStyle
                                                                    .ComponentPlacement.RELATED)
                                                            .addComponent(jButton13)))
                                            .addGroup(
                                                jPanel5Layout
                                                    .createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                    .addGroup(
                                                        jPanel5Layout
                                                            .createSequentialGroup()
                                                            .addGap(18, 167, Short.MAX_VALUE)
                                                            .addComponent(jButton9)
                                                            .addPreferredGap(
                                                                javax.swing.LayoutStyle
                                                                    .ComponentPlacement.RELATED)
                                                            .addComponent(jButton10))
                                                    .addGroup(
                                                        jPanel5Layout
                                                            .createSequentialGroup()
                                                            .addGap(37, 37, 37)
                                                            .addGroup(
                                                                jPanel5Layout
                                                                    .createParallelGroup(
                                                                        javax.swing.GroupLayout
                                                                            .Alignment.LEADING)
                                                                    .addGroup(
                                                                        jPanel5Layout
                                                                            .createSequentialGroup()
                                                                            .addComponent(jButton11)
                                                                            .addPreferredGap(
                                                                                javax.swing
                                                                                    .LayoutStyle
                                                                                    .ComponentPlacement
                                                                                    .RELATED)
                                                                            .addComponent(
                                                                                jButton12))
                                                                    .addComponent(
                                                                        jPanel7,
                                                                        javax.swing.GroupLayout
                                                                            .PREFERRED_SIZE,
                                                                        179,
                                                                        javax.swing.GroupLayout
                                                                            .PREFERRED_SIZE))
                                                            .addGap(0, 0, Short.MAX_VALUE)))))
                            .addComponent(
                                jScrollPane3,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                412,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jPanel5Layout.setVerticalGroup(
        jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel5Layout
                    .createSequentialGroup()
                    .addComponent(
                        jLabel1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        25,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jScrollPane3,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        98,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel5Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel5Layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        jComboBox1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        jPanel5Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton14)
                                            .addComponent(jButton13))
                                    .addContainerGap())
                            .addGroup(
                                jPanel5Layout
                                    .createSequentialGroup()
                                    .addGap(14, 14, 14)
                                    .addComponent(
                                        jPanel7,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        73,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        jPanel5Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton11)
                                            .addComponent(jButton12))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        25,
                                        Short.MAX_VALUE)
                                    .addGroup(
                                        jPanel5Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton9)
                                            .addComponent(jButton10))))));

    getContentPane().add(jPanel5, "card5");

    pack();
  } // </editor-fold>//GEN-END:initComponents
コード例 #21
0
 @Override
 public void cancelCellEditing() {
   super.cancelCellEditing();
   requestFocusToTree();
 }
コード例 #22
0
 public void itemStateChanged(ItemEvent e) {
   super.fireEditingStopped();
 }
  /**
   * setDataIn
   *
   * @param title
   * @param atributos
   */
  public void setDataIn(String title, List<Atributo> atributos) {
    int condCount = 0;

    String stmp = null;
    String name = null;
    String value = null;

    Atributo atributo = null;
    for (int i = 0; i < atributos.size(); i++) {
      atributo = (Atributo) atributos.get(i);
      if (atributo == null) continue;
      name = atributo.getNome();
      if (name != null
          && name.length() >= varNames[1].length()
          && name.substring(0, varNames[1].length()).equals(varNames[1])) {
        condCount++;
      }
    }

    int nNumCols = columnNames.length;

    data = new Object[condCount][nNumCols];
    HashMap<String, String> hmTypes = new HashMap<String, String>();
    HashMap<String, String> hmCond = new HashMap<String, String>();
    HashMap<String, String> hmDestVar = new HashMap<String, String>();
    HashMap<String, String> hmProf = new HashMap<String, String>();
    HashMap<String, String> hmMsgs = new HashMap<String, String>();
    HashMap<String, String> hmOper = new HashMap<String, String>();
    HashMap<String, String> hmVals = new HashMap<String, String>();
    HashMap<String, String> hmCase = new HashMap<String, String>();

    for (int i = 0; i < atributos.size(); i++) {
      name = ((Atributo) atributos.get(i)).getNome();
      value = ((Atributo) atributos.get(i)).getValor();

      if (name.length() >= varNames[0].length()
          && name.substring(0, varNames[0].length()).equals(varNames[0])) {
        hmTypes.put(name, value);
      } else if (name.length() >= varNames[1].length()
          && name.substring(0, varNames[1].length()).equals(varNames[1])) {
        hmCond.put(name, value);
      } else if (name.length() >= varNames[2].length()
          && name.substring(0, varNames[2].length()).equals(varNames[2])) {
        if (value == null) value = "";
        hmDestVar.put(name, value);
      } else if (name.length() >= varNames[3].length()
          && name.substring(0, varNames[3].length()).equals(varNames[3])) {
        if (value == null) value = "";
        hmProf.put(name, value);
      } else if (name.length() >= varNames[4].length()
          && name.substring(0, varNames[4].length()).equals(varNames[4])) {
        if (value == null) value = "";
        hmMsgs.put(name, value);
      } else if (name.length() >= varNames[5].length()
          && name.substring(0, varNames[5].length()).equals(varNames[5])) {
        if (value == null) value = "";
        hmOper.put(name, value);
      } else if (name.length() >= varNames[6].length()
          && name.substring(0, varNames[6].length()).equals(varNames[6])) {
        if (value == null) value = "";
        hmVals.put(name, value);
      } else if (name.length() >= varNames[7].length()
          && name.substring(0, varNames[7].length()).equals(varNames[7])) {
        if (value == null) value = "";
        hmCase.put(name, value);
      }
    }

    for (int i = 0; i < condCount; i++) {
      data[i][0] = new JComboBox(saTYPES);
      stmp = (String) hmTypes.get(varNames[0] + i);
      if (stmp == null || stmp.equals("")) {
        // default type value
        hmTypes.put(varNames[0] + i, saTYPES[0]);
      }
      ((JComboBox) data[i][0]).setSelectedItem(hmTypes.get(varNames[0] + i));
      data[i][1] = (String) hmCond.get(varNames[1] + i);
      data[i][2] = (String) hmDestVar.get(varNames[2] + i);
      data[i][3] = new JComboBox(saFETCH_MODES);
      ((JComboBox) data[i][3]).setSelectedItem(hmProf.get(varNames[3] + i));
      data[i][4] = new JComboBox(saSEARCH_MODES);
      ((JComboBox) data[i][4]).setSelectedItem(hmMsgs.get(varNames[4] + i));
      data[i][5] = (String) hmOper.get(varNames[5] + i);
      data[i][6] = (String) hmVals.get(varNames[6] + i);
      data[i][7] = new JComboBox(saCASE_MODES);
      ((JComboBox) data[i][7]).setSelectedItem(hmCase.get(varNames[7] + i));

      if (data[i][2] == null) data[i][2] = "";
      if (data[i][5] == null) data[i][5] = "";
      if (data[i][6] == null) data[i][6] = "";
    }

    jTable1 = new MyJTableX(data, columnNames);

    jTable1.setModel(new MyTableModel(columnNames, data));

    jTable1.setRowSelectionAllowed(true);
    jTable1.setColumnSelectionAllowed(false);

    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    MyColumnEditorModel rm = new MyColumnEditorModel();
    jTable1.setMyColumnEditorModel(rm);

    JComboBox jcb0 = new JComboBox(saTYPES);
    DefaultCellEditor ed0 = new DefaultCellEditor(jcb0);
    rm.addEditorForColumn(0, ed0);

    JTextField jtf1 = new JTextField();
    jtf1.setSelectionColor(Color.red);
    jtf1.setSelectedTextColor(Color.white);
    DefaultCellEditor cce = new DefaultCellEditor(jtf1);
    cce.setClickCountToStart(2);
    rm.addEditorForColumn(1, cce);

    JTextField jtf1_2 = new JTextField();
    jtf1_2.setSelectionColor(Color.red);
    jtf1_2.setSelectedTextColor(Color.white);
    DefaultCellEditor mce1_2 = new DefaultCellEditor(jtf1_2);
    mce1_2.setClickCountToStart(2);
    rm.addEditorForColumn(2, mce1_2);

    JComboBox jcb1 = new JComboBox(saFETCH_MODES);
    DefaultCellEditor ed = new DefaultCellEditor(jcb1);
    rm.addEditorForColumn(3, ed);

    JComboBox jcb2 = new JComboBox(saSEARCH_MODES);
    DefaultCellEditor ed2 = new DefaultCellEditor(jcb2);
    rm.addEditorForColumn(4, ed2);

    JTextField jtf3 = new JTextField();
    jtf3.setSelectionColor(Color.red);
    jtf3.setSelectedTextColor(Color.white);
    DefaultCellEditor mce3 = new DefaultCellEditor(jtf3);
    mce3.setClickCountToStart(2);
    rm.addEditorForColumn(5, mce3);

    JTextField jtf4 = new JTextField();
    jtf4.setSelectionColor(Color.red);
    jtf4.setSelectedTextColor(Color.white);
    DefaultCellEditor mce4 = new DefaultCellEditor(jtf4);
    mce4.setClickCountToStart(2);
    rm.addEditorForColumn(6, mce4);

    JComboBox jcb3 = new JComboBox(saCASE_MODES);
    DefaultCellEditor ed3 = new DefaultCellEditor(jcb3);
    rm.addEditorForColumn(7, ed3);

    try {
      jbInit();
      pack();
    } catch (Exception ex) {
      adapter.log("error", ex);
    }

    this.setSize(800, 250);
    setVisible(true);
  }
コード例 #24
0
 @Override
 protected void fireEditingStopped() {
   super.fireEditingStopped();
 }
コード例 #25
0
 @Override
 public boolean shouldSelectCell(EventObject arg0) {
   return myProxiedEditor.shouldSelectCell(arg0);
 }
コード例 #26
0
 /**
  * listener method called when the object in the cell changes. Posts message to the table.
  *
  * @param e the actionevent.
  */
 public void actionPerformed(ActionEvent e) {
   super.fireEditingStopped();
 }
コード例 #27
0
 @Override
 public void cancelCellEditing() {
   myProxiedEditor.cancelCellEditing();
 }
コード例 #28
0
  public void init() {

    // <Begin_init>
    if (getParameter("RESOURCE_PROPERTIES") != null) {
      localePropertiesFileName = getParameter("RESOURCE_PROPERTIES");
    }
    resourceBundle =
        com.adventnet.apiutils.Utility.getBundle(
            localePropertiesFileName, getParameter("RESOURCE_LOCALE"), applet);
    if (initialized) return;
    this.setSize(getPreferredSize().width + 495, getPreferredSize().height + 480);
    setTitle(resourceBundle.getString("ViewConfig"));
    Container container = getContentPane();
    container.setLayout(new BorderLayout());
    try {
      initVariables();
      setUpGUI(container);
      setUpProperties();
      setUpConnections();
    } catch (Exception ex) {
      showStatus(resourceBundle.getString("Error in init method"), ex);
    }
    // let us set the initialized variable to true so
    // we dont initialize again even if init is called
    initialized = true;

    // <End_init>
    setTitle(resourceBundle.getString("View Configuration"));
    setIconImage(AuthMain.getBuilderUiIfInstance().getFrameIcon());
    JLabel1.setIcon(AuthMain.getBuilderUiIfInstance().getImage("viewconfig.png"));
    com.adventnet.security.ui.ViewListCellRenderer ViewListCellRenderer1 =
        new com.adventnet.security.ui.ViewListCellRenderer();
    JTable1.setDefaultRenderer(JTable1.getColumnClass(0), ViewListCellRenderer1);

    JLabel2.setIcon(AuthMain.getBuilderUiIfInstance().getImage("addview1.png"));
    JTable1.getCellEditor(0, 0)
        .getTableCellEditorComponent(JTable1, null, true, 0, 0)
        .setEnabled(false);
    DefaultCellEditor te = (DefaultCellEditor) JTable1.getCellEditor(0, 0);
    te.setClickCountToStart(10);
    JTable1.setCellEditor(te);

    JViewport vp = new JViewport();
    JLabel lab = new JLabel(resourceBundle.getString("List of available views"));
    lab.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
    lab.setForeground(Color.black);
    vp.setView(lab);

    AuthMain.getBuilderUiIfInstance().centerWindow(this);
    setData();

    viewc = this;

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            close();
          }
        });

    /*
    TableColumn col2  = JTable1.getColumnModel().getColumn(1);
    DefaultTableCellRenderer ren = new DefaultTableCellRenderer();
    ren.setIcon(AuthMain.getBuilderUiIfInstance().getImage("task1.png"));
    	col2.setCellRenderer(ren);
     	col2.setMaxWidth(30);
    */

    DefaultListSelectionModel selModel = new DefaultListSelectionModel();
    selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JTable1.setSelectionModel(selModel);
  }
コード例 #29
0
ファイル: TreeView.java プロジェクト: kristoferB/javaSP
  public TreeView(final Model model) {
    super(model, "ProjectView");

    ProjecTreeModel pModel =
        new ProjecTreeModel(model) {

          @Override
          public void valueForPathChanged(TreePath path, Object newValue) {
            Object o = path.getLastPathComponent();

            if (o instanceof TreeNode) {
              model.setName((TreeNode) o, (String) newValue);
            }
          }
        };

    tree =
        new JTree(pModel) {

          @Override
          public boolean isPathEditable(TreePath path) {
            Object p = Model.getParent(path.getLastPathComponent());

            if (p != model.getRoot()) {

              return true;
            }

            return false;
          }

          @Override
          public String getToolTipText(MouseEvent event) {

            TreePath path = tree.getPathForLocation(event.getX(), event.getY());

            if (path != null) {
              Object t = path.getLastPathComponent();

              if (t instanceof TreeNode) {
                return "Id: " + Integer.toString(((TreeNode) t).getId());
              }
            }
            return "";
          };
        };

    ToolTipManager.sharedInstance().registerComponent(tree);

    Renderer r = new Renderer();
    tree.setCellRenderer(r);
    tree.setRootVisible(false);
    tree.setToggleClickCount(1);
    tree.setShowsRootHandles(true);
    tree.setEditable(true);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();

    JTextField comboBox = new JTextField();
    comboBox.setEditable(true);
    DefaultCellEditor comboEditor = new DefaultCellEditor(comboBox);
    comboEditor.setClickCountToStart(99);

    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);

    tree.setCellEditor(editor);
    tree.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F2) {
              tree.startEditingAtPath(tree.getSelectionPath());
            }
          }
        });

    this.setLayout(new BorderLayout());

    this.add(new JScrollPane(tree), BorderLayout.CENTER);

    tree.setDragEnabled(false);
    //      expandListener();
    drag = new TreeDragSource(tree, DnDConstants.ACTION_COPY_OR_MOVE);
  }
コード例 #30
0
ファイル: PanelUsuarios.java プロジェクト: Codeko/Maimonides
  /** Creates new form PanelUsuarios */
  public PanelUsuarios() {
    initComponents();
    tabla.setDefaultEditor(GregorianCalendar.class, new DateCellEditor());
    tabla.setDefaultRenderer(
        GregorianCalendar.class,
        new DefaultTableCellRenderer() {

          @Override
          public void setValue(Object val) {
            if (val instanceof GregorianCalendar) {
              setText(Fechas.format((GregorianCalendar) val));
            } else {
              setText("");
            }
          }
        });
    TableColumnExt colRoles = tabla.getColumnExt("Roles");
    colRoles.setCellEditor(new EditorRoles());
    colRoles.setCellRenderer(
        new DefaultTableCellRenderer() {

          @Override
          public void setValue(Object val) {
            setText(Rol.getTextoRoles(Num.getInt(val)));
          }
        });
    TableColumnExt colTutor = tabla.getColumnExt("Profesor");
    TableColumnExt colClave = tabla.getColumnExt("Clave");
    colClave.setCellRenderer(
        new DefaultTableCellRenderer() {

          @Override
          public void setValue(Object val) {
            setText("*********");
          }
        });
    colClave.setCellEditor(new DefaultCellEditor(new JPasswordField()));
    JComboBox comboTutores = new JComboBox(Profesor.getProfesores().toArray());
    comboTutores.insertItemAt("Sin profesor asignado", 0);
    DefaultCellEditor dceTutor =
        new DefaultCellEditor(comboTutores) {

          @Override
          public Object getCellEditorValue() {
            Object obj = super.getCellEditorValue();
            if (obj instanceof Profesor) {
              return ((Profesor) obj);
            }
            return null;
          }

          @Override
          public Component getTableCellEditorComponent(
              JTable table, Object value, boolean isSelected, int row, int column) {
            Component c = super.getTableCellEditorComponent(tabla, value, isSelected, row, column);
            try {
              int id = Num.getInt(value);
              if (id > 0) {
                Profesor p = Profesor.getProfesor(id);
                ((JComboBox) c).setSelectedItem(p);
              } else {
                ((JComboBox) c).setSelectedIndex(0);
              }
            } catch (Exception ex) {
              Logger.getLogger(PanelGrupos.class.getName()).log(Level.SEVERE, null, ex);
            }
            return c;
          }
        };
    dceTutor.setClickCountToStart(2);
    colTutor.setCellEditor(dceTutor);
  }