List of usage examples for com.intellij.openapi.ui TextFieldWithBrowseButton TextFieldWithBrowseButton
public TextFieldWithBrowseButton(ActionListener browseActionListener)
From source file:com.intellij.ui.RawCommandLineEditor.java
License:Apache License
public RawCommandLineEditor(final Function<String, List<String>> lineParser, final Function<List<String>, String> lineJoiner) { super(new BorderLayout()); myTextField = new TextFieldWithBrowseButton(new ActionListener() { @Override//from ww w . jav a 2 s .c om public void actionPerformed(ActionEvent e) { if (StringUtil.isEmpty(myDialogCaption)) { Container parent = getParent(); if (parent instanceof LabeledComponent) { parent = parent.getParent(); } LOG.error("Did not call RawCommandLineEditor.setDialogCaption() in " + parent); myDialogCaption = "Parameters"; } Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow", lineParser, lineJoiner); } }); myTextField.setButtonIcon(AllIcons.Actions.ShowViewer); add(myTextField, BorderLayout.CENTER); setDescriptor(null); }
From source file:com.intellij.uiDesigner.propertyInspector.editors.string.StringEditor.java
License:Apache License
public StringEditor(Project project, final IntroStringProperty property) { myProject = project;/* w ww. java 2s .c o m*/ myProperty = property; myTfWithButton = new TextFieldWithBrowseButton(new MyActionListener()); myTfWithButton.getTextField().setBorder(null); final JTextField textField = myTfWithButton.getTextField(); textField.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { fireValueCommitted(false, false); } }); textField.getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(final DocumentEvent e) { preferredSizeChanged(); myTextFieldModified = true; } }); final MyCancelEditingAction cancelEditingAction = new MyCancelEditingAction(); cancelEditingAction.registerCustomShortcutSet(CommonShortcuts.ESCAPE, myTfWithButton); }
From source file:com.intellij.util.ui.LocalPathCellEditor.java
License:Apache License
@Override public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) { myComponent = new CellEditorComponentWithBrowseButton<JTextField>( new TextFieldWithBrowseButton(createActionListener(table)), this); myComponent.getChildComponent().setText((String) value); return myComponent; }
From source file:consulo.nuget.module.extension.NuGetConfigPanel.java
License:Apache License
public NuGetConfigPanel(final NuGetMutableModuleExtension moduleExtension) { super(new VerticalFlowLayout(VerticalFlowLayout.TOP)); final JBTextField textField = new JBTextField(); textField.getEmptyText().setText(VfsUtil.urlToPath( moduleExtension.getModule().getModuleDirUrl() + "/" + NuGetModuleExtension.PACKAGES_CONFIG)); String configFileUrl = moduleExtension.getConfigFileUrl(); if (!StringUtil.isEmpty(configFileUrl)) { textField.setText(FileUtil.toSystemDependentName(VfsUtil.urlToPath(configFileUrl))); }// w w w.j av a2 s . c o m TextFieldWithBrowseButton browseButton = new TextFieldWithBrowseButton(textField); browseButton.addBrowseFolderListener("Select File", "Select NuGet package config file", moduleExtension.getProject(), FileChooserDescriptorFactory.createSingleFileDescriptor(XmlFileType.INSTANCE), new TextComponentAccessor<JTextField>() { @Override public String getText(JTextField component) { return FileUtil.toSystemDependentName(component.getText()); } @Override public void setText(JTextField component, String text) { component.setText(FileUtil.toSystemDependentName(text)); } }); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { moduleExtension.setConfigFilePath(FileUtil.toSystemIndependentName(textField.getText())); } }); add(LabeledComponent.create(browseButton, "Config file:")); }
From source file:org.jboss.forge.plugin.idea.components.FileChooserComponentBuilder.java
License:Open Source License
@Override public JComponent build(final InputComponent<?, Object> input, Container container) { // Added Label container.add(new JLabel(input.getLabel() == null ? input.getName() : input.getLabel())); final TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(new ActionListener() { @Override//from w w w . j a va 2 s.c om public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } }); // Set Default Value final ConverterFactory converterFactory = ForgeService.INSTANCE.getConverterFactory(); Converter<Object, String> converter = converterFactory.getConverter(input.getValueType(), String.class); String value = converter.convert(InputComponents.getValueFor(input)); fileField.setText(value == null ? "" : value); final JTextField textField = fileField.getTextField(); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { InputComponents.setValueFor(converterFactory, input, textField.getText()); } @Override public void insertUpdate(DocumentEvent e) { InputComponents.setValueFor(converterFactory, input, textField.getText()); } @Override public void changedUpdate(DocumentEvent e) { InputComponents.setValueFor(converterFactory, input, textField.getText()); } }); fileField.addBrowseFolderListener("Select a directory", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); container.add(fileField); return null; }
From source file:org.jetbrains.idea.svn.dialogs.browser.ExportOptionsDialog.java
License:Apache License
@Nullable protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(2, 2, 2, 2); gc.gridwidth = 1;/*from ww w . ja v a 2s .c o m*/ gc.gridheight = 1; gc.gridx = 0; gc.gridy = 0; gc.anchor = GridBagConstraints.WEST; gc.fill = GridBagConstraints.NONE; gc.weightx = 0; gc.weighty = 0; panel.add(new JLabel("Export:"), gc); gc.gridx += 1; gc.gridwidth = 2; gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; JLabel urlLabel = new JLabel(myURL.toString()); urlLabel.setFont(urlLabel.getFont().deriveFont(Font.BOLD)); panel.add(urlLabel, gc); gc.gridy += 1; gc.gridwidth = 1; gc.gridx = 0; gc.weightx = 0; gc.fill = GridBagConstraints.NONE; panel.add(new JLabel("Destination:"), gc); gc.gridx += 1; gc.gridwidth = 2; gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; myPathField = new TextFieldWithBrowseButton(this); myPathField.setText(myFile.getAbsolutePath()); myPathField.setEditable(false); panel.add(myPathField, gc); gc.gridy += 1; gc.gridx = 0; gc.weightx = 0; gc.gridwidth = 3; gc.fill = GridBagConstraints.NONE; // other options. final JLabel depthLabel = new JLabel(SvnBundle.message("label.depth.text")); depthLabel.setToolTipText(SvnBundle.message("label.depth.description")); panel.add(depthLabel, gc); ++gc.gridx; myDepth = new DepthCombo(false); panel.add(myDepth, gc); depthLabel.setLabelFor(myDepth); gc.gridx = 0; gc.gridy += 1; myForceCheckbox = new JCheckBox("Replace existing files"); myForceCheckbox.setSelected(true); panel.add(myForceCheckbox, gc); gc.gridy += 1; myExternalsCheckbox = new JCheckBox("Include externals locations"); myExternalsCheckbox.setSelected(true); panel.add(myExternalsCheckbox, gc); gc.gridy += 1; gc.gridwidth = 2; panel.add(new JLabel("Override 'native' EOLs with:"), gc); gc.gridx += 2; gc.gridwidth = 1; myEOLStyleBox = new JComboBox(new Object[] { "None", "LF", "CRLF", "CR" }); panel.add(myEOLStyleBox, gc); gc.gridy += 1; gc.gridwidth = 3; gc.gridx = 0; gc.weightx = 1; gc.weighty = 1; gc.anchor = GridBagConstraints.SOUTH; gc.fill = GridBagConstraints.HORIZONTAL; panel.add(new JSeparator(), gc); return panel; }
From source file:org.jetbrains.idea.svn.dialogs.browser.ImportOptionsDialog.java
License:Apache License
@Nullable protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(2, 2, 2, 2); gc.gridwidth = 1;/*from w w w.j ava 2 s . c o m*/ gc.gridheight = 1; gc.gridx = 0; gc.gridy = 0; gc.anchor = GridBagConstraints.WEST; gc.fill = GridBagConstraints.NONE; gc.weightx = 0; gc.weighty = 0; panel.add(new JLabel("Import to:"), gc); gc.gridx += 1; gc.gridwidth = 2; gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; JLabel urlLabel = new JLabel(myURL.toString()); urlLabel.setFont(urlLabel.getFont().deriveFont(Font.BOLD)); panel.add(urlLabel, gc); gc.gridy += 1; gc.gridwidth = 1; gc.gridx = 0; gc.weightx = 0; gc.fill = GridBagConstraints.NONE; panel.add(new JLabel("Import from:"), gc); gc.gridx += 1; gc.gridwidth = 2; gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; myPathField = new TextFieldWithBrowseButton(this); myPathField.setText(myFile.getAbsolutePath()); myPathField.setEditable(false); panel.add(myPathField, gc); // other options. gc.gridy += 1; gc.gridx = 0; gc.weightx = 0; gc.gridwidth = 3; gc.fill = GridBagConstraints.NONE; final JLabel depthLabel = new JLabel(SvnBundle.message("label.depth.text")); depthLabel.setToolTipText(SvnBundle.message("label.depth.description")); panel.add(depthLabel, gc); ++gc.gridx; myDepth = new DepthCombo(false); panel.add(myDepth, gc); depthLabel.setLabelFor(myDepth); gc.gridx = 0; gc.gridy += 1; myIncludeIgnoredCheckbox = new JCheckBox("Include ignored resources"); myIncludeIgnoredCheckbox.setSelected(true); panel.add(myIncludeIgnoredCheckbox, gc); gc.gridy += 1; panel.add(new JLabel("Commit Message:"), gc); gc.gridy += 1; gc.gridwidth = 3; gc.gridx = 0; gc.weightx = 1; gc.weighty = 1; gc.anchor = GridBagConstraints.NORTH; gc.fill = GridBagConstraints.BOTH; myCommitMessage = new JTextArea(10, 0); myCommitMessage.setWrapStyleWord(true); myCommitMessage.setLineWrap(true); panel.add(ScrollPaneFactory.createScrollPane(myCommitMessage), gc); gc.gridy += 1; gc.gridwidth = 3; gc.gridx = 0; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.NORTH; gc.fill = GridBagConstraints.HORIZONTAL; panel.add(new JLabel("Recent Messages: "), gc); gc.gridy += 1; final ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages(); Collections.reverse(messages); final String[] model = ArrayUtil.toStringArray(messages); final JComboBox messagesBox = new JComboBox(model); messagesBox.setRenderer(new MessageBoxCellRenderer()); panel.add(messagesBox, gc); String lastMessage = VcsConfiguration.getInstance(myProject).getLastNonEmptyCommitMessage(); if (lastMessage != null) { myCommitMessage.setText(lastMessage); myCommitMessage.selectAll(); } messagesBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myCommitMessage.setText(messagesBox.getSelectedItem().toString()); myCommitMessage.selectAll(); } }); return panel; }
From source file:org.jetbrains.idea.svn.dialogs.SSHCredentialsDialog.java
License:Apache License
protected JComponent createCenterPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints gb = new GridBagConstraints(); // top label. gb.insets = new Insets(2, 2, 2, 2); gb.weightx = 1;/*from w w w . j a va2s . c o m*/ gb.weighty = 0; gb.gridwidth = 3; gb.gridheight = 1; gb.gridx = 0; gb.gridy = 0; gb.anchor = GridBagConstraints.WEST; gb.fill = GridBagConstraints.HORIZONTAL; JLabel label = new JLabel(SvnBundle.message("label.ssh.authentication.realm", myRealm)); panel.add(label, gb); // user name gb.gridy += 1; gb.gridwidth = 1; gb.weightx = 0; gb.fill = GridBagConstraints.NONE; label = new JLabel(SvnBundle.message("label.ssh.user.name")); panel.add(label, gb); // user name field gb.gridx = 1; gb.gridwidth = 2; gb.weightx = 1; gb.fill = GridBagConstraints.HORIZONTAL; myUserNameText = new JTextField(); panel.add(myUserNameText, gb); label.setLabelFor(myUserNameText); if (myUserName != null) { myUserNameText.setText(myUserName); } myUserNameText.selectAll(); myUserNameText.getDocument().addDocumentListener(this); gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 3; // ssh agent type mySshAgentButton = new JBRadioButton(SvnBundle.message("radio.ssh.authentication.with.agent")); panel.add(mySshAgentButton, gb); gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 3; // password type myPasswordButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.with.password")); panel.add(myPasswordButton, gb); gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 1; myPasswordLabel = new JLabel(SvnBundle.message("label.ssh.password")); panel.add(myPasswordLabel, gb); // passworde field gb.gridx = 1; gb.weightx = 1; gb.gridwidth = 2; gb.fill = GridBagConstraints.HORIZONTAL; myPasswordText = new JPasswordField(); panel.add(myPasswordText, gb); myPasswordLabel.setLabelFor(myPasswordText); gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 3; myKeyButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.private.key")); panel.add(myKeyButton, gb); // key file. gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 1; myKeyFileLabel = new JLabel(SvnBundle.message("label.ssh.key.file")); panel.add(myKeyFileLabel, gb); // key field gb.gridx = 1; gb.weightx = 1; gb.gridwidth = 2; gb.fill = GridBagConstraints.HORIZONTAL; myKeyFileText = new TextFieldWithBrowseButton(this); myKeyFileText.setEditable(false); panel.add(myKeyFileText, gb); myKeyFileLabel.setLabelFor(myKeyFileText); gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 1; myPassphraseLabel = new JLabel(SvnBundle.message("label.ssh.passphrase")); panel.add(myPassphraseLabel, gb); // key field gb.gridx = 1; gb.weightx = 1; gb.gridwidth = 2; gb.fill = GridBagConstraints.HORIZONTAL; myPassphraseText = new JPasswordField(30); panel.add(myPassphraseText, gb); myPassphraseText.getDocument().addDocumentListener(this); myPassphraseText.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { checkKeyFile(); updateOKButton(); } }); myPassphraseLabel.setLabelFor(myPassphraseText); // key file. gb.gridy += 1; gb.weightx = 0; gb.gridx = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.NONE; gb.gridwidth = 1; myPortLabel = new JLabel(SvnBundle.message("label.ssh.port")); panel.add(myPortLabel, gb); // key field gb.gridx = 1; gb.weightx = 0; gb.gridwidth = 2; gb.fill = GridBagConstraints.NONE; myPortField = new JTextField(); myPortField.setColumns(6); panel.add(myPortField, gb); myPortLabel.setLabelFor(myPortField); myPortField.setText("22"); myPortField.setMinimumSize(myPortField.getPreferredSize()); myPortField.getDocument().addDocumentListener(this); ButtonGroup group = new ButtonGroup(); group.add(mySshAgentButton); group.add(myPasswordButton); group.add(myKeyButton); mySshAgentButton.setEnabled(myIsAgentAllowed); group.setSelected((myIsAgentAllowed ? mySshAgentButton : myPasswordButton).getModel(), true); gb.gridy += 1; gb.gridx = 0; gb.gridwidth = 3; gb.weightx = 1; gb.anchor = GridBagConstraints.WEST; gb.fill = GridBagConstraints.HORIZONTAL; myAllowSaveCheckBox = new JCheckBox(SvnBundle.message("checkbox.ssh.keep.for.current.session")); panel.add(myAllowSaveCheckBox, gb); if (!myAllowSave) { gb.gridy += 1; final JLabel cannotSaveLabel = new JLabel( SvnBundle.message("svn.cannot.save.credentials.store-auth-creds")); cannotSaveLabel.setForeground(UIUtil.getInactiveTextColor()); panel.add(cannotSaveLabel, gb); } gb.gridy += 1; panel.add(new JSeparator(), gb); gb.gridy += 1; gb.weighty = 1; panel.add(new JLabel(), gb); myAllowSaveCheckBox.setSelected(false); myAllowSaveCheckBox.setEnabled(myAllowSave); mySshAgentButton.addActionListener(this); myKeyButton.addActionListener(this); myPasswordButton.addActionListener(this); updateFields(); updateOKButton(); return panel; }
From source file:org.jetbrains.jet.plugin.framework.ui.ChoosePathDialog.java
License:Apache License
@Override protected JComponent createCenterPanel() { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setGap(3);/*from w w w. ja v a 2 s .c om*/ JPanel panel = new JPanel(verticalLayout); if (description != null) { panel.add(new JLabel(description)); } FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); FileTextField field = FileChooserFactory.getInstance().createFileTextField(descriptor, myDisposable); field.getField().setColumns(25); myPathField = new TextFieldWithBrowseButton(field.getField()); myPathField.addBrowseFolderListener("Choose Destination Folder", "Choose folder", myProject, descriptor); myPathField.setText(defaultPath); panel.add(myPathField); return panel; }
From source file:org.jetbrains.tfsIntegration.ui.ServerPathCellEditor.java
License:Apache License
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) { ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { ServerBrowserDialog d = new ServerBrowserDialog(myTitle, myProject, myServer, (String) getCellEditorValue(), true, false); if (d.showAndGet()) { myComponent.getChildComponent().setText(d.getSelectedPath()); }/*from www . j av a2 s. c o m*/ } }; myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(listener), this); myComponent.getChildComponent().setText((String) value); return myComponent; }