private void buildForOne(JBPanel panel, final FilePath root) { final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 2; final JBLabel comp = new JBLabel("Please select remote URL:"); comp.setFont(comp.getFont().deriveFont(Font.BOLD)); panel.add(comp, c); final JBTextField value = new JBTextField(); value.setColumns(100); final String preset = myCheckoutURLs.get(root.getIOFile()); if (preset != null) { value.setText(preset); } myFields.put(root.getIOFile(), value); ++ c.gridy; panel.add(value, c); addWarning(panel, c); }
@Override public void apply() throws ConfigurationException { FossilConfiguration configuration = FossilConfiguration.getInstance(myProject); final Map<File, String> urls = new HashMap<File, String>(configuration.getRemoteUrls()); for (Map.Entry<File, JBTextField> entry : myFields.entrySet()) { final String text = entry.getValue().getText(); if (text.trim().equals(myCheckoutURLs.get(entry.getKey())) || text.trim().length() == 0) { // remove override from map urls.remove(entry.getKey()); } else { urls.put(entry.getKey(), text.trim()); } } configuration.setRemoteUrls(urls); }
@Override @NotNull protected JComponent createCenterPanel() { JPanel contentPanel = new JPanel(new GridBagLayout()); GridBag g = new GridBag() .setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP)) .setDefaultAnchor(GridBagConstraints.LINE_START) .setDefaultFill(GridBagConstraints.HORIZONTAL); JLabel icon = new JLabel(UIUtil.getQuestionIcon(), SwingConstants.LEFT); myBookmarkName = new JBTextField(13); JBLabel bookmarkLabel = new JBLabel("Bookmark name:"); bookmarkLabel.setLabelFor(myBookmarkName); myActiveCheckbox = new JBCheckBox("Inactive", false); contentPanel.add(icon, g.nextLine().next().coverColumn(3).pady(DEFAULT_HGAP)); contentPanel.add(bookmarkLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP))); contentPanel.add(myBookmarkName, g.next().coverLine().setDefaultWeightX(1)); contentPanel.add(myActiveCheckbox, g.nextLine().next().next().coverLine(2)); return contentPanel; }
/** * Factory method. It creates panel with dialog options. Options panel is located at the * center of the dialog's content pane. The implementation can return <code>null</code> * value. In this case there will be no options panel. * * @return center panel */ @Nullable @Override protected JComponent createCenterPanel() { final JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.setPreferredSize(new Dimension(600, 300)); previewDocument = EditorFactory.getInstance().createDocument(content); preview = Utils.createPreviewEditor(previewDocument, project, false); name = new JBTextField(IgnoreBundle.message("dialog.userTemplate.name.value")); JLabel nameLabel = new JLabel(IgnoreBundle.message("dialog.userTemplate.name")); nameLabel.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 10)); JPanel namePanel = new JPanel(new BorderLayout()); namePanel.add(nameLabel, BorderLayout.WEST); namePanel.add(name, BorderLayout.CENTER); JComponent previewComponent = preview.getComponent(); previewComponent.setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0)); centerPanel.add(namePanel, BorderLayout.NORTH); centerPanel.add(previewComponent, BorderLayout.CENTER); return centerPanel; }
protected void buildQueryToolBar() { toolBarPanel.setLayout(new BorderLayout()); filterField = new JBTextField("*"); filterField.setColumns(10); NonOpaquePanel westPanel = new NonOpaquePanel(); NonOpaquePanel filterPanel = new NonOpaquePanel(); filterPanel.add(new JLabel("Filter: "), BorderLayout.WEST); filterPanel.add(filterField, BorderLayout.CENTER); filterPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST); westPanel.add(filterPanel, BorderLayout.WEST); toolBarPanel.add(westPanel, BorderLayout.WEST); addCommonsActions(); }
private void createUIComponents() { xrayConfig = GlobalSettings.getInstance().getXrayConfig(); url = new JBTextField(); username = new JBTextField(); password = new JBPasswordField(); loadConfig(); }
public FixedComboBoxEditor() { if (SystemInfo.isMac && (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderIntelliJLaF())) { myField = new MacComboBoxTextField(); } else { myField = new JBTextField(); myField.setBorder(null); } }
public TextFieldWithBrowseButton(JTextField field, @Nullable ActionListener browseActionListener, @Nullable Disposable parent) { super(field, browseActionListener); if (!(field instanceof JBTextField)) { UIUtil.addUndoRedoActions(field); } installPathCompletion(FileChooserDescriptorFactory.createSingleLocalFileDescriptor(), parent); }
public StringsCellEditor() { myTextField = new JBTextField(); myTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { stopCellEditing(); e.consume(); } else { super.keyPressed(e); } } }); }
@Override public void fillUi(@NotNull PaintAwarePanel canvas, int indentLevel) { if (!dropOfflineModeBox) { myOfflineModeBox = new JBCheckBox(GradleBundle.message("gradle.settings.text.offline_work")); canvas.add(myOfflineModeBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel)); } addServiceDirectoryControl(canvas, indentLevel); if (!dropVmOptions) { myGradleVmOptionsLabel = new JBLabel(GradleBundle.message("gradle.settings.text.vm.options")); canvas.add(myGradleVmOptionsLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel)); myGradleVmOptionsField = new JBTextField(); canvas.add(myGradleVmOptionsField, ExternalSystemUiUtil.getFillLineConstraints(indentLevel)); } }
@Override @NotNull protected JComponent createCenterPanel() { JPanel contentPanel = new JPanel(new GridBagLayout()); GridBag g = new GridBag() .setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP)) .setDefaultAnchor(GridBagConstraints.LINE_START) .setDefaultFill(GridBagConstraints.HORIZONTAL); JLabel icon = new JLabel(UIUtil.getQuestionIcon(), SwingConstants.LEFT); myBookmarkName = new JBTextField(13); myBookmarkName.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent e) { validateFields(); } }); JBLabel bookmarkLabel = new JBLabel("Bookmark name:"); bookmarkLabel.setLabelFor(myBookmarkName); myActiveCheckbox = new JBCheckBox("Inactive", false); contentPanel.add(icon, g.nextLine().next().coverColumn(3).pady(DEFAULT_HGAP)); contentPanel.add(bookmarkLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP))); contentPanel.add(myBookmarkName, g.next().coverLine().setDefaultWeightX(1)); contentPanel.add(myActiveCheckbox, g.nextLine().next().next().coverLine(2)); return contentPanel; }
public NewRuleUI(int textFieldLength) { this.ruleNameField = new JBTextField(textFieldLength); Kind lastValue = Kind.fromString(PropertiesComponent.getInstance().getValue(LAST_SELECTED_KIND)); if (HANDLED_RULES.contains(lastValue)) { ruleComboBox.setSelectedItem(lastValue); } }
private void initializeToolWindow() { JBPanel mainPanel = new JBPanel(new BorderLayout()); JBPanel addressPanel = new JBPanel(new FlowLayout(FlowLayout.LEFT)); ActionToolbar rightToolbar = createToolbar(); JBLabel addressLabel = new JBLabel("Location: "); addressTextField = new JBTextField(25); addressPanel.add(addressLabel); addressPanel.add(addressTextField); mainPanel.add(addressPanel, BorderLayout.NORTH); requestTextField = new EditorTextField(); responseTextField = new EditorTextField(); requestTextField.setPlaceholder("Request"); responseTextField.setPlaceholder("Response"); JBSplitter splitter = new JBSplitter(false, 0.5f); splitter.setShowDividerControls(true); splitter.setFirstComponent(requestTextField); splitter.setSecondComponent(responseTextField); mainPanel.add(splitter, BorderLayout.CENTER); setContent(mainPanel); setToolbar(rightToolbar.getComponent()); }
public FossilUpdateConfigurable(final Project project, final Collection<FilePath> roots, Map<File, String> checkoutURLs, String warning) { myProject = project; myRoots = roots; myCheckoutURLs = checkoutURLs; myWarning = warning; myFields = new HashMap<File, JBTextField>(); }
private void buildForMultiple(JBPanel panel) { final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0); c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; final JBLabel comp = new JBLabel("Please select remote URLs for roots:"); comp.setFont(comp.getFont().deriveFont(Font.BOLD)); panel.add(comp, c); c.gridwidth = 1; for (FilePath root : myRoots) { c.weighty = 0; c.gridx = 0; ++ c.gridy; c.fill = GridBagConstraints.NONE; panel.add(new JBLabel(root.getName() + " (" + root.getParentPath() + ")"), c); ++ c.gridx; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1; final JBTextField field = new JBTextField(); panel.add(field, c); myFields.put(root.getIOFile(), field); final String preset = myCheckoutURLs.get(root.getIOFile()); if (preset != null) { field.setText(preset); } } addWarning(panel, c); }
@Override public void fillUi(@NotNull PaintAwarePanel canvas, int indentLevel) { myServiceDirectoryLabel = new JBLabel(GradleBundle.message("gradle.settings.text.service.dir.path")); preparePathControl(); canvas.add(myServiceDirectoryLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel)); canvas.add(myServiceDirectoryPathField, ExternalSystemUiUtil.getFillLineConstraints(indentLevel)); myGradleVmOptionsLabel = new JBLabel(GradleBundle.message("gradle.settings.text.vm.options")); canvas.add(myGradleVmOptionsLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel)); myGradleVmOptionsField = new JBTextField(); canvas.add(myGradleVmOptionsField, ExternalSystemUiUtil.getFillLineConstraints(indentLevel)); }
public TextAlignmentForm(ColumnAlignerModel lastSeparators) { resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textfields.removeAll(); JBTextField field = addTextField(null); field.grabFocus(); textfields.revalidate(); textfields.repaint(); } }); setData(lastSeparators); init(lastSeparators.getSeparators()); }
private List<String> getSeparators() { ArrayList<String> strings = new ArrayList<String>(textfields.getComponentCount()); Component[] components = textfields.getComponents(); for (Component component : components) { JBTextField field = (JBTextField) component; strings.add(field.getText()); } return strings; }
@Override protected JComponent createCenterPanel() { nameField = new JBTextField("newRule"); double h = nameField.getSize().getHeight(); nameField.setPreferredSize(new Dimension(250,(int)h)); setTitle("Name the extracted rule"); nameField.selectAll(); return nameField; }
public OptionsDialogWrapper(Project project, Generator generator) { super(project, false, IdeModalityType.IDE); myProject = project; myGenerator = generator; myOutputFolderChooser = new TextFieldWithBrowseButton(new JBTextField()); setTitle("Generator configuration"); getPeer().getWindow().setMinimumSize(new Dimension(400, 40)); setResizable(false); init(); }
public ServiceAuthDialog() { super(null); setTitle("Service Authorization"); myRoot = new JPanel(new VerticalFlowLayout(0, 0)); myServiceAuthConfiguration = ServiceAuthConfiguration.getInstance(); myAsAnonymousButton = new JBRadioButton("Logged as anonymous"); myLogAsButton = new JBRadioButton("Log as user"); JPanel loginPanel = new JPanel(new VerticalFlowLayout(0, 0)); myEmailField = new JBTextField(); loginPanel.add(LabeledComponent.left(myEmailField, "Email")); ButtonGroup group = new ButtonGroup(); group.add(myAsAnonymousButton); group.add(myLogAsButton); myLogAsButton.addItemListener(e -> UIUtil.setEnabled(loginPanel, e.getStateChange() == ItemEvent.SELECTED, true)); myRoot.add(myAsAnonymousButton); myRoot.add(myLogAsButton); myRoot.add(loginPanel); String email = myServiceAuthConfiguration.getEmail(); if (email == null) { myAsAnonymousButton.setSelected(true); } else { myLogAsButton.setSelected(true); myEmailField.setText(email); } pack(); init(); }
public StringWithNewLinesCellEditor() { super(new JBTextField() { @Override public void setDocument(Document doc) { super.setDocument(doc); doc.putProperty("filterNewlines", Boolean.FALSE); } }); }
private static DialogBuilder createDialog(@NotNull Project project, JBTextField contractText, JCheckBox pureCB) { JPanel panel = new JPanel(new BorderLayout()); panel.add(Messages.configureMessagePaneUi(new JTextPane(), ourPrompt), BorderLayout.NORTH); panel.add(contractText, BorderLayout.CENTER); panel.add(pureCB, BorderLayout.SOUTH); DialogBuilder builder = new DialogBuilder(project).setNorthPanel(panel).title("Edit Method Contract"); builder.setPreferredFocusComponent(contractText); return builder; }
private void createUIComponents() { interfaceName = new JBTextField(); factoryParams = new JBList<>(); }
private void buildProperties() { // Header JLabel jlName = new JLabel(Localizer.get("Name")); JLabel jlDescription = new JLabel(Localizer.get("Description")); jtfName = new JBTextField(packageTemplate.getName()); jtaDescription = new JTextArea(packageTemplate.getDescription()); panelProperties.add(jlName, new CC().wrap().spanX().pad(0, 0, 0, 8).gapY("0", "4pt")); panelProperties.add(jtfName, new CC().spanX().growX().pushX().wrap()); panelProperties.add(jlDescription, new CC().wrap().spanX().pad(0, 0, 0, 8).gapY("4pt", "4pt")); panelProperties.add(jtaDescription, new CC().spanX().growX().pushX().wrap().gapY("0", "4pt")); //FileTemplate Source ArrayList<FileTemplateSource> actionTypes = new ArrayList<>(); actionTypes.add(FileTemplateSource.DEFAULT_ONLY); actionTypes.add(FileTemplateSource.PROJECT_ONLY); actionTypes.add(FileTemplateSource.PROJECT_PRIORITY); actionTypes.add(FileTemplateSource.DEFAULT_PRIORITY); cboxFileTemplateSource = new ComboBox(actionTypes.toArray()); cboxFileTemplateSource.setRenderer(new FileTemplateSourceCellRenderer()); cboxFileTemplateSource.setSelectedItem(packageTemplate.getFileTemplateSource()); cboxFileTemplateSource.addActionListener (e -> { packageTemplate.setFileTemplateSource((FileTemplateSource) cboxFileTemplateSource.getSelectedItem()); }); if (mode == ViewMode.USAGE) { jtfName.setEditable(false); jtaDescription.setEditable(false); cboxFileTemplateSource.setEnabled(false); } else { // Properties cbShouldRegisterAction = new JBCheckBox(Localizer.get("property.ShouldRegisterAction"), packageTemplate.isShouldRegisterAction()); cbSkipDefiningNames = new JBCheckBox(Localizer.get("property.SkipPresettings"), packageTemplate.isSkipDefiningNames()); panelProperties.add(cbShouldRegisterAction, new CC().wrap().spanX()); panelProperties.add(cbSkipDefiningNames, new CC().wrap().spanX()); } // Properties cbSkipRootDirectory = new JBCheckBox(Localizer.get("property.SkipRootDirectory"), packageTemplate.isSkipRootDirectory()); cbSkipRootDirectory.addItemListener(e -> { collectDataFromFields(); reBuildElements(); }); cbShowReportDialog = new JBCheckBox(Localizer.get("property.ShowReportDialog"), packageTemplate.shouldShowReport()); panelProperties.add(cbSkipRootDirectory, new CC().spanX().wrap()); panelProperties.add(cbShowReportDialog, new CC().spanX().wrap()); panelProperties.add(new JLabel(Localizer.get("FileTemplateSource")), new CC().spanX().split(2)); panelProperties.add(cboxFileTemplateSource, new CC().pushX().growX().wrap()); }
@Override public void createToolWindowContent(Project project, ToolWindow toolWindow) { makeTable(); // System.out.println("createToolWindowContent()->"+toolWindow.getTitle()); totalSelectedTime = new JBLabel(); totalSelectedTime.setText("Not selected"); searchField = new JBTextField(); searchField.setToolTipText("Select column in combo box, input text, and press enter"); searchField.setColumns(50); buildFilterComboBox(); //build UI NonOpaquePanel totalPanel = new NonOpaquePanel(); totalPanel.add(Box.createHorizontalStrut(50), BorderLayout.WEST); totalPanel.add(totalSelectedTime, BorderLayout.CENTER); totalPanel.add(Box.createHorizontalStrut(50), BorderLayout.EAST); NonOpaquePanel rightPanel = new NonOpaquePanel(); rightPanel.add(comboBoxLabel, BorderLayout.WEST); rightPanel.add(Box.createHorizontalStrut(50), BorderLayout.CENTER); rightPanel.add(totalPanel, BorderLayout.EAST); NonOpaquePanel filterPanel = new NonOpaquePanel(); Icon refreshIcon = IconLoader.getIcon("/icons/refresh.png"); JButton btn = new JButton(refreshIcon); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { loadDataFromSource(table_model, null); table.updateUI(); } }); JPanel butonPanel = new JPanel(); butonPanel.setLayout(new FlowLayout()); butonPanel.add(btn) ; butonPanel.add(new JLabel("Filter: ")) ; filterPanel.add(butonPanel, BorderLayout.WEST); filterPanel.add(searchField, BorderLayout.CENTER); filterPanel.add(rightPanel, BorderLayout.EAST); filterPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); // final Component component = toolWindow.getComponent(); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(filterPanel, BorderLayout.NORTH); panel.add(sp, BorderLayout.CENTER); // component.getParent().add(filterPanel, BorderLayout.NORTH); // component.getParent().add(sp, BorderLayout.CENTER); searchField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { e.consume(); newFilter(searchField.getText(), comboBoxLabel.getSelectedIndex()); table.updateUI(); } else { super.keyPressed(e); } } }); ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); Content content = contentFactory.createContent(panel, "", false); toolWindow.getContentManager().addContent(content); }
@Nullable @Override protected JComponent createCenterPanel() { JPanel root = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 2.0; constraints.weighty = 0.0; constraints.gridwidth = GridBagConstraints.REMAINDER; GridBagConstraints labelConstraint = new GridBagConstraints(); labelConstraint.anchor = GridBagConstraints.EAST; labelConstraint.insets = JBUI.insets(5, 10); GridBagConstraints txtConstraint = new GridBagConstraints(); txtConstraint.weightx = 2.0; txtConstraint.fill = GridBagConstraints.HORIZONTAL; txtConstraint.gridwidth = GridBagConstraints.REMAINDER; txtFixed = new JBTextField(); txtFixed.setName("txtSummary"); txtFixed.setPreferredSize(new Dimension(150, 200)); cmbState = new ComboBox<>(); cmbState.setName("cmbState"); for(ObjectRef item : new MantisSoapAPI(ConnectionSettings.getInstance(project)).getEnum("view_states")) { cmbState.addItem(item.getName()); } java.awt.Label lblFixed = new java.awt.Label("Check In"); java.awt.Label lblState = new java.awt.Label("Status"); JPanel basicsPanel = new JPanel(new GridBagLayout()); basicsPanel.add(lblFixed, labelConstraint); basicsPanel.add(txtFixed, txtConstraint); basicsPanel.add(lblState, labelConstraint); basicsPanel.add(cmbState, txtConstraint); root.add(basicsPanel); return root; }
@Nullable @Override protected JComponent createCenterPanel() { JPanel root = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.weightx = 2.0; constraints.weighty = 0.0; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = GridBagConstraints.REMAINDER; GridBagConstraints labelConstraint = new GridBagConstraints(); labelConstraint.anchor = GridBagConstraints.EAST; labelConstraint.insets = JBUI.insets(5, 10); GridBagConstraints txtConstraint = new GridBagConstraints(); txtConstraint.weightx = 2.0; txtConstraint.fill = GridBagConstraints.HORIZONTAL; txtConstraint.gridwidth = GridBagConstraints.REMAINDER; txtName = new JBTextField(); txtName.setName("txtName"); txtName.setPreferredSize(new Dimension(150, 25)); txtDateOrder = new JBTextField(); txtDateOrder.setText(new SimpleDateFormat("dd-MM-yyyy hh:mm").format(new Date())); txtDateOrder.setName("txtDateOrder"); txtDateOrder.setPreferredSize(new Dimension(150, 25)); txtDescription = new JTextArea(); txtDescription.setName("txtDescription"); txtDescription.setPreferredSize(new Dimension(150, 100)); chkReleased = new JCheckBox("Released"); chkReleased.setName("chkReleased"); chkObsolete = new JCheckBox("Obsolete"); chkObsolete.setName("chkObsolete"); cmdDelete = new JButton("Delete"); cmdDelete.setName("cmdDelete"); cmdDelete.addActionListener(e -> { api.deleteVersion(version.getId()); if(this.getButton(this.getOKAction())!=null) this.getButton(this.getOKAction()).doClick(); }); java.awt.Label lblName = new java.awt.Label("Name"); java.awt.Label lblDateOrder = new java.awt.Label("Date"); java.awt.Label lblDescription = new java.awt.Label("Description"); JPanel basicsPanel = new JPanel(new GridBagLayout()); basicsPanel.add(lblName, labelConstraint); basicsPanel.add(txtName, txtConstraint); basicsPanel.add(lblDateOrder, labelConstraint); basicsPanel.add(txtDateOrder, txtConstraint); basicsPanel.add(lblDescription, labelConstraint); basicsPanel.add(txtDescription, txtConstraint); basicsPanel.add(chkReleased, labelConstraint); basicsPanel.add(chkObsolete, txtConstraint); basicsPanel.add(cmdDelete); root.add(basicsPanel); return root; }
@Nullable @Override protected JComponent createCenterPanel() { JPanel root = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 2.0; constraints.weighty = 0.0; constraints.gridwidth = GridBagConstraints.REMAINDER; GridBagConstraints labelConstraint = new GridBagConstraints(); labelConstraint.anchor = GridBagConstraints.EAST; labelConstraint.insets = JBUI.insets(5, 10); GridBagConstraints txtConstraint = new GridBagConstraints(); txtConstraint.weightx = 2.0; txtConstraint.fill = GridBagConstraints.HORIZONTAL; txtConstraint.gridwidth = GridBagConstraints.REMAINDER; txtPlatform = new JBTextField(); txtPlatform.setName("txtPlatform"); txtPlatform.setPreferredSize(new Dimension(200, 50)); txtOS = new JBTextField(); txtOS.setName("txtOS"); txtOS.setPreferredSize(new Dimension(200, 50)); txtBuild = new JBTextField(); txtBuild.setName("txtBuild"); txtBuild.setPreferredSize(new Dimension(200, 50)); java.awt.Label lblPlatform = new java.awt.Label("Platform"); java.awt.Label lblOS = new java.awt.Label("OS"); java.awt.Label lblBuild = new java.awt.Label("Build"); JPanel basicsPanel = new JPanel(new GridBagLayout()); basicsPanel.add(lblPlatform, labelConstraint); basicsPanel.add(txtPlatform, txtConstraint); basicsPanel.add(lblOS, labelConstraint); basicsPanel.add(txtOS, txtConstraint); basicsPanel.add(lblBuild, labelConstraint); basicsPanel.add(txtBuild, txtConstraint); root.add(basicsPanel); return root; }
@Override protected JTextField createEditorComponent() { JBTextField field = new JBTextField(); field.setBorder(null); return field; }
public JBTextField getEditorComponent() { return (JBTextField)super.getEditorComponent(); }
@NotNull public JBTextField getField() { return myField; }
public TextFieldWithBrowseButton(ActionListener browseActionListener, Disposable parent) { this(new JBTextField(10/* to prevent field to be infinitely resized in grid-box layouts */), browseActionListener, parent); }
public static JTextField createUndoableTextField() { return new JBTextField(); }
public FieldPanel() { this(new JBTextField(30)); }
public FieldPanel(String labelText, final String viewerDialogTitle, ActionListener browseButtonActionListener, final Runnable documentListener) { this(new JBTextField(30), labelText, viewerDialogTitle, browseButtonActionListener, documentListener); }
public FindPopupWithProgress(@NotNull final Project project, @NotNull Collection<String> variants, @NotNull Function<String, Future> function) { myFunction = function; myTextField = new TextFieldWithProgress(project, variants) { @Override public void onOk() { if (myFuture == null) { final Future future = myFunction.fun(getText().trim()); myFuture = future; showProgress(); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { try { future.get(); okPopup(); } catch (CancellationException ex) { cancelPopup(); } catch (InterruptedException ex) { cancelPopup(); } catch (ExecutionException ex) { LOG.error(ex); cancelPopup(); } } }); } } }; myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myTextField, myTextField.getPreferableFocusComponent()) .setCancelOnClickOutside(true).setCancelOnWindowDeactivation(true).setCancelKeyEnabled(true).setRequestFocus(true).createPopup(); myPopup.addListener(new JBPopupListener.Adapter() { @Override public void onClosed(LightweightWindowEvent event) { if (!event.isOk()) { if (myFuture != null) { myFuture.cancel(true); } } myFuture = null; myTextField.hideProgress(); } }); final JBTextField field = new JBTextField(20); final Dimension size = field.getPreferredSize(); final Insets insets = myTextField.getBorder().getBorderInsets(myTextField); size.height += 6 + insets.top + insets.bottom; size.width += 4 + insets.left + insets.right; myPopup.setSize(size); }
@Nullable private DependencyOnPlugin editPluginDependency(@NotNull JComponent parent, @NotNull final DependencyOnPlugin original) { List<String> pluginIds = new ArrayList<String>(getPluginNameByIdMap().keySet()); if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) { pluginIds.add(original.getPluginId()); } Collections.sort(pluginIds, new Comparator<String>() { @Override public int compare(String o1, String o2) { return getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2)); } }); final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250); pluginChooser.setRenderer(new ListCellRendererWrapper<String>() { @Override public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) { setText(getPluginNameById(value)); } }); new ComboboxSpeedSearch(pluginChooser) { @Override protected String getElementText(Object element) { return getPluginNameById((String)element); } }; pluginChooser.setSelectedItem(original.getPluginId()); final JBTextField minVersionField = new JBTextField(StringUtil.notNullize(original.getMinVersion())); final JBTextField maxVersionField = new JBTextField(StringUtil.notNullize(original.getMaxVersion())); minVersionField.getEmptyText().setText("<any>"); minVersionField.setColumns(10); maxVersionField.getEmptyText().setText("<any>"); maxVersionField.setColumns(10); JPanel panel = FormBuilder.createFormBuilder() .addLabeledComponent("Plugin:", pluginChooser) .addLabeledComponent("Minimum version:", minVersionField) .addLabeledComponent("Maximum version:", maxVersionField) .getPanel(); final DialogBuilder dialogBuilder = new DialogBuilder(parent).title("Required Plugin").centerPanel(panel); dialogBuilder.setPreferredFocusComponent(pluginChooser); pluginChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogBuilder.setOkActionEnabled(!StringUtil.isEmpty((String)pluginChooser.getSelectedItem())); } }); if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) { return new DependencyOnPlugin(((String)pluginChooser.getSelectedItem()), StringUtil.nullize(minVersionField.getText().trim()), StringUtil.nullize(maxVersionField.getText().trim())); } return null; }
@Override protected JComponent createNorthPanel() { myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap( UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JBTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField); } if (myShowDirectoryField) { myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)); } final JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(myOpenFilesInEditor, BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }