Exemplo n.º 1
0
 /**
  * A change in the text fields.
  *
  * @param e the document event.
  */
 private void documentChanged(DocumentEvent e) {
   if (e.getDocument().equals(fileCountField.getDocument())) {
     // set file count only if its un integer
     try {
       int newFileCount = Integer.valueOf(fileCountField.getText());
       fileCountField.setForeground(Color.black);
       LoggingUtilsActivator.getPacketLoggingService()
           .getConfiguration()
           .setLogfileCount(newFileCount);
     } catch (Throwable t) {
       fileCountField.setForeground(Color.red);
     }
   } else if (e.getDocument().equals(fileSizeField.getDocument())) {
     // set file size only if its un integer
     try {
       int newFileSize = Integer.valueOf(fileSizeField.getText());
       fileSizeField.setForeground(Color.black);
       LoggingUtilsActivator.getPacketLoggingService()
           .getConfiguration()
           .setLimit(newFileSize * 1000);
     } catch (Throwable t) {
       fileSizeField.setForeground(Color.red);
     }
   }
 }
Exemplo n.º 2
0
  private void init(final EncodeTableModel model) {
    setModal(true);
    setTitle("Encode Production Data");

    table.setAutoCreateRowSorter(true);
    table.setModel(model);
    table.setRowSorter(model.getSorter());
    try {
      rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
    } catch (ParseException e) {

    }

    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    filterTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void insertUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void removeUpdate(DocumentEvent e) {
                updateFilter();
              }
            });
  }
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
  /**
   * Replace the path component under the caret with the file selected from the completion list.
   *
   * @param file the selected file.
   * @param caretPos
   * @param start the start offset of the path component under the caret.
   * @param end the end offset of the path component under the caret.
   * @throws BadLocationException
   */
  private void replacePathComponent(LookupFile file, int caretPos, int start, int end)
      throws BadLocationException {
    final Document doc = myPathTextField.getDocument();

    myPathTextField.setSelectionStart(0);
    myPathTextField.setSelectionEnd(0);

    final String name = file.getName();
    boolean toRemoveExistingName;
    String prefix = "";

    if (caretPos >= start) {
      prefix = doc.getText(start, caretPos - start);
      if (prefix.length() == 0) {
        prefix = doc.getText(start, end - start);
      }
      if (SystemInfo.isFileSystemCaseSensitive) {
        toRemoveExistingName = name.startsWith(prefix) && prefix.length() > 0;
      } else {
        toRemoveExistingName =
            name.toUpperCase().startsWith(prefix.toUpperCase()) && prefix.length() > 0;
      }
    } else {
      toRemoveExistingName = true;
    }

    int newPos;
    if (toRemoveExistingName) {
      doc.remove(start, end - start);
      doc.insertString(start, name, doc.getDefaultRootElement().getAttributes());
      newPos = start + name.length();
    } else {
      doc.insertString(caretPos, name, doc.getDefaultRootElement().getAttributes());
      newPos = caretPos + name.length();
    }

    if (file.isDirectory()) {
      if (!myFinder.getSeparator().equals(doc.getText(newPos, 1))) {
        doc.insertString(
            newPos, myFinder.getSeparator(), doc.getDefaultRootElement().getAttributes());
        newPos++;
      }
    }

    if (newPos < doc.getLength()) {
      if (myFinder.getSeparator().equals(doc.getText(newPos, 1))) {
        newPos++;
      }
    }
    myPathTextField.setCaretPosition(newPos);
  }
  private void processChosenFromCompletion(boolean nameOnly) {
    final LookupFile file = getSelectedFileFromCompletionPopup();
    if (file == null) return;

    if (nameOnly) {
      try {
        final Document doc = myPathTextField.getDocument();
        int caretPos = myPathTextField.getCaretPosition();
        if (myFinder.getSeparator().equals(doc.getText(caretPos, 1))) {
          for (; caretPos < doc.getLength(); caretPos++) {
            final String eachChar = doc.getText(caretPos, 1);
            if (!myFinder.getSeparator().equals(eachChar)) break;
          }
        }

        int start = caretPos > 0 ? caretPos - 1 : caretPos;
        while (start >= 0) {
          final String each = doc.getText(start, 1);
          if (myFinder.getSeparator().equals(each)) {
            start++;
            break;
          }
          start--;
        }

        int end = start < caretPos ? caretPos : start;
        while (end <= doc.getLength()) {
          final String each = doc.getText(end, 1);
          if (myFinder.getSeparator().equals(each)) {
            break;
          }
          end++;
        }

        if (end > doc.getLength()) {
          end = doc.getLength();
        }

        if (start > end || start < 0 || end > doc.getLength()) {
          setTextToFile(file);
        } else {
          replacePathComponent(file, caretPos, start, end);
        }
      } catch (BadLocationException e) {
        LOG.error(e);
      }
    } else {
      setTextToFile(file);
    }
  }
 /** The constructor */
 private BranchNameEditor() {
   myDefaultForeground = myTextField.getForeground();
   myTextField
       .getDocument()
       .addDocumentListener(
           new DocumentAdapter() {
             @Override
             protected void textChanged(DocumentEvent e) {
               String s = myTextField.getText();
               if ((myInvalidValues == null || !myInvalidValues.contains(s))
                   && (s.length() == 0 || BranchNameValidator.INSTANCE.checkInput(s))) {
                 myTextField.setForeground(myDefaultForeground);
               } else {
                 myTextField.setForeground(Color.RED);
               }
             }
           });
   myTextField.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopCellEditing();
         }
       });
   myPanel.add(
       myTextField,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
  /** Adds a listener to the text field holding the abbreviation of this data set. */
  private void addTextFieldListener() {
    textField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {

              @Override
              public void removeUpdate(DocumentEvent e) {
                updateNodeName();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                updateNodeName();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                updateNodeName();
              }

              private void updateNodeName() {
                if (dataSetNode != null) {
                  String newExternalName = textField.getText();
                  String internalID =
                      CyGlobals.KPM.externalToInternalIDManager.getInternalIdentifier(
                          dataSetNode.getExternalName());
                  CyGlobals.KPM.externalToInternalIDManager.updateExternalIdentifier(
                      internalID, newExternalName);
                  dataSetNode.setExternalName(newExternalName);
                  dataPanel.dataSetNamesUnique();
                  KPMLinksTab lp = dataPanel.getKPMTabbedPane().getLinksPanel();
                  lp.refreshLogicalFormulaLabel();
                  lParameterPanel.setExternalName(newExternalName);
                }
              }
            });
  }
  /**
   * A constructor
   *
   * @param project the project
   * @param roots the list of the roots
   * @param defaultRoot the default root to select
   */
  public GitUnstashDialog(
      final Project project, final List<VirtualFile> roots, final VirtualFile defaultRoot) {
    super(project, true);
    setModal(false);
    myProject = project;
    myVcs = GitVcs.getInstance(project);
    setTitle(GitBundle.getString("unstash.title"));
    setOKButtonText(GitBundle.getString("unstash.button.apply"));
    GitUIUtil.setupRootChooser(project, roots, defaultRoot, myGitRootComboBox, myCurrentBranch);
    myStashList.setModel(new DefaultListModel());
    refreshStashList();
    myGitRootComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            refreshStashList();
            updateDialogState();
          }
        });
    myStashList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(final ListSelectionEvent e) {
            updateDialogState();
          }
        });
    myBranchTextField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(final DocumentEvent e) {
                updateDialogState();
              }
            });
    myPopStashCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateDialogState();
          }
        });
    myClearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (Messages.YES
                == Messages.showYesNoDialog(
                    GitUnstashDialog.this.getContentPane(),
                    GitBundle.message("git.unstash.clear.confirmation.message"),
                    GitBundle.message("git.unstash.clear.confirmation.title"),
                    Messages.getWarningIcon())) {
              GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
              h.setNoSSH(true);
              h.addParameters("clear");
              GitHandlerUtil.doSynchronously(
                  h, GitBundle.getString("unstash.clearing.stashes"), h.printableCommandLine());
              refreshStashList();
              updateDialogState();
            }
          }
        });
    myDropButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            final StashInfo stash = getSelectedStash();
            if (Messages.YES
                == Messages.showYesNoDialog(
                    GitUnstashDialog.this.getContentPane(),
                    GitBundle.message(
                        "git.unstash.drop.confirmation.message",
                        stash.getStash(),
                        stash.getMessage()),
                    GitBundle.message("git.unstash.drop.confirmation.title", stash.getStash()),
                    Messages.getQuestionIcon())) {
              final ModalityState current = ModalityState.current();
              ProgressManager.getInstance()
                  .run(
                      new Task.Modal(myProject, "Removing stash " + stash.getStash(), false) {
                        @Override
                        public void run(@NotNull ProgressIndicator indicator) {
                          final GitSimpleHandler h = dropHandler(stash.getStash());
                          try {
                            h.run();
                            h.unsilence();
                          } catch (final VcsException ex) {
                            ApplicationManager.getApplication()
                                .invokeLater(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        GitUIUtil.showOperationError(
                                            myProject, ex, h.printableCommandLine());
                                      }
                                    },
                                    current);
                          }
                        }
                      });
              refreshStashList();
              updateDialogState();
            }
          }

          private GitSimpleHandler dropHandler(String stash) {
            GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH);
            h.setNoSSH(true);
            h.addParameters("drop");
            addStashParameter(h, stash);
            return h;
          }
        });
    myViewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            final VirtualFile root = getGitRoot();
            String resolvedStash;
            String selectedStash = getSelectedStash().getStash();
            try {
              GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REV_LIST);
              h.setNoSSH(true);
              h.setSilent(true);
              h.addParameters("--timestamp", "--max-count=1");
              addStashParameter(h, selectedStash);
              h.endOptions();
              final String output = h.run();
              resolvedStash =
                  GitRevisionNumber.parseRevlistOutputAsRevisionNumber(h, output).asString();
            } catch (VcsException ex) {
              GitUIUtil.showOperationError(myProject, ex, "resolving revision");
              return;
            }
            GitShowAllSubmittedFilesAction.showSubmittedFiles(
                myProject, resolvedStash, root, true, false);
          }
        });
    init();
    updateDialogState();
  }
  /**
   * The constructor
   *
   * @param project the project
   * @param target the target configuration
   * @param allChanges the all changes
   * @param roots the collection of roots
   * @param remoteBranch the remote branch
   * @param config the configuration
   * @param isModify the modify flag
   * @throws VcsException if there is a problem with detecting the current state
   */
  protected SwitchBranchesDialog(
      Project project,
      final BranchConfiguration target,
      final List<Change> allChanges,
      List<VirtualFile> roots,
      String remoteBranch,
      final BranchConfigurations config,
      boolean isModify)
      throws VcsException {
    super(project, true);
    setTitle(isModify ? "Modify Branch Configuration" : "Checkout Branch Configuration");
    assert (remoteBranch == null) || (target == null)
        : "There should be no target for remote branch";
    myTarget = target;
    myConfig = config;
    myModify = isModify;
    myProject = project;
    VirtualFile baseDir = project.getBaseDir();
    myBaseFile = baseDir == null ? null : new File(baseDir.getPath());
    myExistingConfigNames = myConfig.getConfigurationNames();
    myChangesTree =
        new ChangesTreeList<Change>(
            myProject,
            Collections.<Change>emptyList(),
            !myModify,
            true,
            null,
            RemoteRevisionsCache.getInstance(project).getChangesNodeDecorator()) {
          protected DefaultTreeModel buildTreeModel(
              final List<Change> changes, ChangeNodeDecorator changeNodeDecorator) {
            TreeModelBuilder builder = new TreeModelBuilder(myProject, false);
            return builder.buildModel(changes, changeNodeDecorator);
          }

          protected List<Change> getSelectedObjects(final ChangesBrowserNode<Change> node) {
            return node.getAllChangesUnder();
          }

          @Nullable
          protected Change getLeadSelectedObject(final ChangesBrowserNode node) {
            final Object o = node.getUserObject();
            if (o instanceof Change) {
              return (Change) o;
            }
            return null;
          }
        };
    if (remoteBranch != null) {
      myBranches = prepareBranchesForRemote(remoteBranch, roots);
    } else {
      myBranches = prepareBranchDescriptors(target, roots);
    }
    Collections.sort(
        myBranches,
        new Comparator<BranchDescriptor>() {
          @Override
          public int compare(BranchDescriptor o1, BranchDescriptor o2) {
            return o1.getRoot().compareTo(o2.getRoot());
          }
        });
    if (target == null) {
      myNameTextField.setText(generateNewConfigurationName());
    } else {
      myNameTextField.setText(target.getName());
    }
    myChangesTree.setChangesToDisplay(allChanges);
    myChangesTree.setIncludedChanges(Collections.<Change>emptyList());
    myChangesPanel.add(myChangesTree, BorderLayout.CENTER);
    myChangesLabel.setLabelFor(myChangesTree);
    if (myModify) {
      myChangesLabel.setText("Changes in the current configuration");
    }
    RootTableModel tableModel = new RootTableModel();
    myBranchesTable.setModel(tableModel);
    myBranchesTable.setDefaultRenderer(Pair.class, new PairTableRenderer());
    final TableColumnModel columns = myBranchesTable.getColumnModel();
    final PairTableRenderer renderer = new PairTableRenderer();
    for (Enumeration<TableColumn> cs = columns.getColumns(); cs.hasMoreElements(); ) {
      cs.nextElement().setCellRenderer(renderer);
    }
    TableColumn revisionColumn = columns.getColumn(RootTableModel.REVISION_COLUMN);
    revisionColumn.setCellEditor(new ReferenceEditor());
    TableColumn branchColumn = columns.getColumn(RootTableModel.NEW_BRANCH_COLUMN);
    branchColumn.setCellEditor(new BranchNameEditor());
    myNameTextField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                verify();
              }
            });
    tableModel.addTableModelListener(
        new TableModelListener() {
          @Override
          public void tableChanged(TableModelEvent e) {
            verify();
          }
        });
    verify();
    init();
  }
Exemplo n.º 10
0
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
Exemplo n.º 11
0
  public CustomizerRun(J2SEProjectProperties uiProperties) {
    this.uiProperties = uiProperties;
    initComponents();

    this.project = uiProperties.getProject();

    nextExtensionYPos = 0;
    // BEGIN Deprecated
    compProviderDeprecated = Lookup.getDefault().lookup(J2SERunConfigProvider.class);
    initExtPanel(project);
    // END Deprecated

    for (J2SECategoryExtensionProvider compProvider :
        project.getLookup().lookupAll(J2SECategoryExtensionProvider.class)) {
      if (compProvider.getCategory() == J2SECategoryExtensionProvider.ExtensibleCategory.RUN) {
        if (addExtPanel(project, compProvider, nextExtensionYPos)) {
          compProviders.add(compProvider);
          nextExtensionYPos++;
        }
      }
    }
    addPanelFiller(nextExtensionYPos);

    configs = uiProperties.RUN_CONFIGS;

    data =
        new JTextField[] {
          jTextFieldMainClass, jTextFieldArgs, jTextVMOptions, jTextWorkingDirectory,
        };
    dataLabels =
        new JLabel[] {
          jLabelMainClass, jLabelArgs, jLabelVMOptions, jLabelWorkingDirectory,
        };
    keys =
        new String[] {
          ProjectProperties.MAIN_CLASS,
          ProjectProperties.APPLICATION_ARGS,
          ProjectProperties.RUN_JVM_ARGS,
          ProjectProperties.RUN_WORK_DIR,
        };
    assert data.length == keys.length;

    configChanged(uiProperties.activeConfig);

    configCombo.setRenderer(new ConfigListCellRenderer());

    for (int i = 0; i < data.length; i++) {
      final JTextField field = data[i];
      final String prop = keys[i];
      final JLabel label = dataLabels[i];
      field
          .getDocument()
          .addDocumentListener(
              new DocumentListener() {
                Font basefont = label.getFont();
                Font boldfont = basefont.deriveFont(Font.BOLD);

                {
                  updateFont();
                }

                public void insertUpdate(DocumentEvent e) {
                  changed();
                }

                public void removeUpdate(DocumentEvent e) {
                  changed();
                }

                public void changedUpdate(DocumentEvent e) {}

                void changed() {
                  String config = (String) configCombo.getSelectedItem();
                  if (config.length() == 0) {
                    config = null;
                  }
                  String v = field.getText();
                  if (v != null && config != null && v.equals(configs.get(null).get(prop))) {
                    // default value, do not store as such
                    v = null;
                  }
                  configs.get(config).put(prop, v);
                  updateFont();
                }

                void updateFont() {
                  String v = field.getText();
                  String config = (String) configCombo.getSelectedItem();
                  if (config.length() == 0) {
                    config = null;
                  }
                  String def = configs.get(null).get(prop);
                  label.setFont(
                      config != null
                              && !Utilities.compareObjects(
                                  v != null ? v : "", def != null ? def : "")
                          ? boldfont
                          : basefont);
                }
              });
    }

    jButtonMainClass.addActionListener(
        new MainClassListener(project.getSourceRoots(), jTextFieldMainClass));
  }
Exemplo n.º 12
0
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }
  public WizStepManyTextFields(Wizard w, String instr, Vector strings) {
    // store wizard?
    _instructions.setText(instr);
    _instructions.setWrapStyleWord(true);
    _instructions.setEditable(false);
    _instructions.setBorder(null);
    _instructions.setBackground(_mainPanel.getBackground());

    _mainPanel.setBorder(new EtchedBorder());

    GridBagLayout gb = new GridBagLayout();
    _mainPanel.setLayout(gb);

    GridBagConstraints c = new GridBagConstraints();
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.EAST;

    JLabel image = new JLabel("");
    // image.setMargin(new Insets(0, 0, 0, 0));
    image.setIcon(WIZ_ICON);
    image.setBorder(null);
    c.gridx = 0;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridy = 0;
    c.anchor = GridBagConstraints.NORTH;
    gb.setConstraints(image, c);
    _mainPanel.add(image);

    c.weightx = 0.0;
    c.gridx = 2;
    c.gridheight = 1;
    c.gridwidth = 3;
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    gb.setConstraints(_instructions, c);
    _mainPanel.add(_instructions);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer = new SpacerPanel();
    gb.setConstraints(spacer, c);
    _mainPanel.add(spacer);

    c.gridx = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    int size = strings.size();
    for (int i = 0; i < size; i++) {
      c.gridy = 2 + i;
      String s = (String) strings.elementAt(i);
      JTextField tf = new JTextField(s, 50);
      tf.setMinimumSize(new Dimension(200, 20));
      tf.getDocument().addDocumentListener(this);
      _fields.addElement(tf);
      gb.setConstraints(tf, c);
      _mainPanel.add(tf);
    }

    c.gridx = 1;
    c.gridy = 3 + strings.size();
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer2 = new SpacerPanel();
    gb.setConstraints(spacer2, c);
    _mainPanel.add(spacer2);
  }
  public FileTextFieldImpl(
      final JTextField field,
      Finder finder,
      LookupFilter filter,
      Map<String, String> macroMap,
      final Disposable parent) {
    myPathTextField = field;
    myMacroMap = new TreeMap<String, String>();
    myMacroMap.putAll(macroMap);

    final InputMap listMap = (InputMap) UIManager.getDefaults().get("List.focusInputMap");
    final KeyStroke[] listKeys = listMap.keys();
    myDisabledTextActions = new HashSet<Action>();
    for (KeyStroke eachListStroke : listKeys) {
      final String listActionID = (String) listMap.get(eachListStroke);
      if ("selectNextRow".equals(listActionID) || "selectPreviousRow".equals(listActionID)) {
        final Object textActionID = field.getInputMap().get(eachListStroke);
        if (textActionID != null) {
          final Action textAction = field.getActionMap().get(textActionID);
          if (textAction != null) {
            myDisabledTextActions.add(textAction);
          }
        }
      }
    }

    final FileTextFieldImpl assigned = (FileTextFieldImpl) myPathTextField.getClientProperty(KEY);
    if (assigned != null) {
      assigned.myFinder = finder;
      assigned.myFilter = filter;
      return;
    }

    myPathTextField.putClientProperty(KEY, this);
    final boolean headless = ApplicationManager.getApplication().isUnitTestMode();

    myUiUpdater = new MergingUpdateQueue("FileTextField.UiUpdater", 200, false, myPathTextField);
    if (!headless) {
      new UiNotifyConnector(myPathTextField, myUiUpdater);
    }

    myFinder = finder;
    myFilter = filter;

    myFileSpitRegExp = myFinder.getSeparator().replaceAll("\\\\", "\\\\\\\\");

    myPathTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void insertUpdate(final DocumentEvent e) {
                processTextChanged();
              }

              public void removeUpdate(final DocumentEvent e) {
                processTextChanged();
              }

              public void changedUpdate(final DocumentEvent e) {
                processTextChanged();
              }
            });

    myPathTextField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(final KeyEvent e) {
            processListSelection(e);
          }
        });

    myPathTextField.addFocusListener(
        new FocusAdapter() {
          public void focusLost(final FocusEvent e) {
            closePopup();
          }
        });

    myCancelAction = new CancelAction();

    new LazyUiDisposable<FileTextFieldImpl>(parent, field, this) {
      protected void initialize(
          @NotNull Disposable parent, @NotNull FileTextFieldImpl child, @Nullable Project project) {
        Disposer.register(child, myUiUpdater);
      }
    };
  }
  FieldEditorHelper(FieldEditor fieldEditor) {
    this.fieldEditor = fieldEditor;

    fieldNameField = fieldEditor.getFieldNameField();
    fieldNameField.getDocument().addDocumentListener(new FieldNameChangeListener());

    dataTypeCombo = fieldEditor.getDataTypeCombo();
    dataTypeCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dataTypeComboAction(e);
          }
        });
    calcTypeCombo = fieldEditor.getCalcTypeCombo();
    calcTypeCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            calcTypeComboAction(e);
          }
        });
    lookupViewCombo = fieldEditor.getLookupViewCombo();
    lookupViewCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            lookupViewComboAction(e);
          }
        });
    lookupFieldCombo = fieldEditor.getLookupFieldCombo();
    lookupFieldCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            lookupFieldComboAction(e);
          }
        });
    objRelationshipCombo = fieldEditor.getObjRelationshipCombo();
    objRelationshipCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            objRelationshipComboAction(e);
          }
        });

    objAttributeCombo = fieldEditor.getObjAttributeCombo();
    objAttributeCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            objAttributeComboAction(e);
          }
        });
    defaultValueField = fieldEditor.getDefaultValueField();
    defaultValueField.getDocument().addDocumentListener(new DefaultValueChangeListener());

    captionField = fieldEditor.getCaptionField();
    captionField.getDocument().addDocumentListener(new CaptionChangeListener());

    editableCheckBox = fieldEditor.getEditableCheckBox();
    editableCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editableCheckBoxAction(e);
          }
        });
    visibleCheckBox = fieldEditor.getVisibleCheckBox();
    visibleCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            visibleCheckBoxAction(e);
          }
        });
    displayClassField = fieldEditor.getDisplayClassField();
    displayClassField.getDocument().addDocumentListener(new DisplayClassChangeListener());

    displayPatternField = fieldEditor.getDisplayPatternField();
    displayPatternField.getDocument().addDocumentListener(new DisplayPatternChangeListener());

    editClassField = fieldEditor.getEditClassField();
    editClassField.getDocument().addDocumentListener(new EditClassChangeListener());

    editPatternField = fieldEditor.getEditPatternField();
    editPatternField.getDocument().addDocumentListener(new EditPatternChangeListener());

    preferredIndexField = fieldEditor.getPreferredIndexField();
    preferredIndexField.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            preferredIndexFieldChanged(e);
          }
        });
  }
  /** Creates the view's listeners */
  public void createListeners() {

    // If the table selection changes, set the currentInsuranceCompany accordingly (Listens to
    // keyboard and mouse)
    insuranceCompaniesTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if ((e.getValueIsAdjusting() == false)
                    && (insuranceCompaniesTable.getSelectedRow() != -1)) {
                  int selectedCompanyId =
                      Integer.valueOf(
                          (String)
                              insuranceCompaniesTable.getValueAt(
                                  insuranceCompaniesTable.getSelectedRow(), 0));
                  controller.selectInsuranceCompany(selectedCompanyId);
                }
              }
            });

    // Add a new InsuranceCompany
    addInsuranceCompanyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            controller.addInsuranceCompany();
          }
        });

    // Save an InsuranceCompany
    saveInsuranceCompanyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Check if a row is selected
            if (insuranceCompaniesTable.getSelectedRow() != -1) {
              int selectedCompanyId =
                  Integer.parseInt(
                      (String)
                          insuranceCompaniesTable.getValueAt(
                              insuranceCompaniesTable.getSelectedRow(), 0));
              String[] newData = {
                companyNameTextField.getText(),
                telephoneTextField.getText(),
                urlTextField.getText(),
                insuranceTypesTextField.getText(),
                percentageTextField.getText(),
                generalDescriptionTextField.getText()
              };

              // Input validation
              boolean checkInput = true;
              for (String input : newData) {
                if ((input.equals("")) || (input.equals(":"))) {
                  checkInput = false;
                }
              }
              // Use regex pattern to check double values
              if (!percentageTextField.getText().matches("(-|\\+)?[0-9]+(\\.[0-9]+)?")) {
                checkInput = false;
              }

              if (checkInput) {
                recordEdited = insuranceCompaniesTable.getSelectedRow();
                controller.updateInsuranceCompany(selectedCompanyId, newData);
              } else {
                showErrorMsg(
                    "Error Saving Insurance Company",
                    "Please enter proper values:\n(Fields cannot be blank or contain \":\")");
              }

            } else {
              showErrorMsg("Error Saving Insurance Company", "Please select a valid table row.");
            }
          }
        });

    // Delete an InsuranceCompany
    deleteInsuranceCompanyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Check if a row is selected
            if (insuranceCompaniesTable.getSelectedRow() != -1) {
              int i =
                  JOptionPane.showConfirmDialog(
                      null,
                      "<html>Are you sure you want to delete following Insurance Company:<br><br><b>ID: "
                          + (String)
                              insuranceCompaniesTable.getValueAt(
                                  insuranceCompaniesTable.getSelectedRow(), 0)
                          + " - "
                          + (String)
                              insuranceCompaniesTable.getValueAt(
                                  insuranceCompaniesTable.getSelectedRow(), 1)
                          + "</b></html>",
                      "Delete Insurance Company",
                      JOptionPane.YES_NO_OPTION);

              if (i == JOptionPane.YES_OPTION) {
                int selectedCompanyId =
                    Integer.parseInt(
                        (String)
                            insuranceCompaniesTable.getValueAt(
                                insuranceCompaniesTable.getSelectedRow(), 0));
                controller.deleteInsuranceCompany(selectedCompanyId);
                searchTextField.setText("");
              }
            } else {
              showErrorMsg("Error Deleting Insurance Company", "Please select a valid table row.");
            }
          }
        });

    // Enable dynamic searching, by just typing into the searchTextField
    searchTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {}

              public void removeUpdate(DocumentEvent e) {
                searchInsuranceCompany();
              }

              public void insertUpdate(DocumentEvent e) {
                searchInsuranceCompany();
              }
            });

    // Clear the searchTextField
    clearSearchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            searchTextField.setText("");
          }
        });

    // Enable sorting
    sortComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String sortStrategy = (String) sortComboBox.getSelectedItem();

            if (sortStrategy.equals("ID")) {
              model.setSortingStrategy(null);
            } else if (sortStrategy.equals("Company Name")) {
              model.setSortingStrategy(new InsuranceCompanyNameComparator());
            } else {
              model.setSortingStrategy(new InsuranceCompanyPercentageComparator());
            }

            updateTable();
          }
        });
  }