public FrameworkGroupOptionsComponent(
     final FrameworkGroup<?> group, final FrameworkSupportModelBase model) {
   JPanel panel = new JPanel(new VerticalFlowLayout());
   List<? extends FrameworkGroupVersion> versions = group.getGroupVersions();
   if (!versions.isEmpty()) {
     final ComboBox versionsBox = new ComboBox();
     versionsBox.setRenderer(
         new ListCellRendererWrapper<FrameworkGroupVersion>() {
           @Override
           public void customize(
               JList list,
               FrameworkGroupVersion value,
               int index,
               boolean selected,
               boolean hasFocus) {
             setText(value != null ? value.getPresentableName() : "");
           }
         });
     versionsBox.addActionListener(
         new ActionListener() {
           @Override
           public void actionPerformed(ActionEvent e) {
             model.setSelectedVersion(
                 group, (FrameworkGroupVersion) versionsBox.getSelectedItem());
           }
         });
     for (FrameworkGroupVersion version : versions) {
       versionsBox.addItem(version);
     }
     panel.add(
         FormBuilder.createFormBuilder().addLabeledComponent("Version:", versionsBox).getPanel());
   }
   myMainPanel = panel;
 }
  private void initEditor() {
    myEditor =
        new EditorComboBoxEditor(getProject(), getEditorsProvider().getFileType()) {
          @Override
          public void setItem(Object anObject) {
            if (anObject == null) {
              anObject = XExpressionImpl.EMPTY_EXPRESSION;
            }
            XExpression expression = (XExpression) anObject;
            getEditorComponent()
                .setNewDocumentAndFileType(getFileType(expression), createDocument(expression));
          }

          @Override
          protected void onEditorCreate(EditorEx editor) {
            editor.putUserData(DebuggerCopyPastePreprocessor.REMOVE_NEWLINES_ON_PASTE, true);
            editor.getColorsScheme().setEditorFontSize(myComboBox.getFont().getSize());
          }
        };
    myEditor.getEditorComponent().setFontInheritedFromLAF(false);
    myComboBox.setEditor(myEditor);
    // myEditor.setItem(myExpression);
    myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));
    myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
  }
  public BreakpointChooser(
      final Project project,
      Delegate delegate,
      Breakpoint baseBreakpoint,
      List<BreakpointItem> breakpointItems) {
    myDelegate = delegate;

    BreakpointItem breakpointItem = null;
    for (BreakpointItem item : breakpointItems) {
      if (item.getBreakpoint() == baseBreakpoint) {
        breakpointItem = item;
        break;
      }
    }
    myDetailController =
        new DetailController(
            new MasterController() {
              JLabel fake = new JLabel();

              @Override
              public ItemWrapper[] getSelectedItems() {
                return new ItemWrapper[] {((BreakpointItem) myList.getSelectedValue())};
              }

              @Override
              public JLabel getPathLabel() {
                return fake;
              }
            });

    final ItemWrapperListRenderer listRenderer = new ItemWrapperListRenderer(project, null);

    ComboBoxModel model = new CollectionComboBoxModel(breakpointItems, breakpointItem);
    myComboBox =
        new ComboBox(model) {
          @Override
          protected JBList createJBList(ComboBoxModel model) {
            myList = super.createJBList(model);
            myDetailController.setList(myList);
            myList.setCellRenderer(listRenderer);
            return myList;
          }
        };
    myComboBox.setRenderer(listRenderer);

    myComboBox.setSwingPopup(false);
    myComboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent event) {
            myDelegate.breakpointChosen(project, ((BreakpointItem) myComboBox.getSelectedItem()));
          }
        });
  }
 private void updateRenderer(final Project project) {
   myFileChooser.setRenderer(
       new ListCellRendererWrapper<FileDescriptor>() {
         @Override
         public void customize(
             JList list, FileDescriptor value, int index, boolean selected, boolean hasFocus) {
           final PsiFile file = value.myFile;
           setIcon(getIconForFile(file));
           final VirtualFile vFile = file.getVirtualFile();
           setForeground(FileStatusManager.getInstance(project).getStatus(vFile).getColor());
           //noinspection ConstantConditions
           setText(value.getPresentableName(vFile));
         }
       });
 }
  private void setUpNameComboBox(Collection<String> possibleNames) {
    final EditorComboBoxEditor comboEditor =
        new StringComboboxEditor(myProject, HaxeFileType.HAXE_FILE_TYPE, myNameComboBox);

    myNameComboBox.setEditor(comboEditor);
    myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    myNameComboBox.setEditable(true);
    myNameComboBox.setMaximumRowCount(8);

    myContentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myNameComboBox.requestFocus();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK),
        JComponent.WHEN_IN_FOCUSED_WINDOW);

    for (String possibleName : possibleNames) {
      myNameComboBox.addItem(possibleName);
    }
  }
  @Nullable
  private DependencyOnPlugin editPluginDependency(
      @NotNull JComponent parent, @NotNull final DependencyOnPlugin original) {
    List<String> pluginIds = new ArrayList<String>(getPluginNameByIdMap().keySet());
    if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) {
      pluginIds.add(original.getPluginId());
    }
    Collections.sort(
        pluginIds,
        new Comparator<String>() {
          @Override
          public int compare(String o1, String o2) {
            return getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2));
          }
        });

    final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250);
    pluginChooser.setRenderer(
        new ListCellRendererWrapper<String>() {
          @Override
          public void customize(
              JList list, String value, int index, boolean selected, boolean hasFocus) {
            setText(getPluginNameById(value));
          }
        });
    new ComboboxSpeedSearch(pluginChooser) {
      @Override
      protected String getElementText(Object element) {
        return getPluginNameById((String) element);
      }
    };
    pluginChooser.setSelectedItem(original.getPluginId());

    final JBTextField minVersionField =
        new JBTextField(StringUtil.notNullize(original.getMinVersion()));
    final JBTextField maxVersionField =
        new JBTextField(StringUtil.notNullize(original.getMaxVersion()));
    final JBTextField channelField = new JBTextField(StringUtil.notNullize(original.getChannel()));
    minVersionField.getEmptyText().setText("<any>");
    minVersionField.setColumns(10);
    maxVersionField.getEmptyText().setText("<any>");
    maxVersionField.setColumns(10);
    channelField.setColumns(10);
    JPanel panel =
        FormBuilder.createFormBuilder()
            .addLabeledComponent("Plugin:", pluginChooser)
            .addLabeledComponent("Minimum version:", minVersionField)
            .addLabeledComponent("Maximum version:", maxVersionField)
            .addLabeledComponent("Channel:", channelField)
            .getPanel();
    final DialogBuilder dialogBuilder =
        new DialogBuilder(parent).title("Required Plugin").centerPanel(panel);
    dialogBuilder.setPreferredFocusComponent(pluginChooser);
    pluginChooser.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dialogBuilder.setOkActionEnabled(
                !StringUtil.isEmpty((String) pluginChooser.getSelectedItem()));
          }
        });
    if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
      return new DependencyOnPlugin(
          ((String) pluginChooser.getSelectedItem()),
          StringUtil.nullize(minVersionField.getText().trim()),
          StringUtil.nullize(maxVersionField.getText().trim()),
          StringUtil.nullize(channelField.getText().trim()));
    }
    return null;
  }
Ejemplo n.º 7
0
    @Override
    public JComponent createComponent() {
      JPanel panel = new JPanel(new GridLayoutManager(2, 1));

      List<ModelRootManager> managers = ManagerTableCellEditor.getManagers();
      managers.remove(null);
      final ModelRootManager empty = new ModelRootManager("", "Default");
      managers.add(empty);
      myComboBox = new ComboBox(managers.toArray(), 10);
      myComboBox.setRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean selected, boolean focus) {
              ModelRootManager manager = ((ModelRootManager) value);
              String managerName = NameUtil.shortNameFromLongName(manager.getClassName());
              return super.getListCellRendererComponent(list, managerName, index, selected, focus);
            }
          });
      panel.add(
          myComboBox,
          new GridConstraints(
              0,
              0,
              1,
              1,
              GridConstraints.ANCHOR_NORTHWEST,
              GridConstraints.FILL_HORIZONTAL,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              GridConstraints.SIZEPOLICY_FIXED,
              null,
              null,
              null));
      myComboBox.setSelectedItem(
          myModelRoot.getModelRoot().getManager() == null
              ? empty
              : myModelRoot.getModelRoot().getManager());
      myComboBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                ModelRootManager manager = (ModelRootManager) e.getItem();
                myModelRoot.getModelRoot().setManager(manager.equals(empty) ? null : manager);
                myEventDispatcher.getMulticaster().fireDataChanged();
              }
            }
          });

      myTreePanel = new JPanel(new BorderLayout());
      updateTree();
      final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTreePanel);
      panel.add(
          scrollPane,
          new GridConstraints(
              1,
              0,
              1,
              1,
              GridConstraints.ANCHOR_CENTER,
              GridConstraints.FILL_BOTH,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              null,
              null,
              null));

      return panel;
    }