public void init(
      final Project project,
      final boolean suggestSearchInLibs,
      final boolean prevSearchWholeFiles,
      final String preselect) {
    mySuggestSearchInLibs = suggestSearchInLibs;
    myPrevSearchFiles = prevSearchWholeFiles;
    myProject = project;
    myScopeListener =
        new NamedScopesHolder.ScopeListener() {
          @Override
          public void scopesChanged() {
            final SearchScope selectedScope = getSelectedScope();
            rebuildModel();
            if (selectedScope != null) {
              selectScope(selectedScope.getDisplayName());
            }
          }
        };
    myNamedScopeManager = NamedScopeManager.getInstance(project);
    myNamedScopeManager.addScopeListener(myScopeListener);
    myValidationManager = DependencyValidationManager.getInstance(project);
    myValidationManager.addScopeListener(myScopeListener);
    addActionListener(createScopeChooserListener());

    final JComboBox combo = getComboBox();
    combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer()));

    rebuildModel();

    selectScope(preselect);
  }
 @NotNull
 JComponent createComponent() {
   myRemoteCombobox = new JComboBox();
   myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer()));
   for (GitRemote remote : myRemotes) {
     myRemoteCombobox.addItem(remote);
   }
   myRemoteCombobox.setToolTipText("Select remote");
   if (myRemotes.size() == 1) {
     myRemoteCombobox.setEnabled(false);
   }
   return myRemoteCombobox;
 }
  public void init() {
    myExistingListsCombo.setRenderer(
        new ColoredListCellRendererWrapper() {
          private final IssueLinkRenderer myLinkRenderer = new IssueLinkRenderer(myProject, this);

          @Override
          protected void doCustomize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof LocalChangeList) {
              String name = ((LocalChangeList) value).getName();

              if (myExistingListsCombo.getWidth() == 0) {
                name = name.length() > 10 ? name.substring(0, 7) + " .." : name;
              } else {
                final FontMetrics fm = list.getFontMetrics(list.getFont());
                final int width = fm.stringWidth(name);
                final int listWidth = myExistingListsCombo.getWidth();
                if ((listWidth > 0) && (width > listWidth)) {
                  final String truncated =
                      CommittedChangeListRenderer.truncateDescription(
                          name, fm, listWidth - fm.stringWidth(" ..") - 7);
                  if (truncated.length() > 5) {
                    name = truncated + " ..";
                  }
                }
              }
              myLinkRenderer.appendTextWithLinks(
                  name,
                  ((LocalChangeList) value).isDefault()
                      ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                      : SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
          }
        });
    myNewListPanel.init(null);
    myRbNew.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            getPreferredFocusedComponent().requestFocusInWindow();
          }
        });
    final ComboboxSpeedSearch search = new ComboboxSpeedSearch(myExistingListsCombo);
    search.setComparator(new SpeedSearchComparator(true, false));
  }
    public ChangeListChooser(List<? extends ChangeList> lists) {
      super(new BorderLayout(4, 2));
      myChooser = new JComboBox();
      //noinspection unchecked
      myChooser.setRenderer(
          new ColoredListCellRendererWrapper<LocalChangeList>() {
            @Override
            protected void doCustomize(
                JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
              if (value != null) {
                String name = value.getName().trim();
                if (name.length() > MAX_LEN) {
                  name = name.substring(0, MAX_LEN - 3) + "...";
                }
                append(
                    name,
                    value.isDefault()
                        ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                        : SimpleTextAttributes.REGULAR_ATTRIBUTES);
              }
            }
          });

      myChooser.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                final LocalChangeList changeList = (LocalChangeList) myChooser.getSelectedItem();
                setSelectedList(changeList);
                myChooser.setToolTipText(changeList == null ? "" : (changeList.getName()));
              }
            }
          });

      updateLists(lists);
      myChooser.setEditable(false);
      add(myChooser, BorderLayout.CENTER);

      JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label"));
      label.setLabelFor(myChooser);
      add(label, BorderLayout.WEST);
    }
  public void setValue(T value, ObjectMeta target) {
    init(m_widgetContext);
    m_parentObject = target;

    valueMap = m_parentObject.getAll(getClassModel().getContainedClass());
    byName = new HashMap<String, ObjectMeta<T>>();
    for (ObjectMeta<T> objectMeta : valueMap.values()) {
      byName.put(objectMeta.getKey(), objectMeta);
    }
    setComboValues(new ArrayList(valueMap.keySet()));
    m_comboBox.setRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof String) {
              T obj = getObj((String) value);
              setToolTipText(getTooltip(obj));
              String t = getLabelText(obj);
              value = t != null ? t : value;
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          }
        });

    /*if (getClassModel().isTreeType()) {
        m_root = new Tree();
        Tree root = getClassModel().getTreeRoot();
        m_root.setPathSeparator(root.pathSeparator());
        m_root.getChildren().add(root);
        m_comboBox.setEditable(true);
    }
    else {
        m_comboBox.setEditable(false);
    }*/

    m_comboBox.setSelectedItem(getKeyByValue(value));
  }
 /** The constructor */
 private ReferenceEditor() {
   myComboBox.setEditable(true);
   myComboBox.setRenderer(new BasicComboBoxRenderer());
   myComboBox.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopCellEditing();
         }
       });
   myPanel.add(
       myComboBox,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
Beispiel #7
0
  public FoodEditor(JFrame parent, RItem data) {
    super(parent, "Scroll Editor: " + data.id);
    this.data = data;

    JPanel itemProps = new JPanel();
    GroupLayout layout = new GroupLayout(itemProps);
    itemProps.setLayout(layout);
    layout.setAutoCreateGaps(true);

    JLabel nameLabel = new JLabel("Name: ");
    JLabel costLabel = new JLabel("Cost: ");
    JLabel colorLabel = new JLabel("Color: ");
    JLabel charLabel = new JLabel("Character: ");
    JLabel weightLabel = new JLabel("Weight: ");
    JLabel spellLabel = new JLabel("Spell: ");
    nameField = new JTextField(15);
    costField = new JFormattedTextField(NeonFormat.getIntegerInstance());
    colorBox = new JComboBox<String>(ColorFactory.getColorNames());
    colorBox.setBackground(Color.black);
    colorBox.setRenderer(new ColorCellRenderer());
    colorBox.addActionListener(new ColorListener(colorBox));
    charField = new JFormattedTextField(getMaskFormatter("*", 'X'));
    weightField = new JFormattedTextField(NeonFormat.getFloatInstance());
    spellBox = new JComboBox<String>(loadSpells());
    JLabel nameHelpLabel = HelpLabels.getNameHelpLabel();
    JLabel costHelpLabel = HelpLabels.getCostHelpLabel();
    JLabel colorHelpLabel = HelpLabels.getColorHelpLabel();
    JLabel charHelpLabel = HelpLabels.getCharHelpLabel();
    JLabel weightHelpLabel = HelpLabels.getWeightHelpLabel();
    JLabel foodHelpLabel = HelpLabels.getFoodEffectHelpLabel();
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(nameLabel)
                    .addComponent(nameField)
                    .addComponent(nameHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(costLabel)
                    .addComponent(costField)
                    .addComponent(costHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(colorLabel)
                    .addComponent(colorBox)
                    .addComponent(colorHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(charLabel)
                    .addComponent(charField)
                    .addComponent(charHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(weightLabel)
                    .addComponent(weightField)
                    .addComponent(weightHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(spellLabel)
                    .addComponent(spellBox)
                    .addComponent(foodHelpLabel)));
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(nameLabel)
                    .addComponent(costLabel)
                    .addComponent(colorLabel)
                    .addComponent(charLabel)
                    .addComponent(weightLabel)
                    .addComponent(spellLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(
                        nameField,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addComponent(costField)
                    .addComponent(colorBox)
                    .addComponent(charField)
                    .addComponent(weightField)
                    .addComponent(spellBox))
            .addGap(10)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(nameHelpLabel)
                    .addComponent(costHelpLabel)
                    .addComponent(colorHelpLabel)
                    .addComponent(charHelpLabel)
                    .addComponent(weightHelpLabel)
                    .addComponent(foodHelpLabel)));

    JScrollPane propScroller = new JScrollPane(itemProps);
    propScroller.setBorder(new TitledBorder("Properties"));
    frame.add(propScroller, BorderLayout.CENTER);
  }
 public void setRenderer(ListCellRenderer<? super Locale> newValue) {
   renderer = null;
   super.setRenderer(newValue);
 }
  public CreateXmlResourceDialog(
      @NotNull Module module,
      @NotNull ResourceType resourceType,
      @Nullable String predefinedName,
      @Nullable String predefinedValue,
      boolean chooseName,
      @Nullable VirtualFile defaultFile) {
    super(module.getProject());
    myResourceType = resourceType;

    if (predefinedName != null && predefinedName.length() > 0) {
      if (!chooseName) {
        myNameLabel.setVisible(false);
        myNameField.setVisible(false);
      }
      myNameField.setText(predefinedName);
    }

    if (predefinedValue != null && predefinedValue.length() > 0) {
      myValueLabel.setVisible(false);
      myValueField.setVisible(false);
      myValueField.setText(predefinedValue);
    }
    final Set<Module> modulesSet = new HashSet<Module>();
    modulesSet.add(module);

    for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) {
      modulesSet.add(depFacet.getModule());
    }

    assert modulesSet.size() > 0;

    if (modulesSet.size() == 1) {
      myModule = module;
      myModuleLabel.setVisible(false);
      myModuleCombo.setVisible(false);
    } else {
      myModule = null;

      final Module[] modules = modulesSet.toArray(new Module[modulesSet.size()]);
      Arrays.sort(
          modules,
          new Comparator<Module>() {
            @Override
            public int compare(Module m1, Module m2) {
              return m1.getName().compareTo(m2.getName());
            }
          });

      myModuleCombo.setModel(new DefaultComboBoxModel(modules));
      myModuleCombo.setSelectedItem(module);
      myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer()));
    }

    if (defaultFile == null) {
      final String defaultFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType);

      if (defaultFileName != null) {
        myFileNameCombo.getEditor().setItem(defaultFileName);
      }
    }
    myDirectoriesList = new CheckBoxList();
    myDirectoriesLabel.setLabelFor(myDirectoriesList);
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);

    decorator.setEditAction(null);
    decorator.disableUpDownActions();

    decorator.setAddAction(
        new AnActionButtonRunnable() {
          @Override
          public void run(AnActionButton button) {
            doAddNewDirectory();
          }
        });

    decorator.setRemoveAction(
        new AnActionButtonRunnable() {
          @Override
          public void run(AnActionButton button) {
            doDeleteDirectory();
          }
        });

    final AnActionButton selectAll =
        new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            doSelectAllDirs();
          }
        };
    decorator.addExtraAction(selectAll);

    final AnActionButton unselectAll =
        new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            doUnselectAllDirs();
          }
        };
    decorator.addExtraAction(unselectAll);

    myDirectoriesPanel.add(decorator.createPanel());

    updateDirectories(true);

    myModuleCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            updateDirectories(true);
          }
        });
    final JCheckBox valuesCheckBox = myCheckBoxes.get(SdkConstants.FD_RES_VALUES);
    if (valuesCheckBox != null) {
      valuesCheckBox.setSelected(true);
    }

    if (defaultFile != null) {
      resetFromFile(defaultFile, module.getProject());
    }
    init();
  }
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
Beispiel #12
0
  protected void dolayout(String strDir, String strFreq, String strTraynum) {
    // TopBar
    String strTitle = gettitle(strFreq);
    Color color = DisplayOptions.getColor("Heading3");

    // Center Panel
    JPanel panelCenter = new JPanel(new GridBagLayout());
    GridBagConstraints gbc =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.2,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0);
    ImageIcon icon = getImageIcon();
    // panelCenter.add(new JLabel(icon));
    addComp(panelCenter, new JLabel(icon), gbc, 0, 0);
    strTitle = getSampleName(strDir, strTraynum);
    m_lblSampleName = new JLabel(strTitle);
    if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3";
    Font font = m_lblSampleName.getFont();
    font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300);
    m_lblSampleName.setFont(font);
    m_lblSampleName.setForeground(color);
    // panelCenter.add(m_lblSampleName);
    m_pnlSampleName = new JPanel(new CardLayout());
    m_pnlSampleName.add(m_lblSampleName, OTHER);
    addComp(panelCenter, m_pnlSampleName, gbc, 1, 0);
    m_pnlSampleName.setVisible(false);
    m_pnlTrays = new JPanel(new GridLayout(1, 0));
    // Vast panels
    VBox pnlVast1 = new VBox(m_pnlTrays, "1");
    m_pnlTrays.add(pnlVast1);
    m_pnlVast[0] = pnlVast1;
    VBox pnlVast2 = new VBox(m_pnlTrays, "2");
    m_pnlTrays.add(pnlVast2);
    m_pnlVast[1] = pnlVast2;
    VBox pnlVast3 = new VBox(m_pnlTrays, "3");
    m_pnlTrays.add(pnlVast3);
    m_pnlVast[2] = pnlVast3;
    VBox pnlVast4 = new VBox(m_pnlTrays, "4");
    m_pnlTrays.add(pnlVast4);
    m_pnlVast[3] = pnlVast4;
    VBox pnlVast5 = new VBox(m_pnlTrays, "5");
    m_pnlTrays.add(pnlVast5);
    m_pnlVast[4] = pnlVast5;
    m_pnlSampleName.add(m_pnlTrays, VAST);

    // Login Panel
    JPanel panelThird = new JPanel(new BorderLayout());
    JPanel panelLogin = new JPanel(new GridBagLayout());
    gbc = new GridBagConstraints();
    panelThird.add(panelLogin);
    Object[] aStrUser = getOperators();
    m_cmbUser = new JComboBox(aStrUser);
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
    m_cmbUser.setRenderer(renderer);
    m_cmbUser.setEditable(true);
    m_passwordField = new JPasswordField();
    // *Warning, working around a Java problem*
    // When we went to the T3500 running Redhat 5.3, the JPasswordField
    // fields sometimes does not allow ANY entry of characters.  Setting
    // the enableInputMethods() to true fixed this problem.  There are
    // comments that indicate that this could cause the typed characters
    // to be visible.  I have not found that to be a problem.
    // This may not be required in the future, or could cause characters
    // to become visible in the future if Java changes it's code.
    // GRS  8/20/09
    m_passwordField.enableInputMethods(true);

    m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0);
    m_lblLogin.setVisible(false);
    okButton.setActionCommand("enter");
    okButton.addActionListener(this);
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    m_passwordField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin();
          }
        });

    // These is some wierd problem such that sometimes, the vnmrj command
    // area gets the focus and these items in the login box do not get
    // the focus.  Even clicking in these items does not bring focus to
    // them.  Issuing requestFocus() does not bring focus to them.
    // I can however, determing if either the operator entry box or
    // the password box has focus and if neither does, I can unshow and
    // reshow the panel and that fixes the focus.  So, I have added this
    // to the mouseClicked action.  If neither has focus, it will
    // take focus with setVisible false then true.
    comboTextField = m_cmbUser.getEditor().getEditorComponent();
    m_passwordField.addMouseListener(this);
    comboTextField.addMouseListener(this);

    m_lblUsername = new JLabel(Util.getLabel("_Operator"));
    addComp(panelLogin, m_lblUsername, gbc, 0, 0);
    addComp(panelLogin, m_cmbUser, gbc, 1, 0);
    m_lblPassword = new JLabel(Util.getLabel("_Password"));
    addComp(panelLogin, m_lblPassword, gbc, 0, 1);
    addComp(panelLogin, m_passwordField, gbc, 1, 1);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    addComp(panelLogin, m_lblLogin, gbc, 2, 0);
    setPref();

    Container container = getContentPane();
    JPanel panelLoginBox = new JPanel(new BorderLayout());
    panelLoginBox.add(panelCenter, BorderLayout.CENTER);
    panelLoginBox.add(panelThird, BorderLayout.SOUTH);
    container.add(panelLoginBox, BorderLayout.CENTER);
  }