List of usage examples for com.intellij.openapi.ui ComboBox ComboBox
public ComboBox(E @NotNull [] items)
From source file:com.vladsch.idea.multimarkdown.settings.MultiMarkdownSettingsPanel.java
License:Apache License
private void createUIComponents() { // TODO: place custom component creation code here // create the css themes combobox, make it locale aware ArrayList<String> options = new ArrayList<String>(10); for (int i = 0;; i++) { String message = MultiMarkdownBundle.messageOrBlank("settings.html-theme-" + (i + 1)); if (message.isEmpty()) break; options.add(message);/*w w w . j a va 2 s .c o m*/ } // we use the list to report but combo box if available htmlThemeList = new JBList(options); htmlThemeList.setSelectedIndex(2); htmlThemeComboBox = new JLabel(); htmlThemeComboBox.setVisible(false); haveCustomizableEditor = false; try { htmlThemeComboBox = new ComboBox(options.toArray(new String[options.size()])); ((JComboBox) htmlThemeComboBox).setSelectedIndex(2); htmlThemeList.setVisible(false); haveCustomizableEditor = true; } catch (NoSuchMethodError e) { // does not exist, use list box } catch (NoClassDefFoundError e) { // does not exist, use list box } // create the CSS text edit control Language language = Language.findLanguageByID("CSS"); final boolean foundCSS = language != null; final FileType fileType = language != null && language.getAssociatedFileType() != null ? language.getAssociatedFileType() : StdFileTypes.PLAIN_TEXT; // Set zoom to 0.1 increments final SpinnerNumberModel model = new SpinnerNumberModel(1.0, 0.2, 5.0, 0.01); pageZoomSpinner = new JSpinner(model); JSpinner.NumberEditor decimalFormat = new JSpinner.NumberEditor(pageZoomSpinner, "0.00"); CustomizableEditorTextField.EditorCustomizationListener listener = new CustomizableEditorTextField.EditorCustomizationListener() { @Override public boolean editorCreated(@NotNull EditorEx editor, @NotNull Project project) { EditorSettings settings = editor.getSettings(); settings.setRightMarginShown(true); //settings.setRightMargin(-1); if (foundCSS) settings.setFoldingOutlineShown(true); settings.setLineNumbersShown(true); if (foundCSS) settings.setLineMarkerAreaShown(true); settings.setIndentGuidesShown(true); settings.setVirtualSpace(true); //settings.setWheelFontChangeEnabled(false); editor.setHorizontalScrollbarVisible(true); editor.setVerticalScrollbarVisible(true); FileType fileTypeH = FileTypeManagerEx.getInstanceEx().getFileTypeByExtension(".css"); FileType highlighterFileType = foundCSS ? fileType : fileTypeH; if (highlighterFileType != null && project != null) { editor.setHighlighter(HighlighterFactory.createHighlighter(project, highlighterFileType)); } int lineCursorWidth = 2; if (haveCustomizableEditor) { // get the standard caret width from the registry try { RegistryValue value = Registry.get("editor.caret.width"); if (value != null) { lineCursorWidth = value.asInteger(); } } catch (Exception ex) { // ignore } focusEditorButton .setEnabled(((CustomizableEditorTextField) textCustomCss).haveSavedState(editor)); } settings.setLineCursorWidth(lineCursorWidth); return false; } }; if (!haveCustomizableEditor) { Project project = CustomizableEditorTextField.getAnyProject(null, true); Document document = CustomizableEditorTextField.createDocument("", fileType, project, new CustomizableEditorTextField.SimpleDocumentCreator()); textCustomCss = new CustomizableLanguageEditorTextField(document, project, fileType, false, false); textCustomCss.setFontInheritedFromLAF(false); ((CustomizableLanguageEditorTextField) textCustomCss).registerListener(listener); //focusEditorButton.setEnabled(false); } else { // we pass a null project because we don't have one, the control will grab any project so that // undo works properly in the edit control. Project project = CustomizableEditorTextField.getAnyProject(null, true); textCustomCss = new CustomizableEditorTextField(fileType, project, "", false); textCustomCss.setFontInheritedFromLAF(false); ((CustomizableEditorTextField) textCustomCss).registerListener(listener); } }
From source file:consulo.google.appengine.java.module.extension.JavaAppMutableModuleExtension.java
License:Apache License
@Override @Nullable//from ww w . j a v a 2s . co m @RequiredUIAccess public JComponent createConfigurablePanel(@Nullable Runnable runnable) { JPanel panel = new JPanel(new VerticalFlowLayout()); panel.add(ModuleExtensionSdkBoxBuilder.createAndDefine(this, runnable).build()); Collection<? extends Artifact> artifactsByType = ArtifactManager.getInstance(getProject()) .getArtifactsByType(ExplodedWarArtifactType.getInstance()); List<String> map = ContainerUtil.map(artifactsByType, new Function<Artifact, String>() { @Override public String fun(Artifact artifact) { return artifact.getName(); } }); final ComboBox box = new ComboBox( new CollectionComboBoxModel(map, myArtifactPointer == null ? null : myArtifactPointer.getName())); box.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList jList, Object o, int i, boolean b, boolean b2) { String artifactName = (String) o; if (artifactName == null) { append(""); return; } Artifact artifact = ArtifactManager.getInstance(getModule().getProject()) .findArtifact(artifactName); if (artifact != null) { append(artifactName); setIcon(artifact.getArtifactType().getIcon()); } else { append(artifactName, SimpleTextAttributes.ERROR_ATTRIBUTES); setIcon(AllIcons.Toolbar.Unknown); } } }); box.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selectedItem = (String) box.getSelectedItem(); if (StringUtil.isEmptyOrSpaces(selectedItem)) { myArtifactPointer = null; } else { myArtifactPointer = ArtifactPointerUtil.getPointerManager(getModule().getProject()) .create((String) selectedItem); } } }); panel.add(LabeledComponent.left(box, "Artifact")); return panel; }
From source file:consulo.javascript.client.module.extension.ClientJavaScriptModuleExtensionPanel.java
License:Apache License
public ClientJavaScriptModuleExtensionPanel(final JavaScriptMutableModuleExtension<?> extension) { super(new VerticalFlowLayout(true, false)); List<BaseJavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions .getValidLanguageVersions(); ComboBox languageVersionComboBox = new ComboBox( new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion())); languageVersionComboBox.addItemListener(new ItemListener() { @Override/*w w w .j a va 2s. c o m*/ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { //noinspection unchecked extension.setLanguageVersion((LanguageVersion) e.getItem()); } } }); languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>() { @Override protected void customizeCellRenderer(JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus) { append(value.getPresentableName()); } }); add(LabeledComponent.left(languageVersionComboBox, "Language Version")); }
From source file:de.mobilej.plugin.adc.ToolWindowFactory.java
License:Apache License
@NotNull private JPanel createPanel(@NotNull Project project) { // Create Panel and Content JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; devices = new ComboBox(new String[] { resourceBundle.getString("device.none") }); c.gridx = 0;// w ww . j a v a2s . c o m c.gridy = 0; panel.add(new JLabel("Device"), c); c.gridx = 1; c.gridy = 0; panel.add(devices, c); showLayoutBounds = new JBCheckBox(resourceBundle.getString("show.layout.bounds")); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; panel.add(showLayoutBounds, c); showLayoutBounds.addActionListener(e -> { final String what = showLayoutBounds.isSelected() ? "true" : "\"\""; final String cmd = "setprop debug.layout " + what; ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; executeShellCommand(cmd, true); userAction = false; }, resourceBundle.getString("setting.values.title"), false, null); }); localeChooser = new ComboBox(LOCALES); c.gridx = 0; c.gridy = 2; c.gridwidth = 2; panel.add(localeChooser, c); localeChooser.addActionListener(e -> { final LocaleData ld = (LocaleData) localeChooser.getSelectedItem(); if (ld == null) { return; } ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; executeShellCommand( "am start -a SETMYLOCALE --es language " + ld.language + " --es country " + ld.county, false); userAction = false; }, resourceBundle.getString("setting.values.title"), false, null); }); goToActivityButton = new JButton(resourceBundle.getString("button.goto_activity")); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; panel.add(goToActivityButton, c); goToActivityButton .addActionListener(e -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; final String result = executeShellCommand("dumpsys activity top", false); userAction = false; if (result == null) { return; } ApplicationManager.getApplication().invokeLater(() -> { String activity = result.substring(result.indexOf("ACTIVITY ") + 9); activity = activity.substring(0, activity.indexOf(" ")); String pkg = activity.substring(0, activity.indexOf("/")); String clz = activity.substring(activity.indexOf("/") + 1); if (clz.startsWith(".")) { clz = pkg + clz; } GlobalSearchScope scope = GlobalSearchScope.allScope(project); PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(clz, scope); if (psiClass != null) { FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); //Open the file containing the class VirtualFile vf = psiClass.getContainingFile().getVirtualFile(); //Jump there new OpenFileDescriptor(project, vf, 1, 0).navigateInEditor(project, false); } else { Messages.showMessageDialog(project, clz, resourceBundle.getString("error.class_not_found"), Messages.getWarningIcon()); return; } }); }, resourceBundle.getString("setting.values.title"), false, null)); inputOnDeviceButton = new JButton(resourceBundle.getString("button.input_on_device")); c.gridx = 0; c.gridy = 4; c.gridwidth = 2; panel.add(inputOnDeviceButton, c); inputOnDeviceButton.addActionListener(e -> { final String text2send = Messages.showMultilineInputDialog(project, resourceBundle.getString("send_text.message"), resourceBundle.getString("send_text.title"), storage.getLastSentText(), Messages.getQuestionIcon(), null); if (text2send != null) { storage.setLastSentText(text2send); ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; doInputOnDevice(text2send); userAction = false; }, resourceBundle.getString("processing.title"), false, null); } }); clearDataButton = new JButton(resourceBundle.getString("button.clear_data")); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; panel.add(clearDataButton, c); clearDataButton.addActionListener(actionEvent -> { ArrayList<String> appIds = new ArrayList<String>(); List<AndroidFacet> androidFacets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID); if (androidFacets != null) { for (AndroidFacet facet : androidFacets) { if (!facet.isLibraryProject()) { AndroidModel androidModel = facet.getAndroidModel(); if (androidModel != null) { String appId = androidModel.getApplicationId(); appIds.add(appId); } } } } ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); userAction = true; for (String appId : appIds) { executeShellCommand("pm clear " + appId, false); } userAction = false; }, resourceBundle.getString("processing.title"), false, null); }); JPanel framePanel = new JPanel(new BorderLayout()); framePanel.add(panel, BorderLayout.NORTH); return framePanel; }
From source file:net.groboclown.idea.p4ic.ui.checkin.P4SubmitPanel.java
License:Apache License
private void createUIComponents() { // place custom component creation code here jobTableModel = new JobTableModel(); myJobTable = new JBTable(jobTableModel); jobStatusModel = new DefaultComboBoxModel(); myJobStatus = new ComboBox(jobStatusModel); }
From source file:net.orfjackal.sbt.plugin.SelectSbtActionDialog.java
License:Open Source License
protected JComponent createCenterPanel() { runInCurrentModuleField = new JCheckBox(); runInCurrentModuleField.setSelected(runInCurrentModule); JLabel runInCurrentModuleLabel = new JLabel(MessageBundle.message("sbt.tasks.select.action.run.current")); runInCurrentModuleLabel//from w w w .ja va 2 s . c o m .setToolTipText(MessageBundle.message("sbt.tasks.select.action.run.current.tooltip")); actionField = new ComboBox(SBT_ACTIONS_WITH_SEPARATOR); actionField.setEditable(true); actionField.setSelectedItem(selectedAction); actionField.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList jList, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value.equals(SEPARATOR)) { return new JSeparator(JSeparator.HORIZONTAL); } if (value.equals(SBT_07_HEADER) || value.equals(SBT_10_HEADER)) { setEnabled(false); setText("<html><b>" + value + "</b></html>"); return this; } return super.getListCellRendererComponent(jList, value, index, isSelected, cellHasFocus); } }); // TODO Make the headings and separator non-selectable. JPanel root = new JPanel(new MigLayout()); root.add(runInCurrentModuleField, ""); root.add(runInCurrentModuleLabel, "wrap"); root.add(actionField, "width 200::, spanx 2"); return root; }
From source file:nim.module.NimModuleTypeEditor.java
License:Open Source License
@Nullable @Override/* www. j a v a2 s. com*/ public JComponent createComponent() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.add(new JLabel("Module type:")); comboModuleType = new ComboBox(new String[] { "Application", "Console application", "Library" }); comboModuleType.setSelectedIndex(moduleTypeToComboIndex(component.getModuleType())); panel.add(comboModuleType); return panel; }
From source file:org.apache.camel.idea.preference.CamelPreferencePage.java
License:Apache License
@Nullable @Override/*from ww w. j a v a2s.c o m*/ public JComponent createComponent() { realTimeEndpointValidationCatalogCheckBox = new JBCheckBox( "Real time validation of Camel endpoints in editor"); realTimeSimpleValidationCatalogCheckBox = new JBCheckBox( "Real time validation of Camel simple language in editor"); highlightCustomOptionsCheckBox = new JBCheckBox("Highlight custom endpoint options as warnings in editor"); downloadCatalogCheckBox = new JBCheckBox("Allow downloading camel-catalog over the internet"); scanThirdPartyComponentsCatalogCheckBox = new JBCheckBox( "Scan classpath for third party Camel components using modern component packaging"); scanThirdPartyLegacyComponentsCatalogCheckBox = new JBCheckBox( "Scan classpath for third party Camel components using legacy component packaging"); camelIconInGutterCheckBox = new JBCheckBox("Show Camel icon in gutter"); camelIconsComboBox = new ComboBox<>(new String[] { "Camel Icon", "Camel Badge Icon", "Custom Icon" }); customIconButton = new TextFieldWithBrowseButton(); customIconButton.addBrowseFolderListener("Choose Custom Camel Icon", "The icon should be a 16x16 png file", null, FileChooserDescriptorFactory.createSingleFileDescriptor("png")); camelIconsComboBox.setRenderer(new CamelChosenIconCellRender(customIconButton)); camelIconsComboBox.addItemListener((l) -> { // only enable custom if selected in the drop down customIconButton.setEnabled("Custom Icon".equals(l.getItem())); }); // use mig layout which is like a spread-sheet with 2 columns, which we can span if we only have one element JPanel panel = new JPanel(new MigLayout("fillx,wrap 2", "[left]rel[grow,fill]")); panel.setOpaque(false); panel.add(realTimeEndpointValidationCatalogCheckBox, "span 2"); panel.add(realTimeSimpleValidationCatalogCheckBox, "span 2"); panel.add(highlightCustomOptionsCheckBox, "span 2"); panel.add(downloadCatalogCheckBox, "span 2"); panel.add(scanThirdPartyComponentsCatalogCheckBox, "span 2"); panel.add(scanThirdPartyLegacyComponentsCatalogCheckBox, "span 2"); panel.add(camelIconInGutterCheckBox, "span 2"); panel.add(new JLabel("Camel icon")); panel.add(camelIconsComboBox); panel.add(new JLabel("Custom icon file path")); panel.add(customIconButton); JPanel result = new JPanel(new BorderLayout()); result.add(panel, BorderLayout.NORTH); JPanel propertyTablePanel = new JPanel(new VerticalLayout(1)); propertyTablePanel.add(createPropertyIgnoreTable(), -1); propertyTablePanel.add(createExcludePropertyFilesTable(), -1); result.add(propertyTablePanel, -1); reset(); return result; }
From source file:org.apache.camel.idea.preference.editorsettings.CamelEditorSettingsPage.java
License:Apache License
@Nullable @Override//www . jav a 2s.c o m public JComponent createComponent() { downloadCatalogCheckBox = new JBCheckBox("Allow downloading camel-catalog over the internet"); scanThirdPartyComponentsCatalogCheckBox = new JBCheckBox( "Scan classpath for third party Camel components using modern component packaging"); scanThirdPartyLegacyComponentsCatalogCheckBox = new JBCheckBox( "Scan classpath for third party Camel components using legacy component packaging"); camelIconInGutterCheckBox = new JBCheckBox("Show Camel icon in gutter"); camelIconsComboBox = new ComboBox<>(new String[] { "Camel Icon", "Camel Animal Icon", "Camel Badge Icon" }); camelIconsComboBox.setRenderer(new CamelChosenIconCellRender()); // use mig layout which is like a spread-sheet with 2 columns, which we can span if we only have one element JPanel panel = new JPanel(new MigLayout("fillx,wrap 2", "[left]rel[grow,fill]")); panel.setOpaque(false); panel.add(downloadCatalogCheckBox, "span 2"); panel.add(scanThirdPartyComponentsCatalogCheckBox, "span 2"); panel.add(scanThirdPartyLegacyComponentsCatalogCheckBox, "span 2"); panel.add(camelIconInGutterCheckBox, "span 2"); panel.add(new JLabel("Camel icon")); panel.add(camelIconsComboBox); JPanel result = new JPanel(new BorderLayout()); result.add(panel, BorderLayout.NORTH); reset(); return result; }
From source file:org.codinjutsu.tools.jenkins.view.BuildParamDialog.java
License:Apache License
private JComboBox createComboBox(JobParameter jobParameter, String defaultValue) { ComboBox comboBox = new ComboBox(jobParameter.getValues().toArray()); if (StringUtils.isNotEmpty(defaultValue)) { comboBox.setSelectedItem(defaultValue); }/*from ww w . j a v a 2s . co m*/ return comboBox; }