List of usage examples for com.intellij.openapi.ui FixedSizeButton FixedSizeButton
public FixedSizeButton(@NotNull JComponent component)
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// w w w.ja va 2 s. c om 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.execution.ui.ConfigurationArgumentsHelpArea.java
License:Apache License
public ConfigurationArgumentsHelpArea() { super(new BorderLayout()); add(myPanel);/*w w w .j a v a 2s . c o m*/ setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0)); final DefaultActionGroup group = new DefaultActionGroup(); group.add(new MyCopyAction()); myHelpArea.addMouseListener(new PopupHandler() { public void invokePopup(final Component comp, final int x, final int y) { createPopupMenu(group).getComponent().show(comp, x, y); } }); FixedSizeButton copyButton = new FixedSizeButton(22); copyButton.setIcon(PlatformIcons.COPY_ICON); copyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final StringSelection contents = new StringSelection(myHelpArea.getText().trim()); CopyPasteManager.getInstance().setContents(contents); } }); myToolbarPanel.add(copyButton, BorderLayout.NORTH); myToolbarPanel.setVisible(false); }
From source file:com.intellij.find.impl.FindDialog.java
License:Apache License
@NotNull private JComponent createGlobalScopePanel() { JPanel scopePanel = new JPanel(); scopePanel.setLayout(new GridBagLayout()); scopePanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.scope.group"), true)); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.fill = GridBagConstraints.HORIZONTAL; gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.gridx = 0;//from w ww . j a va 2 s. c om gbConstraints.gridy = 0; gbConstraints.gridwidth = 3; gbConstraints.weightx = 1; myRbProject = new JRadioButton(FindBundle.message("find.scope.whole.project.radio"), true); scopePanel.add(myRbProject, gbConstraints); ChangeListener l = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { findSettingsChanged(); } }; myRbProject.addChangeListener(l); gbConstraints.gridx = 0; gbConstraints.gridy++; gbConstraints.weightx = 0; gbConstraints.gridwidth = 1; myRbModule = new JRadioButton(FindBundle.message("find.scope.module.radio"), false); scopePanel.add(myRbModule, gbConstraints); myRbModule.addChangeListener(l); gbConstraints.gridx = 1; gbConstraints.gridwidth = 2; gbConstraints.weightx = 1; Module[] modules = ModuleManager.getInstance(myProject).getModules(); String[] names = new String[modules.length]; for (int i = 0; i < modules.length; i++) { names[i] = modules[i].getName(); } Arrays.sort(names, String.CASE_INSENSITIVE_ORDER); myModuleComboBox = new ComboBox(names); myModuleComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findSettingsChanged(); } }); scopePanel.add(myModuleComboBox, gbConstraints); if (modules.length == 1) { myModuleComboBox.setVisible(false); myRbModule.setVisible(false); } gbConstraints.gridx = 0; gbConstraints.gridy++; gbConstraints.weightx = 0; gbConstraints.gridwidth = 1; myRbDirectory = new JRadioButton(FindBundle.message("find.scope.directory.radio"), false); scopePanel.add(myRbDirectory, gbConstraints); myRbDirectory.addChangeListener(l); gbConstraints.gridx = 1; gbConstraints.weightx = 1; myDirectoryComboBox = new ComboBox(200); Component editorComponent = myDirectoryComboBox.getEditor().getEditorComponent(); if (editorComponent instanceof JTextField) { JTextField field = (JTextField) editorComponent; field.setColumns(40); } initCombobox(myDirectoryComboBox); myDirectoryComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findSettingsChanged(); } }); scopePanel.add(myDirectoryComboBox, gbConstraints); gbConstraints.weightx = 0; gbConstraints.gridx = 2; mySelectDirectoryButton = new FixedSizeButton(myDirectoryComboBox); TextFieldWithBrowseButton.MyDoClickAction.addTo(mySelectDirectoryButton, myDirectoryComboBox); mySelectDirectoryButton.setMargin(new Insets(0, 0, 0, 0)); scopePanel.add(mySelectDirectoryButton, gbConstraints); gbConstraints.gridx = 0; gbConstraints.gridy++; gbConstraints.weightx = 1; gbConstraints.gridwidth = 3; gbConstraints.insets = new Insets(0, 16, 0, 0); myCbWithSubdirectories = createCheckbox(true, FindBundle.message("find.scope.directory.recursive.checkbox")); myCbWithSubdirectories.setSelected(true); scopePanel.add(myCbWithSubdirectories, gbConstraints); gbConstraints.gridx = 0; gbConstraints.gridy++; gbConstraints.weightx = 0; gbConstraints.gridwidth = 1; gbConstraints.insets = new Insets(0, 0, 0, 0); myRbCustomScope = new JRadioButton(FindBundle.message("find.scope.custom.radio"), false); scopePanel.add(myRbCustomScope, gbConstraints); gbConstraints.gridx++; gbConstraints.weightx = 1; gbConstraints.gridwidth = 2; myScopeCombo = new ScopeChooserCombo(myProject, true, true, FindSettings.getInstance().getDefaultScopeName()); myRbCustomScope.addChangeListener(l); Disposer.register(myDisposable, myScopeCombo); scopePanel.add(myScopeCombo, gbConstraints); ButtonGroup bgScope = new ButtonGroup(); bgScope.add(myRbDirectory); bgScope.add(myRbProject); bgScope.add(myRbModule); bgScope.add(myRbCustomScope); ActionListener validateAll = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validateScopeControls(); validateFindButton(); } }; myRbProject.addActionListener(validateAll); myRbCustomScope.addActionListener(validateAll); myRbDirectory.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validateScopeControls(); validateFindButton(); myDirectoryComboBox.getEditor().getEditorComponent().requestFocusInWindow(); } }); myRbModule.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validateScopeControls(); validateFindButton(); myModuleComboBox.requestFocusInWindow(); } }); mySelectDirectoryButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() { @Override public void consume(final List<VirtualFile> files) { myDirectoryComboBox.setSelectedItem(files.get(0).getPresentableUrl()); } }); } }); return scopePanel; }
From source file:com.intellij.ide.fileTemplates.ui.SelectTemplateDialog.java
License:Apache License
@Override protected JComponent createCenterPanel() { loadCombo();// w w w .j a va 2s . c om JButton editTemplatesButton = new FixedSizeButton(myCbxTemplates); JPanel centerPanel = new JPanel(new GridBagLayout()); JLabel selectTemplateLabel = new JLabel(IdeBundle.message("label.name")); centerPanel.add(selectTemplateLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); centerPanel.add(myCbxTemplates, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 50, 0)); centerPanel.add(editTemplatesButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); editTemplatesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onEditTemplates(); } }); return centerPanel; }
From source file:com.intellij.javaee.EditLocationDialog.java
License:Apache License
protected void init() { setTitle(myTitle);//from www . j av a2 s. c om myTfUrl = new JTextField(); myTfPath = new JTextField(); myBtnBrowseLocalPath = new FixedSizeButton(myTfPath); super.init(); }
From source file:com.intellij.tools.ToolEditorDialog.java
License:Apache License
private JPanel createCommandPane() { final JPanel pane = new JPanel(new GridBagLayout()); pane.setBorder(IdeBorderFactory.createTitledBorder(ToolsBundle.message("tools.tool.group"), true)); GridBagConstraints constr;//from w w w .j a v a2 s. c om // program constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 0; constr.insets = new Insets(0, 0, 0, 10); constr.anchor = GridBagConstraints.BASELINE_LEADING; pane.add(new JLabel(ToolsBundle.message("tools.program.label")), constr); FixedSizeButton browseCommandButton = new FixedSizeButton(myTfCommand); addCommandBrowseAction(pane, browseCommandButton, myTfCommand); JPanel _pane0 = new JPanel(new BorderLayout()); _pane0.add(myTfCommand, BorderLayout.CENTER); _pane0.add(browseCommandButton, BorderLayout.EAST); TextFieldWithBrowseButton.MyDoClickAction.addTo(browseCommandButton, myTfCommand); constr = new GridBagConstraints(); constr.gridx = 1; constr.gridy = 0; constr.insets = new Insets(0, 0, 0, 10); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.BASELINE_LEADING; constr.weightx = 1.0; pane.add(_pane0, constr); constr = new GridBagConstraints(); constr.gridx = 2; constr.gridy = 0; constr.insets = new Insets(0, 0, 0, 0); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.BASELINE_LEADING; myInsertCommandMacroButton = new JButton(ToolsBundle.message("tools.insert.macro.button")); pane.add(myInsertCommandMacroButton, constr); // parameters constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 1; constr.insets = new Insets(5, 0, 0, 10); constr.anchor = GridBagConstraints.BASELINE_LEADING; pane.add(new JLabel(ToolsBundle.message("tools.parameters.label")), constr); constr = new GridBagConstraints(); constr.gridx = 1; constr.gridy = 1; constr.insets = new Insets(5, 0, 0, 10); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.BASELINE_LEADING; constr.weightx = 1.0; pane.add(myParametersField, constr); constr = new GridBagConstraints(); constr.gridx = 2; constr.gridy = 1; constr.insets = new Insets(5, 0, 0, 0); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.BASELINE_LEADING; myInsertParametersMacroButton = new JButton(ToolsBundle.message("tools.insert.macro.button.a")); pane.add(myInsertParametersMacroButton, constr); // working directory constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 2; constr.insets = new Insets(5, 0, 0, 10); constr.anchor = GridBagConstraints.BASELINE_LEADING; pane.add(new JLabel(ToolsBundle.message("tools.working.directory.label")), constr); FixedSizeButton browseDirectoryButton = new FixedSizeButton(myTfCommandWorkingDirectory); TextFieldWithBrowseButton.MyDoClickAction.addTo(browseDirectoryButton, myTfCommandWorkingDirectory); addWorkingDirectoryBrowseAction(pane, browseDirectoryButton, myTfCommandWorkingDirectory); JPanel _pane1 = new JPanel(new BorderLayout()); _pane1.add(myTfCommandWorkingDirectory, BorderLayout.CENTER); _pane1.add(browseDirectoryButton, BorderLayout.EAST); constr = new GridBagConstraints(); constr.gridx = 1; constr.gridy = 2; constr.gridwidth = 1; constr.insets = new Insets(5, 0, 0, 10); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.WEST; constr.weightx = 1.0; pane.add(_pane1, constr); constr = new GridBagConstraints(); constr.gridx = 2; constr.gridy = 2; constr.insets = new Insets(5, 0, 0, 0); constr.fill = GridBagConstraints.HORIZONTAL; constr.anchor = GridBagConstraints.BASELINE_LEADING; myInsertWorkingDirectoryMacroButton = new JButton(ToolsBundle.message("tools.insert.macro.button.c")); pane.add(myInsertWorkingDirectoryMacroButton, constr); // for normal resizing constr = new GridBagConstraints(); constr.gridy = 3; constr.fill = GridBagConstraints.BASELINE_LEADING; constr.weighty = 1.0; pane.add(new JLabel(), constr); return pane; }
From source file:com.intellij.ui.AbstractFieldPanel.java
License:Apache License
public void createComponent() { removeAll();//w w w .j av a 2 s . c o m setLayout(new GridBagLayout()); if (myLabelText != null) { myLabel = new JLabel(myLabelText); this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0)); myLabel.setLabelFor(myComponent); } this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); if (myBrowseButtonActionListener != null) { FixedSizeButton browseButton = new FixedSizeButton(getComponent()); myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton); browseButton.setFocusable(false); browseButton.addActionListener(myBrowseButtonActionListener); myButtons.add(browseButton); this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); } if (myViewerDialogTitle != null) { final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent()); if (myBrowseButtonActionListener == null) { LOG.assertTrue(myDoClickAction == null); myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton); } showViewerButton.setFocusable(false); showViewerButton.setIcon(AllIcons.Actions.ShowViewer); showViewerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Viewer viewer = new Viewer(); viewer.setTitle(myViewerDialogTitle); viewer.show(); } }); myButtons.add(showViewerButton); this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } }
From source file:com.intellij.ui.GuiUtils.java
License:Apache License
private static JPanel constructFieldWithBrowseButton(final JComponent aComponent, final ActionListener aActionListener, int delta) { JPanel result = new JPanel(new GridBagLayout()); result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent); result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); browseButton.addActionListener(aActionListener); return result; }
From source file:com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialogBase.java
License:Apache License
private void createUIComponents() { myColorSample = new SimpleColoredComponent(); mySamplePanel = new JPanel(new BorderLayout()); mySamplePanel.setBorder(BorderFactory.createEtchedBorder()); mySamplePanel.add(BorderLayout.CENTER, myColorSample); myChooseColorButton = new FixedSizeButton(mySamplePanel); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
License:Open Source License
private void addConfigurationLineItem() { JLabel jobConfigurationLabel = new JLabel("Job configurations"); add(jobConfigurationLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0)); String[] columns = { "Key", "Value", "" }; jobConfigurationTable = new JBTable(); Dimension jobConfigurationTableSize = new Dimension(320, 100); jobConfigurationTable.setPreferredScrollableViewportSize(jobConfigurationTableSize); jobConfigurationTable.setSurrendersFocusOnKeystroke(true); jobConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jobConfigurationTable.setColumnSelectionAllowed(true); JBScrollPane scrollPane = new JBScrollPane(jobConfigurationTable); jobConfigurationTable.setFillsViewportHeight(true); scrollPane.setMinimumSize(jobConfigurationTableSize); jobConfigurationTable.addPropertyChangeListener((evt) -> { if ((evt.getPropertyName().equals("tableCellEditor") || evt.getPropertyName().equals("model")) && jobConfigurationTable.getModel() instanceof SubmissionTableModel) { SubmissionTableModel model = (SubmissionTableModel) jobConfigurationTable.getModel(); setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), false); SparkSubmissionJobConfigCheckResult result = model.getFirstCheckResults(); if (result != null) { setStatusForMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), true, result.getMessaqge(), result.getStatus() == SparkSubmissionJobConfigCheckStatus.Warning); }//from w ww. j av a 2 s.c o m } }); add(scrollPane, new GridBagConstraints(1, displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, 0), 0, 0)); JButton loadJobConfigurationButton = new JButton("..."); loadJobConfigurationButton.setPreferredSize(selectedArtifactTextField.getButton().getPreferredSize()); FixedSizeButton loadJobConfigurationFixedSizeButton = new FixedSizeButton(loadJobConfigurationButton); add(loadJobConfigurationFixedSizeButton, new GridBagConstraints(2, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(margin, margin / 2, 0, margin), 0, 0)); loadJobConfigurationFixedSizeButton.setToolTipText("Load Spark config from property file"); loadJobConfigurationFixedSizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); fileChooserDescriptor.setTitle("Select Spark property file"); VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null); if (chooseFile != null) { submitModel.loadJobConfigMapFromPropertyFile(chooseFile.getCanonicalPath()); } } }); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] = new JLabel(); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] .setForeground(DarkThemeManager.getInstance().getErrorMessageColor()); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setVisible(false); add(errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0)); }