List of usage examples for com.intellij.openapi.ui Messages showTextAreaDialog
public static void showTextAreaDialog(final JTextField textField, @Nls(capitalization = Nls.Capitalization.Title) final String title, @NonNls final String dimensionServiceKey, final Function<? super String, ? extends List<String>> parser, final Function<? super List<String>, String> lineJoiner)
From source file:com.intellij.codeInspection.htmlInspections.HtmlUnknownTagInspection.java
License:Apache License
@Nonnull protected static JComponent createOptionsPanel(@Nonnull final HtmlUnknownElementInspection inspection) { final JPanel result = new JPanel(new BorderLayout()); final JPanel internalPanel = new JPanel(new BorderLayout()); result.add(internalPanel, BorderLayout.NORTH); final Ref<FieldPanel> panelRef = new Ref<FieldPanel>(); final FieldPanel additionalAttributesPanel = new FieldPanel(null, null, new ActionListener() { @Override//from ww w.j a v a2s. co m public void actionPerformed(ActionEvent event) { Messages.showTextAreaDialog(panelRef.get().getTextField(), StringUtil.wordsToBeginFromUpperCase(inspection.getPanelTitle()), inspection.getClass().getSimpleName(), new Function<String, List<String>>() { @Override public List<String> fun(String s) { return reparseProperties(s); } }, new Function<List<String>, String>() { @Override public String fun(List<String> strings) { return StringUtil.join(strings, ","); } }); } }, null); ((JButton) additionalAttributesPanel.getComponent(1)).setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON); panelRef.set(additionalAttributesPanel); additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { final Document document = e.getDocument(); try { final String text = document.getText(0, document.getLength()); if (text != null) { inspection.updateAdditionalEntries(text.trim()); } } catch (BadLocationException e1) { inspection.getLogger().error(e1); } } }); final JCheckBox checkBox = new JCheckBox(inspection.getCheckboxTitle()); checkBox.setSelected(inspection.isCustomValuesEnabled()); checkBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final boolean b = checkBox.isSelected(); if (b != inspection.isCustomValuesEnabled()) { inspection.enableCustomValues(b); additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled()); } } }); internalPanel.add(checkBox, BorderLayout.NORTH); internalPanel.add(additionalAttributesPanel, BorderLayout.CENTER); additionalAttributesPanel .setPreferredSize(new Dimension(150, additionalAttributesPanel.getPreferredSize().height)); additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled()); additionalAttributesPanel.setText(inspection.getAdditionalEntries()); return result; }
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 w w w.ja v a 2s . com*/ 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); }