Search in sources :

Example 36 with ComboBox

use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.

the class EduCCModuleBuilder method modifySettingsStep.

@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
    ModuleWizardStep javaSettingsStep = ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
    Function<JTextField, String> getValue = JTextComponent::getText;
    getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
    getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);
    LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(EduCourseConfigurator.EP_NAME).getExtensions();
    myLanguageComboBox.removeAllItems();
    for (LanguageExtensionPoint extension : extensions) {
        String languageId = extension.getKey();
        Language language = Language.findLanguageByID(languageId);
        if (language == null) {
            LOG.info("Language with id " + languageId + " not found");
        }
        myLanguageComboBox.addItem(new LanguageWrapper(language));
    }
    getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem()).addToSettings(settingsStep);
    getWizardInputField("ccdescr", "", "Description:", myPanel.getDescriptionField(), JTextArea::getText).addToSettings(settingsStep);
    return javaSettingsStep;
}
Also used : Language(com.intellij.lang.Language) ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Function(java.util.function.Function) WizardInputField(com.intellij.ide.util.projectWizard.WizardInputField) JDOMException(org.jdom.JDOMException) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel) StudyProjectGenerator(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator) EduCourseModuleBuilder(com.jetbrains.edu.learning.intellij.generation.EduCourseModuleBuilder) Project(com.intellij.openapi.project.Project) Conditions(com.intellij.openapi.util.Conditions) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ComboBox(com.intellij.openapi.ui.ComboBox) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) IOException(java.io.IOException) StudyTaskManager(com.jetbrains.edu.learning.StudyTaskManager) ProjectWizardStepFactory(com.intellij.ide.util.projectWizard.ProjectWizardStepFactory) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Task(com.jetbrains.edu.learning.courseFormat.Task) JTextComponent(javax.swing.text.JTextComponent) File(java.io.File) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) Nullable(org.jetbrains.annotations.Nullable) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) CCUtils(com.jetbrains.edu.coursecreator.CCUtils) Course(com.jetbrains.edu.learning.courseFormat.Course) javax.swing(javax.swing) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Language(com.intellij.lang.Language) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with ComboBox

use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.

the class ParametersPerConstructorInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final JFormattedTextField valueField = prepareNumberEditor("m_limit");
    final JComboBox comboBox = new ComboBox(new Object[] { Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED });
    comboBox.setRenderer(new ListCellRendererWrapper() {

        @Override
        public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof Scope)
                setText(((Scope) value).getText());
        }
    });
    comboBox.setSelectedItem(ignoreScope);
    comboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ignoreScope = (Scope) comboBox.getSelectedItem();
        }
    });
    comboBox.setPrototypeDisplayValue(Scope.PROTECTED);
    final FormBuilder formBuilder = FormBuilder.createFormBuilder();
    formBuilder.addLabeledComponent(getConfigurationLabel(), valueField);
    formBuilder.addLabeledComponent(InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(formBuilder.getPanel(), BorderLayout.NORTH);
    return panel;
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) ListCellRendererWrapper(com.intellij.ui.ListCellRendererWrapper) ActionListener(java.awt.event.ActionListener)

Example 38 with ComboBox

use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.

the class GradleRunTaskDialog method setUpDialog.

private void setUpDialog() {
    JComponent commandLineComponent;
    if (myHistory == null) {
        commandLineEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
        commandLineComponent = commandLineEditor;
        commandLineLabel.setLabelFor(commandLineEditor);
    } else {
        commandLineComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
        commandLineComponent = commandLineComboBox;
        commandLineLabel.setLabelFor(commandLineComboBox);
        commandLineComboBox.setLightWeightPopupEnabled(false);
        EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, commandLineComboBox);
        //noinspection GtkPreferredJComboBoxRenderer
        commandLineComboBox.setRenderer(new EditorComboBoxRenderer(editor));
        commandLineComboBox.setEditable(true);
        commandLineComboBox.setEditor(editor);
        commandLineComboBox.setFocusable(true);
        commandLineEditor = editor.getEditorComponent();
    }
    commandLinePanel.add(commandLineComponent);
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
    FileChooserDescriptor projectPathChooserDescriptor = null;
    if (manager instanceof ExternalSystemUiAware) {
        projectPathChooserDescriptor = ((ExternalSystemUiAware) manager).getExternalProjectConfigDescriptor();
    }
    if (projectPathChooserDescriptor == null) {
        projectPathChooserDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    }
    String title = ExternalSystemBundle.message("settings.label.select.project", GradleConstants.SYSTEM_ID.getReadableName());
    myProjectPathField = new ExternalProjectPathField(myProject, GradleConstants.SYSTEM_ID, projectPathChooserDescriptor, title) {

        @Override
        public Dimension getPreferredSize() {
            return commandLinePanel == null ? super.getPreferredSize() : commandLinePanel.getPreferredSize();
        }
    };
    projectPathFieldPanel.add(myProjectPathField);
    new GradleArgumentsCompletionProvider(myProject, myProjectPathField).apply(commandLineEditor);
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) GradleArgumentsCompletionProvider(org.jetbrains.plugins.gradle.service.execution.GradleArgumentsCompletionProvider) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) ExternalProjectPathField(com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField) ComboBox(com.intellij.openapi.ui.ComboBox) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) EditorTextField(com.intellij.ui.EditorTextField) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 39 with ComboBox

use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.

the class GitVcsPanel method createUIComponents.

private void createUIComponents() {
    myProtectedBranchesButton = new TextFieldWithBrowseButton.NoPathCompletion(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Messages.showTextAreaDialog(myProtectedBranchesButton.getTextField(), "Protected Branches", "Git.Force.Push.Protected.Branches", ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER);
        }
    });
    myProtectedBranchesButton.setButtonIcon(AllIcons.Actions.ShowViewer);
    myUpdateMethodComboBox = new ComboBox(new EnumComboBoxModel<>(UpdateMethod.class));
    myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper<UpdateMethod>() {

        @Override
        public void customize(JList list, UpdateMethod value, int index, boolean selected, boolean hasFocus) {
            setText(StringUtil.capitalize(StringUtil.toLowerCase(value.name().replace('_', ' '))));
        }
    });
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) EnumComboBoxModel(com.intellij.ui.EnumComboBoxModel) ActionEvent(java.awt.event.ActionEvent) ComboBox(com.intellij.openapi.ui.ComboBox)

Example 40 with ComboBox

use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.

the class EditVariableDialog method createVariablesTable.

private JComponent createVariablesTable() {
    final String[] names = { CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined") };
    // Create a model of the data.
    TableModel dataModel = new VariablesModel(names);
    // Create the table
    myTable = new JBTable(dataModel);
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
    myTable.getColumn(names[0]).setPreferredWidth(120);
    myTable.getColumn(names[1]).setPreferredWidth(200);
    myTable.getColumn(names[2]).setPreferredWidth(200);
    myTable.getColumn(names[3]).setPreferredWidth(100);
    if (myVariables.size() > 0) {
        myTable.getSelectionModel().setSelectionInterval(0, 0);
    }
    Predicate<Macro> isAcceptableInContext = macro -> myContextTypes.stream().anyMatch(macro::isAcceptableInContext);
    Stream<String> availableMacroNames = Arrays.stream(MacroFactory.getMacros()).filter(isAcceptableInContext).map(Macro::getPresentableName).sorted();
    Set<String> uniqueNames = availableMacroNames.collect(Collectors.toCollection(LinkedHashSet::new));
    ComboBox comboField = new ComboBox();
    uniqueNames.forEach(comboField::addItem);
    comboField.setEditable(true);
    DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
    cellEditor.setClickCountToStart(1);
    myTable.getColumn(names[1]).setCellEditor(cellEditor);
    myTable.setRowHeight(comboField.getPreferredSize().height);
    JTextField textField = new JTextField();
    /*textField.addMouseListener(
      new PopupHandler(){
        public void invokePopup(Component comp,int x,int y){
          showCellPopup((JTextField)comp,x,y);
        }
      }
    );*/
    cellEditor = new DefaultCellEditor(textField);
    cellEditor.setClickCountToStart(1);
    myTable.setDefaultEditor(String.class, cellEditor);
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
    return decorator.createPanel();
}
Also used : java.util(java.util) Document(com.intellij.openapi.editor.Document) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) CodeInsightBundle(com.intellij.codeInsight.CodeInsightBundle) TableCellEditor(javax.swing.table.TableCellEditor) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) CommonBundle(com.intellij.CommonBundle) AbstractTableModel(javax.swing.table.AbstractTableModel) TemplateContextType(com.intellij.codeInsight.template.TemplateContextType) TableModel(javax.swing.table.TableModel) ComboBox(com.intellij.openapi.ui.ComboBox) Predicate(java.util.function.Predicate) Editor(com.intellij.openapi.editor.Editor) Collectors(java.util.stream.Collectors) MacroFactory(com.intellij.codeInsight.template.macro.MacroFactory) java.awt(java.awt) CommandProcessor(com.intellij.openapi.command.CommandProcessor) HelpManager(com.intellij.openapi.help.HelpManager) JBTable(com.intellij.ui.table.JBTable) List(java.util.List) Stream(java.util.stream.Stream) Macro(com.intellij.codeInsight.template.Macro) EditableModel(com.intellij.util.ui.EditableModel) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) Macro(com.intellij.codeInsight.template.Macro) ComboBox(com.intellij.openapi.ui.ComboBox) JBTable(com.intellij.ui.table.JBTable) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

Aggregations

ComboBox (com.intellij.openapi.ui.ComboBox)46 Nullable (org.jetbrains.annotations.Nullable)12 ActionListener (java.awt.event.ActionListener)11 ActionEvent (java.awt.event.ActionEvent)10 JBLabel (com.intellij.ui.components.JBLabel)7 NotNull (org.jetbrains.annotations.NotNull)7 JBTextField (com.intellij.ui.components.JBTextField)6 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)5 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)4 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)4 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)4 Project (com.intellij.openapi.project.Project)4 javax.swing (javax.swing)4 Module (com.intellij.openapi.module.Module)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3 java.awt (java.awt)3 ItemEvent (java.awt.event.ItemEvent)3 ItemListener (java.awt.event.ItemListener)3 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2