예제 #1
0
 private void initComboBox(String root) {
   Preferences preferences;
   if (SelectProviderPanel.USE_PROJECT_PROPERTIES) {
     preferences =
         ProjectUtils.getPreferences(wizardDescriptor.getProject(), ProviderControl.class, false);
   } else {
     preferences = NbPreferences.forModule(ProviderControl.class);
   }
   field.setStorage(propertyKey, preferences);
   field.read(root);
 }
예제 #2
0
 private void storeHistory() {
   Preferences preferences;
   if (SelectProviderPanel.USE_PROJECT_PROPERTIES) {
     preferences =
         ProjectUtils.getPreferences(wizardDescriptor.getProject(), ProviderControl.class, false);
   } else {
     preferences = NbPreferences.forModule(ProviderControl.class);
     field.setStorage(propertyKey, NbPreferences.forModule(ProviderControl.class));
   }
   field.setStorage(propertyKey, preferences);
   field.store();
 }
예제 #3
0
  private void rootFolderButtonActionPerformed(ActionEvent evt, boolean isBinary, String title) {
    FileFilter[] filters = null;
    if (chooserMode == JFileChooser.FILES_ONLY) {
      if (isBinary) {
        filters = FileFilterFactory.getBinaryFilters();
      } else {
        filters = new FileFilter[] {new LogFileFilter()};
      }
    }

    JFileChooser fileChooser =
        new FileChooser(
            title,
            getString("ROOT_DIR_BUTTON_TXT"), // NOI18N
            chooserMode,
            filters,
            getComboBoxText(),
            false);
    int ret = fileChooser.showOpenDialog(panel);
    if (ret == JFileChooser.CANCEL_OPTION) {
      return;
    }
    String path = fileChooser.getSelectedFile().getPath();
    field.setSelectedItem(path);
  }
예제 #4
0
 private void additionalLibrariesButtonActionPerformed(ActionEvent evt) {
   StringTokenizer tokenizer =
       new StringTokenizer(getComboBoxText(), LIST_LIST_DELIMITER); // NOI18N
   List<String> list = new ArrayList<String>();
   while (tokenizer.hasMoreTokens()) {
     list.add(tokenizer.nextToken());
   }
   AdditionalLibrariesListPanel libPanel = new AdditionalLibrariesListPanel(list);
   DialogDescriptor dialogDescriptor =
       new DialogDescriptor(
           AdditionalLibrariesListPanel.wrapPanel(libPanel),
           getString("ADDITIONAL_LIBRARIES_TXT"));
   DialogDisplayer.getDefault().notify(dialogDescriptor);
   if (dialogDescriptor.getValue() == DialogDescriptor.OK_OPTION) {
     List<String> newList = libPanel.getListData();
     StringBuilder includes = new StringBuilder();
     for (int i = 0; i < newList.size(); i++) {
       if (i > 0) {
         includes.append(LIST_LIST_DELIMITER); // NOI18N
       }
       includes.append(newList.get(i));
     }
     field.setSelectedItem(includes.toString());
   }
 }
예제 #5
0
  private void layout(JPanel panel) {
    GridBagConstraints gridBagConstraints;
    label.setLabelFor(field);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new Insets(4, 0, 0, 0);
    panel.add(label, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(4, 4, 0, 0);
    panel.add(field, gridBagConstraints);
    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < 35; i++) {
      buf.append("w"); // NOI18N
    }
    field.setPrototypeDisplayValue(buf.toString());

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
    gridBagConstraints.anchor = GridBagConstraints.SOUTH;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 4, 0, 0);
    panel.add(button, gridBagConstraints);
  }
예제 #6
0
 private void addListeners() {
   field.addChangeListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           update();
         }
       });
 }
예제 #7
0
 public ProviderControl(
     String key,
     ProviderProperty property,
     DiscoveryDescriptor wizardDescriptor,
     JPanel panel,
     ChangeListener listener) {
   this.propertyKey = key;
   this.property = property;
   this.panel = panel;
   this.listener = listener;
   this.wizardDescriptor = wizardDescriptor;
   description = property.getDescription();
   label = new JLabel();
   Mnemonics.setLocalizedText(label, property.getName());
   switch (property.getKind()) {
     case MakeLogFile:
       field = new EditableComboBox();
       field.setEditable(true);
       chooserMode = JFileChooser.FILES_ONLY;
       initBuildOrRoot(wizardDescriptor);
       button = new JButton();
       Mnemonics.setLocalizedText(button, getString("ROOT_DIR_BROWSE_BUTTON_TXT"));
       layout(panel);
       button.addActionListener(
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent evt) {
               rootFolderButtonActionPerformed(
                   evt,
                   ProviderControl.this.property.getKind() == PropertyKind.BinaryFile,
                   getString("LOG_FILE_CHOOSER_TITLE_TXT"));
             }
           });
       addListeners();
       break;
     case BinaryFile:
       field = new EditableComboBox();
       field.setEditable(true);
       chooserMode = JFileChooser.FILES_ONLY;
       initBuildOrRoot(wizardDescriptor);
       button = new JButton();
       Mnemonics.setLocalizedText(button, getString("ROOT_DIR_BROWSE_BUTTON_TXT"));
       layout(panel);
       button.addActionListener(
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent evt) {
               rootFolderButtonActionPerformed(
                   evt,
                   ProviderControl.this.property.getKind() == PropertyKind.BinaryFile,
                   getString("BINARY_FILE_CHOOSER_TITLE_TXT"));
             }
           });
       addListeners();
       break;
     case Folder:
       field = new EditableComboBox();
       field.setEditable(true);
       chooserMode = JFileChooser.DIRECTORIES_ONLY;
       initRoot(wizardDescriptor);
       button = new JButton();
       Mnemonics.setLocalizedText(button, getString("ROOT_DIR_BROWSE_BUTTON_TXT"));
       layout(panel);
       button.addActionListener(
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent evt) {
               rootFolderButtonActionPerformed(evt, true, getString("ROOT_DIR_CHOOSER_TITLE_TXT"));
             }
           });
       addListeners();
       break;
     case BinaryFiles:
       field = new EditableComboBox();
       field.setEditable(true);
       chooserMode = JFileChooser.FILES_ONLY;
       initArray();
       button = new JButton();
       Mnemonics.setLocalizedText(button, getString("ROOT_DIR_EDIT_BUTTON_TXT"));
       layout(panel);
       button.addActionListener(
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent evt) {
               additionalLibrariesButtonActionPerformed(evt);
             }
           });
       addListeners();
       break;
     default:
       // unsuported UI
       break;
   }
 }
예제 #8
0
 private String getComboBoxText() {
   return field.getText();
 }