コード例 #1
0
 /**
  * tests if there should be an empty row appended
  *
  * @param inserting is set: the selected cell will be filled but is not yet
  */
 public void addRow(boolean inserting) {
   int row = replaceTable.getSelectedRow();
   int col = replaceTable.getSelectedColumn();
   if (row + 1 == replaceTable.getRowCount() && col >= 0) {
     boolean[] colSet = new boolean[2];
     colSet[0] = !data.lastElement().firstElement().equals("");
     colSet[1] = !data.lastElement().lastElement().equals("");
     colSet[col] = colSet[col] || inserting;
     if (colSet[0] && colSet[1]) {
       TableCellEditor editor = replaceTable.getCellEditor();
       if (editor != null) {
         row = replaceTable.getEditingRow();
         col = replaceTable.getEditingColumn();
         data.get(row).set(col, editor.getCellEditorValue().toString());
       }
       data.add(new Vector<String>(Arrays.asList(new String[] {"", ""})));
       replaceTable.revalidate();
       CASSubDialog.this.pack();
       Rectangle r = replaceTable.getCellRect(replaceTable.getRowCount() - 1, col, false);
       scrollPane.getViewport().scrollRectToVisible(r);
       if (editor != null) {
         replaceTable.editCellAt(row, col);
       }
     }
   }
 }
コード例 #2
0
  public void openEditWindow() {
    if (!table.isEditing()) return;

    int col = table.getEditingColumn();
    int row = table.getEditingRow();
    String data = null;
    TableCellEditor editor = table.getCellEditor();

    if (editor instanceof WbTextCellEditor) {
      WbTextCellEditor wbeditor = (WbTextCellEditor) editor;
      if (table.isEditing() && wbeditor.isModified()) {
        data = wbeditor.getText();
      } else {
        data = table.getValueAsString(row, col);
      }
    } else {
      data = (String) editor.getCellEditorValue();
    }

    Window owner = SwingUtilities.getWindowAncestor(table);
    Frame ownerFrame = null;
    if (owner instanceof Frame) {
      ownerFrame = (Frame) owner;
    }

    String title = ResourceMgr.getString("TxtEditWindowTitle");
    EditWindow w = new EditWindow(ownerFrame, title, data);
    try {
      w.setVisible(true);
      if (editor != null) {
        // we need to "cancel" the editor so that the data
        // in the editor component will not be written into the
        // table model!
        editor.cancelCellEditing();
      }
      if (!w.isCancelled()) {
        table.setValueAt(w.getText(), row, col);
      }
    } finally {
      w.dispose();
    }
  }
コード例 #3
0
 @Override
 public void editingStopped(ChangeEvent e) {
   TableCellEditor cellEditor = getCellEditor();
   String signalName = signals.get(editingRow);
   if ((cellEditor != null) && (signalName != null)) {
     SignalData signalData = signalDataMap.get(signalName);
     Object value = cellEditor.getCellEditorValue();
     if ((signalData != null) && (value != null)) {
       switch (editingColumn) {
         case COLUMN_VISIBILE:
           signalData.visible = (Boolean) value;
           break;
         case COLUMN_COLOR:
           signalData.color = (Color) value;
           break;
       }
       setValueAt(value, editingRow, editingColumn);
       removeEditor();
     }
   }
 }
コード例 #4
0
ファイル: cmdAssert.java プロジェクト: dawoodamr/Java-SNePS
  private void optionsComboBoxActionPerformed(ActionEvent e) {
    try {
      final int rowNumber = relationNodesetTable.getSelectedRow();
      TableCellEditor cell = relationNodesetTable.getCellEditor(rowNumber, 2);

      if (cell.getCellEditorValue().equals("Base Node")) {
        String nodeName =
            (String)
                JOptionPane.showInputDialog(
                    getRootPane(),
                    "Enter the name of the node:",
                    "Create a Node",
                    JOptionPane.PLAIN_MESSAGE);
        if (nodeName != null) {
          String currentNodesetValue =
              relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

          if (currentNodesetValue.isEmpty()) {
            relationNodesetTableModel.setValueAt(nodeName, rowNumber, 1);
          } else {
            relationNodesetTableModel.setValueAt(
                currentNodesetValue + ", " + nodeName, rowNumber, 1);
          }
        }

      } else if (cell.getCellEditorValue().equals("Variable Node")) {
        Node varNode = network.buildVariableNode();

        String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

        if (currentNodesetValue.isEmpty()) {
          relationNodesetTableModel.setValueAt(varNode.getIdentifier(), rowNumber, 1);
        } else {
          relationNodesetTableModel.setValueAt(
              currentNodesetValue + ", " + varNode.getIdentifier(), rowNumber, 1);
        }
      } else if (cell.getCellEditorValue().equals("build")) {

        JFrame popupFrame = new JFrame("build");
        popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        final cmdBuild buildPanel = new cmdBuild(network, frame, popupFrame);
        popupFrame.getContentPane().add(buildPanel);
        popupFrame.pack();
        popupFrame.setVisible(true);
        Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition();
        popupFrame.setLocation(point);
        doneButton.setEnabled(false);
        popupFrame.addWindowListener(
            new WindowAdapter() {

              @Override
              public void windowClosed(WindowEvent e) {
                LinkedList<Node> nodes = buildPanel.getNodes();
                if (nodes.size() != 0) {
                  for (Node item : nodes) {

                    String currentNodesetValue =
                        relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

                    if (currentNodesetValue.isEmpty()) {
                      relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1);
                    } else {
                      relationNodesetTableModel.setValueAt(
                          currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1);
                    }
                  }
                }

                frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack();
                doneButton.setEnabled(true);
              }
            });

      } else if (cell.getCellEditorValue().equals("assert")) {
        JFrame popupFrame = new JFrame("assert");
        popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        final cmdAssert assertPanel = new cmdAssert(network, frame, popupFrame);
        popupFrame.getContentPane().add(assertPanel);
        popupFrame.pack();
        popupFrame.setVisible(true);
        Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition();
        popupFrame.setLocation(point);
        doneButton.setEnabled(false);
        popupFrame.addWindowListener(
            new WindowAdapter() {

              @Override
              public void windowClosed(WindowEvent e) {
                LinkedList<Node> nodes = assertPanel.getNodes();
                if (nodes.size() != 0) {
                  for (Node item : nodes) {

                    String currentNodesetValue =
                        relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

                    if (currentNodesetValue.isEmpty()) {
                      relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1);
                    } else {
                      relationNodesetTableModel.setValueAt(
                          currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1);
                    }
                  }
                }

                frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack();
                doneButton.setEnabled(true);
              }
            });

      } else if (cell.getCellEditorValue().equals("find")) {
        JFrame popupFrame = new JFrame("find");
        popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        final cmdFind findPanel = new cmdFind(network, frame, popupFrame);
        popupFrame.getContentPane().add(findPanel);
        popupFrame.pack();
        popupFrame.setVisible(true);
        Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition();
        popupFrame.setLocation(point);
        doneButton.setEnabled(false);
        popupFrame.addWindowListener(
            new WindowAdapter() {

              @Override
              public void windowClosed(WindowEvent e) {
                LinkedList<Node> nodes = findPanel.getNodes();
                if (nodes.size() != 0) {
                  for (Node item : nodes) {

                    String currentNodesetValue =
                        relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

                    if (currentNodesetValue.isEmpty()) {
                      relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1);
                    } else {
                      relationNodesetTableModel.setValueAt(
                          currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1);
                    }
                  }
                }

                frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack();
                doneButton.setEnabled(true);
              }
            });
      } else if (cell.getCellEditorValue().equals("Existing Node")) {
        Node node = frame.getsNePSULPanel1().getMenuDrivenCommands().existingNodes();
        if (node != null) {
          String currentNodesetValue =
              relationNodesetTableModel.getValueAt(rowNumber, 1).toString();

          if (currentNodesetValue.isEmpty()) {
            relationNodesetTableModel.setValueAt(node.getIdentifier(), rowNumber, 1);
          } else {
            relationNodesetTableModel.setValueAt(
                currentNodesetValue + ", " + node.getIdentifier(), rowNumber, 1);
          }
        }
      } else if (cell.getCellEditorValue().equals("Act Node")) {
        frame
            .getsNePSULPanel1()
            .getMenuDrivenCommands()
            .actNodes(this, relationNodesetTable, doneButton, relationNodesetTableModel);
      }
      relationNodesetTable.setValueAt(options.getItemAt(0), rowNumber, 2);
      validate();
    } catch (Exception e1) {
    }
  }
コード例 #5
0
ファイル: EachRowEditor.java プロジェクト: Xephoxx/BurpSuite
 public Object getCellEditorValue() {
   return editor.getCellEditorValue();
 }