List of usage examples for com.intellij.openapi.ui TextFieldWithBrowseButton TextFieldWithBrowseButton
public TextFieldWithBrowseButton(ActionListener browseActionListener)
From source file:com.android.tools.idea.editors.strings.StringResourceViewPanel.java
License:Apache License
private void createDefaultValueTextField() { myDefaultValueTextField = new TextFieldWithBrowseButton(new TranslationsEditorTextField()); myDefaultValueTextField.setButtonIcon(AllIcons.Actions.ShowViewer); myDefaultValueTextField.addActionListener(new ShowMultilineActionListener()); FocusListener listener = new SetTableValueAtFocusListener(StringResourceTableModel.DEFAULT_VALUE_COLUMN); myDefaultValueTextField.getTextField().addFocusListener(listener); }
From source file:com.android.tools.idea.editors.strings.StringResourceViewPanel.java
License:Apache License
private void createTranslationTextField() { myTranslationTextField = new TextFieldWithBrowseButton(new TranslationsEditorTextField()); myTranslationTextField.setButtonIcon(AllIcons.Actions.ShowViewer); myTranslationTextField.addActionListener(new ShowMultilineActionListener()); myTranslationTextField.getTextField() .addFocusListener(new SetTableValueAtFocusListener(myTable::getSelectedColumnModelIndex)); }
From source file:com.android.tools.idea.gradle.structure.editors.KeyValuePane.java
License:Apache License
public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) { GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2); setLayout(layout);/*from w w w .jav a 2 s . co m*/ GridConstraints constraints = new GridConstraints(); constraints.setAnchor(GridConstraints.ANCHOR_WEST); constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED); for (BuildFileKey property : properties) { constraints.setColumn(0); constraints.setFill(GridConstraints.FILL_NONE); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); JBLabel label = new JBLabel(property.getDisplayName()); add(label, constraints); constraints.setColumn(1); constraints.setFill(GridConstraints.FILL_HORIZONTAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW); JComponent component; switch (property.getType()) { case BOOLEAN: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = createComboBox(false); comboBox.addItem(""); comboBox.addItem("true"); comboBox.addItem("false"); comboBox.setPrototypeDisplayValue("(false) "); component = comboBox; break; } case FILE: case FILE_AS_STRING: { JBTextField textField = new JBTextField(); TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField); FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false); d.setShowFileSystemRoots(true); fileField.addBrowseFolderListener(new TextBrowseFolderListener(d)); fileField.getTextField().getDocument().addDocumentListener(this); component = fileField; break; } case REFERENCE: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = createComboBox(true); if (hasKnownValues(property)) { for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } } // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference // type wakes up and notifies us of its current values. component = comboBox; break; } case CLOSURE: case STRING: case INTEGER: default: { if (hasKnownValues(property)) { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = createComboBox(true); for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } component = comboBox; } else { JBTextField textField = new JBTextField(); textField.getDocument().addDocumentListener(this); component = textField; } break; } } add(component, constraints); label.setLabelFor(component); myProperties.put(property, component); constraints.setRow(constraints.getRow() + 1); } constraints.setColumn(0); constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); add(new JBLabel(""), constraints); updateUiFromCurrentObject(); }
From source file:com.android.tools.idea.structure.gradle.KeyValuePane.java
License:Apache License
public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) { GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2); setLayout(layout);// w ww. ja va2s . co m GridConstraints constraints = new GridConstraints(); constraints.setAnchor(GridConstraints.ANCHOR_WEST); constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED); for (BuildFileKey property : properties) { constraints.setColumn(0); constraints.setFill(GridConstraints.FILL_NONE); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); JBLabel label = new JBLabel(property.getDisplayName()); add(label, constraints); constraints.setColumn(1); constraints.setFill(GridConstraints.FILL_HORIZONTAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW); JComponent component; switch (property.getType()) { case BOOLEAN: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(false); comboBox.addItem(""); comboBox.addItem("true"); comboBox.addItem("false"); comboBox.setPrototypeDisplayValue("(false) "); component = comboBox; break; } case FILE: case FILE_AS_STRING: { JBTextField textField = new JBTextField(); TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField); FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false); d.setShowFileSystemRoots(true); fileField.addBrowseFolderListener(new TextBrowseFolderListener(d)); fileField.getTextField().getDocument().addDocumentListener(this); component = fileField; break; } case REFERENCE: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(true); if (hasKnownValues(property)) { for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } } // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference // type wakes up and notifies us of its current values. component = comboBox; break; } case CLOSURE: case STRING: case INTEGER: default: { if (hasKnownValues(property)) { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(true); for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } component = comboBox; } else { JBTextField textField = new JBTextField(); textField.getDocument().addDocumentListener(this); component = textField; } break; } } add(component, constraints); label.setLabelFor(component); myProperties.put(property, component); constraints.setRow(constraints.getRow() + 1); } constraints.setColumn(0); constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); add(new JBLabel(""), constraints); updateUiFromCurrentObject(); }
From source file:com.android.tools.idea.structure.KeyValuePane.java
License:Apache License
public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) { GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2); setLayout(layout);//from w ww .j ava 2 s .c om GridConstraints constraints = new GridConstraints(); constraints.setAnchor(GridConstraints.ANCHOR_WEST); constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED); for (BuildFileKey property : properties) { constraints.setColumn(0); constraints.setFill(GridConstraints.FILL_NONE); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); add(new JBLabel(property.getDisplayName()), constraints); constraints.setColumn(1); constraints.setFill(GridConstraints.FILL_HORIZONTAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW); JComponent component; switch (property.getType()) { case BOOLEAN: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(false); comboBox.addItem(""); comboBox.addItem("true"); comboBox.addItem("false"); comboBox.setPrototypeDisplayValue("(false) "); component = comboBox; break; } case FILE: case FILE_AS_STRING: { JBTextField textField = new JBTextField(); TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField); FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false); d.setShowFileSystemRoots(true); fileField.addBrowseFolderListener(new TextBrowseFolderListener(d)); fileField.getTextField().getDocument().addDocumentListener(this); component = fileField; break; } case REFERENCE: { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(true); if (hasKnownValues(property)) { for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } } // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference // type wakes up and notifies us of its current values. component = comboBox; break; } case CLOSURE: case STRING: case INTEGER: default: { if (hasKnownValues(property)) { constraints.setFill(GridConstraints.FILL_NONE); ComboBox comboBox = getComboBox(true); for (String s : myKeysWithKnownValues.get(property).values()) { comboBox.addItem(s); } component = comboBox; } else { JBTextField textField = new JBTextField(); textField.getDocument().addDocumentListener(this); component = textField; } break; } } add(component, constraints); myProperties.put(property, component); constraints.setRow(constraints.getRow() + 1); } constraints.setColumn(0); constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL); constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED); add(new JBLabel(""), constraints); updateUiFromCurrentObject(); }
From source file:com.hp.alm.ali.idea.genesis.GenesisDialog.java
License:Apache License
public GenesisDialog() { super("Provision Development Environment", JOptionPane.getRootFrame()); AliConfiguration conf = ApplicationManager.getApplication().getComponent(AliConfiguration.class); panel = new JPanel(); panel.setLayout(new BorderLayout(10, 10)); JPanel panel3 = new JPanel(); panel3.setLayout(new BorderLayout()); panel3.add(new JLabel(IconLoader.getIcon("/ali_icon_64x64.png")), BorderLayout.NORTH); panel.add(panel3, BorderLayout.WEST); context = new WizardContext(); context.panel = panel;//w w w . j av a 2 s. c om JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayout(0, 1)); context.locationLbl = new JLabel("HP ALM Location:"); panel2.add(context.locationLbl); context.location = new JTextField(conf.ALM_LOCATION); context.location.setPreferredSize(new Dimension(200, context.location.getPreferredSize().height)); context.location.getDocument().addDocumentListener(this); panel2.add(context.location); context.usernameLbl = new JLabel("Username:"); panel2.add(context.usernameLbl); context.username = new JTextField(conf.ALM_USERNAME); context.username.setPreferredSize(new Dimension(75, context.location.getPreferredSize().height)); context.username.getDocument().addDocumentListener(this); panel2.add(context.username); context.passwordLbl = new JLabel("Password:"); panel2.add(context.passwordLbl); context.password = new JPasswordField(conf.ALM_PASSWORD); panel2.add(context.password); context.domainLbl = new JLabel("Domain:"); context.domainLbl.setVisible(false); panel2.add(context.domainLbl); context.domain = new JComboBox(); context.domain.setVisible(false); context.domain.addItemListener(this); panel2.add(context.domain); context.projectLbl = new JLabel("Project:"); context.projectLbl.setVisible(false); panel2.add(context.projectLbl); context.project = new JComboBox(); context.project.setVisible(false); context.project.addItemListener(this); panel2.add(context.project); context.releaseLbl = new JLabel("Release:"); context.releaseLbl.setVisible(false); panel2.add(context.releaseLbl); context.release = new JComboBox(); context.release.setVisible(false); context.release.addItemListener(this); panel2.add(context.release); context.repositoryLbl = new JLabel("Repository:"); context.repositoryLbl.setVisible(false); panel2.add(context.repositoryLbl); context.repository = new JComboBox(); context.repository.setVisible(false); context.repository.addItemListener(this); panel2.add(context.repository); context.branchLbl = new JLabel("Branch:"); context.branchLbl.setVisible(false); panel2.add(context.branchLbl); context.branch = new JComboBox(); context.branch.setVisible(false); context.branch.addItemListener(this); panel2.add(context.branch); context.targetLbl = new JLabel("Target directory:"); context.targetLbl.setVisible(false); panel2.add(context.targetLbl); context.targetBtn = new TextFieldWithBrowseButton(new TextFieldWithBrowseButtonActionListener(context)); context.targetBtn.setVisible(false); panel2.add(context.targetBtn); context.targetFullLbl = new JLabel("Checkout as:"); context.targetFullLbl.setVisible(false); panel2.add(context.targetFullLbl); context.targetFull = new JComboBox(); context.targetFull.setVisible(false); context.targetFull.addItemListener(this); context.targetFull.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { enableDisableNext(); } }); panel2.add(context.targetFull); panel.add(panel2, BorderLayout.CENTER); ALMStep qcStep = new ALMStep(context); addStep(qcStep); DomainStep domainStep = new DomainStep(qcStep, context, conf.ALM_DOMAIN); addStep(domainStep); ProjectStep projectStep = new ProjectStep(domainStep, context, conf.ALM_PROJECT); addStep(projectStep); ReleaseStep releaseStep = new ReleaseStep(projectStep, context); addStep(releaseStep); RepositoryStep repoStep = new RepositoryStep(releaseStep, context); addStep(repoStep); BranchStep branchStep = new BranchStep(repoStep, context); addStep(branchStep); TargetStep targetStep = new TargetStep(branchStep, context); addStep(targetStep); context.targetBtn.getTextField().getDocument().addDocumentListener(targetStep); init(); enableDisableNext(); }
From source file:com.intellij.codeEditor.printing.ExportToHTMLDialog.java
License:Apache License
@Override protected JComponent createNorthPanel() { OptionGroup optionGroup = new OptionGroup(); myRbCurrentFile = new JRadioButton( CodeEditorBundle.message("export.to.html.file.name.radio", (myFileName != null ? myFileName : ""))); optionGroup.add(myRbCurrentFile);// www . ja va2 s . c o m myRbSelectedText = new JRadioButton(CodeEditorBundle.message("export.to.html.selected.text.radio")); optionGroup.add(myRbSelectedText); myRbCurrentPackage = new JRadioButton(CodeEditorBundle.message( "export.to.html.all.files.in.directory.radio", (myDirectoryName != null ? myDirectoryName : ""))); optionGroup.add(myRbCurrentPackage); myCbIncludeSubpackages = new JCheckBox( CodeEditorBundle.message("export.to.html.include.subdirectories.checkbox")); optionGroup.add(myCbIncludeSubpackages, true); FileTextField field = FileChooserFactory.getInstance() .createFileTextField(FileChooserDescriptorFactory.createSingleFolderDescriptor(), myDisposable); myTargetDirectoryField = new TextFieldWithBrowseButton(field.getField()); LabeledComponent<TextFieldWithBrowseButton> labeledComponent = assignLabel(myTargetDirectoryField, myProject); optionGroup.add(labeledComponent); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(myRbCurrentFile); buttonGroup.add(myRbSelectedText); buttonGroup.add(myRbCurrentPackage); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myCbIncludeSubpackages.setEnabled(myRbCurrentPackage.isSelected()); } }; myRbCurrentFile.addActionListener(actionListener); myRbSelectedText.addActionListener(actionListener); myRbCurrentPackage.addActionListener(actionListener); return optionGroup.createPanel(); }
From source file:com.intellij.compiler.options.ProcessorProfilePanel.java
License:Apache License
public ProcessorProfilePanel(Project project) { super(new GridBagLayout()); myProject = project;//from w w w. j a v a2 s . c o m myCbEnableProcessing = new JCheckBox("Enable annotation processing"); { myRbClasspath = new JRadioButton("Obtain processors from project classpath"); myRbProcessorsPath = new JRadioButton("Processor path:"); ButtonGroup group = new ButtonGroup(); group.add(myRbClasspath); group.add(myRbProcessorsPath); } { myRbRelativeToContentRoot = new JRadioButton("Module content root"); myRbRelativeToOutputRoot = new JRadioButton("Module output directory"); final ButtonGroup group = new ButtonGroup(); group.add(myRbRelativeToContentRoot); group.add(myRbRelativeToOutputRoot); } myProcessorPathField = new TextFieldWithBrowseButton(new ActionListener() { public void actionPerformed(ActionEvent e) { final FileChooserDescriptor descriptor = FileChooserDescriptorFactory .createAllButJarContentsDescriptor(); final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProcessorPathField, myProject, null); if (files.length > 0) { final StringBuilder builder = new StringBuilder(); for (VirtualFile file : files) { if (builder.length() > 0) { builder.append(File.pathSeparator); } builder.append(FileUtil.toSystemDependentName(file.getPath())); } myProcessorPathField.setText(builder.toString()); } } }); myProcessorTablePanel = new JPanel(new BorderLayout()); myProcessorsModel = new ProcessorTableModel(); myProcessorTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processors", false)); myProcessorTable = new JBTable(myProcessorsModel); myProcessorTable.getEmptyText().setText("Compiler will run all automatically discovered processors"); myProcessorPanel = createTablePanel(myProcessorTable); myProcessorTablePanel.add(myProcessorPanel, BorderLayout.CENTER); myOptionsTablePanel = new JPanel(new BorderLayout()); myOptionsModel = new OptionsTableModel(); myOptionsTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processor options", false)); myOptionsTable = new JBTable(myOptionsModel); myOptionsTable.getEmptyText().setText("No processor-specific options configured"); myOptionsPanel = createTablePanel(myOptionsTable); myOptionsTablePanel.add(myOptionsPanel, BorderLayout.CENTER); myGeneratedProductionDirField = new JTextField(); myGeneratedTestsDirField = new JTextField(); myWarninglabel = new JLabel("<html>WARNING!<br>" + /*"All source files located in the generated sources output directory WILL BE EXCLUDED from annotation processing. " +*/ "If option 'Clear output directory on rebuild' is enabled, " + "the entire contents of directories where generated sources are stored WILL BE CLEARED on rebuild.</html>"); myWarninglabel.setFont(myWarninglabel.getFont().deriveFont(Font.BOLD)); add(myCbEnableProcessing, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); add(myRbClasspath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); add(myRbProcessorsPath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); add(myProcessorPathField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0)); myStoreGenSourcesLabel = new JLabel("Store generated sources relative to: "); add(myStoreGenSourcesLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0)); add(myRbRelativeToOutputRoot, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0)); add(myRbRelativeToContentRoot, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0)); myProductionLabel = new JLabel("Production sources directory:"); add(myProductionLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0)); add(myGeneratedProductionDirField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0)); myTestLabel = new JLabel("Test sources directory:"); add(myTestLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0)); add(myGeneratedTestsDirField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0)); add(myProcessorTablePanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0)); add(myOptionsTablePanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0)); add(myWarninglabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0)); myRbClasspath.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEnabledState(); } }); myProcessorTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateEnabledState(); } } }); myCbEnableProcessing.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEnabledState(); } }); updateEnabledState(); }
From source file:com.intellij.execution.ui.CommonProgramParametersPanel.java
License:Apache License
protected void initComponents() { myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.program.parameters")); final JPanel panel = new JPanel(new BorderLayout()); myWorkingDirectoryField = new TextFieldWithBrowseButton(new ActionListener() { @Override/*from w w w . j a va 2 s . c o m*/ public void actionPerformed(ActionEvent e) { FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory .createSingleFolderDescriptor(); fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message")); fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext); Project project = myModuleContext != null ? myModuleContext.getProject() : null; VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, myWorkingDirectoryComponent, project, null); if (file != null) { setWorkingDirectory(file.getPresentableUrl()); } } }) { @Override protected void installPathCompletion(FileChooserDescriptor fileChooserDescriptor) { super.installPathCompletion(FileChooserDescriptorFactory.createSingleFolderDescriptor()); } }; panel.add(myWorkingDirectoryField, BorderLayout.CENTER); final FixedSizeButton button = new FixedSizeButton(myWorkingDirectoryField); button.setIcon(AllIcons.RunConfigurations.Variables); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final List<String> macros = new ArrayList<String>(PathMacros.getInstance().getUserMacroNames()); if (myHaveModuleContext) macros.add("MODULE_DIR"); final JList list = new JBList(ArrayUtil.toStringArray(macros)); final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setItemChoosenCallback(new Runnable() { @Override public void run() { final Object value = list.getSelectedValue(); if (value instanceof String) { setWorkingDirectory("$" + value + "$"); } } }).setMovable(false).setResizable(false).createPopup(); popup.showUnderneathOf(button); } }); panel.add(button, BorderLayout.EAST); myWorkingDirectoryComponent = LabeledComponent.create(panel, ExecutionBundle.message("run.configuration.working.directory.label")); myEnvVariablesComponent = new EnvironmentVariablesComponent(); myEnvVariablesComponent.setLabelLocation(BorderLayout.WEST); myProgramParametersComponent.setLabelLocation(BorderLayout.WEST); myWorkingDirectoryComponent.setLabelLocation(BorderLayout.WEST); addComponents(); setPreferredSize(new Dimension(10, 10)); setAnchor(myEnvVariablesComponent.getLabel()); }
From source file:com.intellij.ui.classFilter.ClassFilterEditorAddDialog.java
License:Apache License
protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new GridBagLayout()); final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern")); myClassName = new TextFieldWithBrowseButton(new JTextField(35)); final JLabel iconLabel = new JLabel(Messages.getQuestionIcon()); panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0)); panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0)); panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0)); myClassName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PsiClass currentClass = getSelectedClass(); TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject) .createNoInnerClassesScopeChooser( UIBundle.message("class.filter.editor.choose.class.title"), GlobalSearchScope.allScope(myProject), null, null); if (currentClass != null) { PsiFile containingFile = currentClass.getContainingFile(); if (containingFile != null) { PsiDirectory containingDirectory = containingFile.getContainingDirectory(); if (containingDirectory != null) { chooser.selectDirectory(containingDirectory); }//from w ww .j a va2s . com } } chooser.showDialog(); PsiClass selectedClass = chooser.getSelected(); if (selectedClass != null) { myClassName.setText(selectedClass.getQualifiedName()); } } }); myClassName.setEnabled(myProject != null); return panel; }