List of usage examples for com.intellij.openapi.ui ComponentWithBrowseButton ComponentWithBrowseButton
public ComponentWithBrowseButton(@NotNull Comp component, @Nullable ActionListener browseActionListener)
From source file:com.android.tools.idea.run.editor.DeepLinkConfigurable.java
License:Apache License
private void createUIComponents() { myDeepLinkField = new ComponentWithBrowseButton<JBTextField>(new JBTextField(), null); }
From source file:com.android.tools.idea.run.editor.SpecificActivityConfigurable.java
License:Apache License
private void createUIComponents() { final EditorTextField editorTextField = new LanguageTextField(PlainTextLanguage.INSTANCE, myProject, "") { @Override/*from ww w. j a v a 2 s. c om*/ protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); if (file != null) { DaemonCodeAnalyzer.getInstance(myProject).setHighlightingEnabled(file, false); } editor.putUserData(LaunchOptionConfigurableContext.KEY, myContext); return editor; } }; myActivityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null); }
From source file:com.google.idea.blaze.android.run.binary.BlazeAndroidBinaryRunConfigurationStateEditor.java
License:Open Source License
private void createUIComponents(Project project) { final EditorTextField editorTextField = new LanguageTextField(PlainTextLanguage.INSTANCE, project, "") { @Override// www . jav a2 s . c o m protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file != null) { DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, false); } editor.putUserData(ACTIVITY_CLASS_TEXT_FIELD_KEY, BlazeAndroidBinaryRunConfigurationStateEditor.this); return editor; } }; activityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null); }
From source file:com.intellij.android.designer.propertyTable.editors.ResourceEditor.java
License:Apache License
public ResourceEditor(ResourceType[] types, Set<AttributeFormat> formats, String[] values) { myTypes = types;// w w w . j a va 2 s. c o m myIsDimension = formats.contains(AttributeFormat.Dimension); if (formats.contains(AttributeFormat.Boolean)) { myCheckBox = new JCheckBox(); myEditor = new ComponentWithBrowseButton<JCheckBox>(myCheckBox, null) { @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (!myIgnoreCheckBoxValue) { myBooleanResourceValue = null; fireValueCommitted(true, true); } } }); } else if (formats.contains(AttributeFormat.Enum)) { ComboboxWithBrowseButton editor = new ComboboxWithBrowseButton( SystemInfo.isWindows ? new MyComboBox() : new JComboBox()) { @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; final JComboBox comboBox = editor.getComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(values); model.insertElementAt(StringsComboEditor.UNSET, 0); comboBox.setModel(model); comboBox.setEditable(true); ComboEditor.installListeners(comboBox, new ComboEditor.ComboEditorListener(this) { @Override protected void onValueChosen() { if (comboBox.getSelectedItem() == StringsComboEditor.UNSET) { comboBox.setSelectedItem(null); } super.onValueChosen(); } }); myEditor = editor; comboBox.setSelectedIndex(0); } else { myEditor = new TextFieldWithBrowseButton() { @Override protected void installPathCompletion(FileChooserDescriptor fileChooserDescriptor, @Nullable Disposable parent) { } @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myEditor.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); JTextField textField = getComboText(); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireValueCommitted(true, true); } }); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(final DocumentEvent e) { preferredSizeChanged(); } }); } if (myCheckBox == null) { myEditor.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } myEditor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showDialog(); } }); myEditor.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myEditor.getChildComponent().requestFocus(); } }); }
From source file:com.intellij.execution.ui.AlternativeJREPanel.java
License:Apache License
public AlternativeJREPanel() { myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); myFieldWithHistory = new TextFieldWithHistory(); final ArrayList<String> foundJDKs = new ArrayList<String>(); for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { foundJDKs.add(path);//from w w w . j a v a2 s.co m } } final Sdk[] allJDKs = SdkTable.getInstance().getAllSdks(); for (Sdk jdk : allJDKs) { foundJDKs.add(jdk.getHomePath()); } myFieldWithHistory.setHistory(foundJDKs); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"), ExecutionBundle.message("run.configuration.select.jre.dir.label"), null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); setLayout(new MigLayout("ins 0, gap 10, fill, flowx")); add(myCbEnabled, "shrinkx"); add(myPathField, "growx, pushx"); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); myCbEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enabledChanged(); } }); enabledChanged(); setAnchor(myCbEnabled); updateUI(); }
From source file:com.intellij.uiDesigner.palette.ComponentItemDialog.java
License:Apache License
/** * @param itemToBeEdited item to be edited. If user closes dialog by "OK" button then * @param oneOff/* w ww . jav a2s . com*/ */ public ComponentItemDialog(final Project project, final Component parent, @NotNull ComponentItem itemToBeEdited, final boolean oneOff) { super(parent, false); myProject = project; myItemToBeEdited = itemToBeEdited; myOneOff = oneOff; myEditorTextField = new EditorTextField("", project, JavaFileType.INSTANCE); myEditorTextField.setFontInheritedFromLAF(true); myTfClassName = new ComponentWithBrowseButton<EditorTextField>(myEditorTextField, new MyChooseClassActionListener(project)); PsiFile boundForm = itemToBeEdited.getBoundForm(); if (boundForm != null) { myNestedFormRadioButton.setSelected(true); myTfNestedForm.setText(FormEditingUtil.buildResourceName(boundForm)); } else { myClassRadioButton.setSelected(true); setEditorText(myItemToBeEdited.getClassName().replace('$', '.')); } updateEnabledTextField(); myTfClassName.getChildComponent() .addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() { public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) { updateOKAction(); } }); myTfClassName.getButton().setEnabled(!project.isDefault()); // chooser should not work in default project myClassNamePlaceholder.setLayout(new BorderLayout()); myClassNamePlaceholder.add(myTfClassName, BorderLayout.CENTER); myTfIconPath.setText(myItemToBeEdited.getIconPath()); myTfIconPath.addActionListener(new MyChooseFileActionListener(project, new ImageFileFilter(null), myTfIconPath, UIDesignerBundle.message("add.component.choose.icon"))); myTfNestedForm .addActionListener(new MyChooseFileActionListener(project, new TreeFileChooser.PsiFileFilter() { public boolean accept(PsiFile file) { return file.getFileType().equals(GuiFormFileType.INSTANCE); } }, myTfNestedForm, UIDesignerBundle.message("add.component.choose.form"))); myTfNestedForm.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(DocumentEvent e) { updateOKAction(); } }); final GridConstraints defaultConstraints = myItemToBeEdited.getDefaultConstraints(); // Horizontal size policy { final int hSizePolicy = defaultConstraints.getHSizePolicy(); myChkHorCanShrink.setSelected((hSizePolicy & GridConstraints.SIZEPOLICY_CAN_SHRINK) != 0); myChkHorCanGrow.setSelected((hSizePolicy & GridConstraints.SIZEPOLICY_CAN_GROW) != 0); myChkHorWantGrow.setSelected((hSizePolicy & GridConstraints.SIZEPOLICY_WANT_GROW) != 0); } // Vertical size policy { final int vSizePolicy = defaultConstraints.getVSizePolicy(); myChkVerCanShrink.setSelected((vSizePolicy & GridConstraints.SIZEPOLICY_CAN_SHRINK) != 0); myChkVerCanGrow.setSelected((vSizePolicy & GridConstraints.SIZEPOLICY_CAN_GROW) != 0); myChkVerWantGrow.setSelected((vSizePolicy & GridConstraints.SIZEPOLICY_WANT_GROW) != 0); } myIsContainerCheckBox.setSelected(itemToBeEdited.isContainer()); myAutoCreateBindingCheckbox.setSelected(itemToBeEdited.isAutoCreateBinding()); myCanAttachLabelCheckbox.setSelected(itemToBeEdited.isCanAttachLabel()); myLblIcon.setLabelFor(myTfIconPath); myClassRadioButton.addChangeListener(new MyRadioChangeListener()); myNestedFormRadioButton.addChangeListener(new MyRadioChangeListener()); if (oneOff) { myLblIcon.setVisible(false); myTfIconPath.setVisible(false); myCanAttachLabelCheckbox.setVisible(false); myHSizePolicyPanel.setVisible(false); myVSizePolicyPanel.setVisible(false); } updateOKAction(); init(); }
From source file:com.jetbrains.unchain.ui.UnchainPanel.java
License:Apache License
public UnchainPanel(final Project project, final PsiClass initialClass) { myProject = project;/*from w ww . j a v a 2s .co m*/ setLayout(new BorderLayout()); add(myMainPanel, BorderLayout.CENTER); myBadDepsList.getEmptyText().setText("Select class to analyze and press Analyze Dependencies"); createToolbar(); myClassNameField = new EditorTextField("", project, StdFileTypes.JAVA); final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject); PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage(""); final PsiCodeFragment fragment = factory.createReferenceCodeFragment("", defaultPackage, true, true); myClassNameField.setDocument(PsiDocumentManager.getInstance(myProject).getDocument(fragment)); if (initialClass != null) { myClassNameField.setText(initialClass.getQualifiedName()); } ComponentWithBrowseButton<EditorTextField> classNameWithBrowseButton = new ComponentWithBrowseButton<EditorTextField>( myClassNameField, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { PsiClass initialClass = getSelectedClass(); TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project) .createProjectScopeChooser("Choose Class to Move", initialClass); chooser.showDialog(); PsiClass selected = chooser.getSelected(); if (selected != null) { myClassNameField.setText(selected.getQualifiedName()); } } }); myClassNamePlaceholder.add(classNameWithBrowseButton, BorderLayout.CENTER); Module[] modules = ModuleManager.getInstance(project).getModules(); myTargetModuleComboBox.setModel(new CollectionComboBoxModel(Arrays.asList(modules))); myTargetModuleComboBox.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value != null) { append(((Module) value).getName()); } } }); new ComboboxSpeedSearch(myTargetModuleComboBox) { @Override protected String getElementText(Object element) { return element instanceof Module ? ((Module) element).getName() : ""; } }; myGoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { runUnchainer(); } }); setupBadDependenciesListeners(); setupCallChainListeners(); setupGoodDependenciesListeners(); myMoveClassesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { moveClasses(); } }); }
From source file:com.perl5.lang.perl.idea.run.PerlAlternativeSdkPanel.java
License:Apache License
public PerlAlternativeSdkPanel() { myCbEnabled = new JBCheckBox("Use alternative Perl"); myFieldWithHistory = new TextFieldWithHistory(); myFieldWithHistory.setHistorySize(-1); final ArrayList<String> foundSdks = new ArrayList<String>(); final List<Sdk> perlSdks = ProjectJdkTable.getInstance().getSdksOfType(PerlSdkType.getInstance()); for (Sdk sdk : perlSdks) { if (sdk.getSdkType() == PerlSdkType.getInstance()) { foundSdks.add(sdk.getName()); }/*w ww . j a va 2 s . c o m*/ } for (Sdk sdk : perlSdks) { String homePath = sdk.getHomePath(); if (!foundSdks.contains(homePath)) { foundSdks.add(homePath); } } myFieldWithHistory.setHistory(foundSdks); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener("Select Perl", "Select Perl SDK", null, new FileChooserDescriptor(false, true, false, false, false, false) { @Override public boolean isFileSelectable(VirtualFile file) { return super.isFileSelectable(file) && PerlSdkType.getInstance().isValidSdkHome(file.getPath()); } }, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); setLayout(new MigLayout("ins 0, gap 10, fill, flowx")); add(myCbEnabled, "shrinkx"); add(myPathField, "growx, pushx"); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); myCbEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enabledChanged(); } }); enabledChanged(); setAnchor(myCbEnabled); updateUI(); }
From source file:net.ishchenko.idea.nginx.configurator.ServerFieldsForm.java
License:Apache License
private void createUIComponents() { executableField = new ComponentWithBrowseButton<JTextField>(new JTextField(), null); configurationField = new ComponentWithBrowseButton<JTextField>(new JTextField(), null); pidField = new ComponentWithBrowseButton<JTextField>(new JTextField(), null); }
From source file:org.cordovastudio.editors.designer.propertyTable.editors.ResourceEditor.java
License:Apache License
public ResourceEditor(@Nullable ResourceType[] types, Set<AttributeFormat> formats, String propertyName) { myTypes = types;//w w w . j av a 2s . co m myIsDimension = formats.contains(AttributeFormat.Dimension); myPropertyName = propertyName; if (formats.contains(AttributeFormat.Boolean) || formats.contains(AttributeFormat.OnOff) || formats.contains(AttributeFormat.Empty)) { for (AttributeFormat format : formats) { if (formats.contains(AttributeFormat.Boolean) || formats.contains(AttributeFormat.OnOff) || formats.contains(AttributeFormat.Empty)) { myBooleanFormat = format; break; } } myCheckBox = new JCheckBox(); myEditor = new ComponentWithBrowseButton<JCheckBox>(myCheckBox, null) { @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (!myIgnoreCheckBoxValue) { myBooleanResourceValue = null; fireValueCommitted(true, true); } } }); } else { myEditor = new TextFieldWithBrowseButton() { @Override protected void installPathCompletion(FileChooserDescriptor fileChooserDescriptor, @Nullable Disposable parent) { } @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myEditor.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); JTextField textField = getComboText(); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireValueCommitted(true, true); } }); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(final DocumentEvent e) { preferredSizeChanged(); } }); } if (myCheckBox == null) { myEditor.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } myEditor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showDialog(); } }); myEditor.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myEditor.getChildComponent().requestFocus(); } }); }