diff --git a/grid/impl/src/csv/ui/CsvFormatForm.java b/grid/impl/src/csv/ui/CsvFormatForm.java index f77c8deac491..27780099be1b 100644 --- a/grid/impl/src/csv/ui/CsvFormatForm.java +++ b/grid/impl/src/csv/ui/CsvFormatForm.java @@ -5,25 +5,33 @@ import com.intellij.database.csv.CsvFormatEditor; import com.intellij.database.csv.CsvRecordFormat; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.EventListener; +import java.util.ResourceBundle; public class CsvFormatForm implements Disposable, CsvFormatEditor { - private JPanel myPanel; - private JBCheckBox myHeaderFormatCheckBox; + private final JPanel myPanel; + private final JBCheckBox myHeaderFormatCheckBox; - @SuppressWarnings("unused") private JPanel myRecordFormatPanel; - @SuppressWarnings("unused") private JPanel myHeaderFormatPanel; - private JBCheckBox myRowNumbersCheckBox; - private JPanel myHeaderFormatWithTitlePanel; + @SuppressWarnings("unused") private final JPanel myRecordFormatPanel; + @SuppressWarnings("unused") private final JPanel myHeaderFormatPanel; + private final JBCheckBox myRowNumbersCheckBox; + private final JPanel myHeaderFormatWithTitlePanel; private String myFormatName; private CsvRecordFormatForm myRecordFormatForm; @@ -34,6 +42,65 @@ public class CsvFormatForm implements Disposable, CsvFormatEditor { private CsvFormat myFormat; public CsvFormatForm(@NotNull Disposable parent, @NotNull CsvFormatUISettings settings) { + { + myRecordFormatForm = new CsvRecordFormatForm(this); + myHeaderFormatForm = new CsvRecordFormatForm(this); + myRecordFormatPanel = myRecordFormatForm.getMainPanel(); + myHeaderFormatPanel = myHeaderFormatForm.getMainPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.add(myRecordFormatPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myRowNumbersCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myRowNumbersCheckBox, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.first.column.is.header")); + panel1.add(myRowNumbersCheckBox, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHeaderFormatCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myHeaderFormatCheckBox, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.first.row.is.header")); + panel1.add(myHeaderFormatCheckBox, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHeaderFormatWithTitlePanel = new JPanel(); + myHeaderFormatWithTitlePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(myHeaderFormatWithTitlePanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.header.format.label")); + myHeaderFormatWithTitlePanel.add(titledSeparator1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHeaderFormatWithTitlePanel.add(myHeaderFormatPanel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } Disposer.register(parent, this); myHeaderFormatCheckBox.addItemListener(new ItemListener() { @@ -68,13 +135,53 @@ public class CsvFormatForm implements Disposable, CsvFormatEditor { myHeaderFormatWithTitlePanel.setVisible(false); } - private void createUIComponents() { - myRecordFormatForm = new CsvRecordFormatForm(this); - myHeaderFormatForm = new CsvRecordFormatForm(this); - myRecordFormatPanel = myRecordFormatForm.getMainPanel(); - myHeaderFormatPanel = myHeaderFormatForm.getMainPanel(); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void reset(@NotNull CsvFormat format) { myFormat = format; myResetting = true; diff --git a/grid/impl/src/csv/ui/CsvFormatsUI.java b/grid/impl/src/csv/ui/CsvFormatsUI.java index cf535535ee47..1b9086aa8c42 100644 --- a/grid/impl/src/csv/ui/CsvFormatsUI.java +++ b/grid/impl/src/csv/ui/CsvFormatsUI.java @@ -11,35 +11,81 @@ import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; public abstract class CsvFormatsUI implements Disposable { private CsvFormatsListComponent myFormatsList; - private JPanel myPanel; - private JPanel myFormatListPanel; + private final JPanel myPanel; + private final JPanel myFormatListPanel; - private JBLabel myFormatsLabel; - private CsvFormatForm myFormatForm; + private final JBLabel myFormatsLabel; + private final CsvFormatForm myFormatForm; - private JBScrollPane myFormatFormScrollPane; + private final JBScrollPane myFormatFormScrollPane; private CsvFormatPreview myPreview; private final CsvFormatUISettings mySettings; public CsvFormatsUI(boolean allowNameEditing, @NotNull CsvFormatUISettings settings) { mySettings = settings; + { + myFormatForm = new CsvFormatForm(this, mySettings); + myFormatsList = new CsvFormatsListComponent(this); + myFormatFormScrollPane = (JBScrollPane)ScrollPaneFactory.createScrollPane(); + myFormatFormScrollPane.setBorder(JBUI.Borders.empty()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myFormatFormScrollPane.setHorizontalScrollBarPolicy(31); + myPanel.add(myFormatFormScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myFormatFormScrollPane.setViewportView(panel1); + panel1.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + panel1.add(myFormatForm.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myFormatListPanel = new JPanel(); + myFormatListPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myFormatListPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(1, -1), null, 0, false)); + myFormatsLabel = new JBLabel(); + this.$$$loadLabelText$$$(myFormatsLabel, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.formats")); + myFormatListPanel.add(myFormatsLabel, BorderLayout.NORTH); + } new FormatsListToFormatEditorBond().setListeners(); //noinspection AbstractMethodCallInConstructor @@ -67,15 +113,55 @@ public abstract class CsvFormatsUI implements Disposable { myFormatFormScrollPane.setPreferredSize(myFormatFormScrollPane.getViewport().getView().getPreferredSize()); } - public @NotNull CsvFormatForm getFormatForm() { - return myFormatForm; + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } - private void createUIComponents() { - myFormatForm = new CsvFormatForm(this, mySettings); - myFormatsList = new CsvFormatsListComponent(this); - myFormatFormScrollPane = (JBScrollPane)ScrollPaneFactory.createScrollPane(); - myFormatFormScrollPane.setBorder(JBUI.Borders.empty()); + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + + public @NotNull CsvFormatForm getFormatForm() { + return myFormatForm; } public void reset(@NotNull List formats, @Nullable String nameToSelect) { diff --git a/grid/impl/src/csv/ui/CsvRecordFormatForm.java b/grid/impl/src/csv/ui/CsvRecordFormatForm.java index 662242f65578..a678accb042e 100644 --- a/grid/impl/src/csv/ui/CsvRecordFormatForm.java +++ b/grid/impl/src/csv/ui/CsvRecordFormatForm.java @@ -17,6 +17,9 @@ import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTextField; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; @@ -33,25 +36,34 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.TableCellEditor; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.EventListener; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.function.Supplier; public class CsvRecordFormatForm implements Disposable { @@ -72,12 +84,18 @@ public class CsvRecordFormatForm implements Disposable { } public static final List> DELIMITERS = - List.of(new LazyPair<>("\n", DataGridBundle.messagePointer("csv.format.settings.delimiter.newline"), DataGridBundle.messagePointer("csv.format.settings.delimiter.newline.lowercase")), - new LazyPair<>(" ", DataGridBundle.messagePointer("csv.format.settings.delimiter.space"), DataGridBundle.messagePointer("csv.format.settings.delimiter.space.lowercase")), - new LazyPair<>("\t", DataGridBundle.messagePointer("csv.format.settings.delimiter.tab"), DataGridBundle.messagePointer("csv.format.settings.delimiter.tab.lowercase")), - new LazyPair<>(",", DataGridBundle.messagePointer("csv.format.settings.delimiter.comma"), DataGridBundle.messagePointer("csv.format.settings.delimiter.comma.lowercase")), - new LazyPair<>(";", DataGridBundle.messagePointer("csv.format.settings.delimiter.semicolon"), DataGridBundle.messagePointer("csv.format.settings.delimiter.semicolon.lowercase")), - new LazyPair<>("|", DataGridBundle.messagePointer("csv.format.settings.delimiter.pipe"), DataGridBundle.messagePointer("csv.format.settings.delimiter.pipe.lowercase"))); + List.of(new LazyPair<>("\n", DataGridBundle.messagePointer("csv.format.settings.delimiter.newline"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.newline.lowercase")), + new LazyPair<>(" ", DataGridBundle.messagePointer("csv.format.settings.delimiter.space"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.space.lowercase")), + new LazyPair<>("\t", DataGridBundle.messagePointer("csv.format.settings.delimiter.tab"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.tab.lowercase")), + new LazyPair<>(",", DataGridBundle.messagePointer("csv.format.settings.delimiter.comma"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.comma.lowercase")), + new LazyPair<>(";", DataGridBundle.messagePointer("csv.format.settings.delimiter.semicolon"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.semicolon.lowercase")), + new LazyPair<>("|", DataGridBundle.messagePointer("csv.format.settings.delimiter.pipe"), + DataGridBundle.messagePointer("csv.format.settings.delimiter.pipe.lowercase"))); private static final List> NULL_TEXT_VARIANTS = List.of(new LazyPair<>(DataGridBundle.messagePointer("csv.format.settings.null.text.undefined"), null), new LazyPair<>(DataGridBundle.messagePointer("csv.format.settings.null.text.empty.string"), ""), @@ -88,19 +106,19 @@ public class CsvRecordFormatForm implements Disposable { CsvRecordFormat.QuotationPolicy.AS_NEEDED), new LazyPair<>(DataGridBundle.messagePointer("csv.format.settings.quotation.policy.always"), CsvRecordFormat.QuotationPolicy.ALWAYS)); - private JPanel myPanel; + private final JPanel myPanel; - private JBCheckBox myTrimWhitespaceCheckBox; - private JBTextField myRecordPrefixTextField; - private JBTextField myRecordSuffixTextField; - private ComboBox myNullTextCombo; - private ComboBox myValueSeparatorComboBox; - private ComboBox myRecordSeparatorComboBox; - private ComboBox myQuotationPolicyComboBox; - private JPanel myRowPrefixSuffixPanel; - private ActionLink myAddRowPrefixSuffixActionLink; - private JPanel myQuotesTablePanel; - private JBLabel myQuotationLabel; + private final JBCheckBox myTrimWhitespaceCheckBox; + private final JBTextField myRecordPrefixTextField; + private final JBTextField myRecordSuffixTextField; + private final ComboBox myNullTextCombo; + private final ComboBox myValueSeparatorComboBox; + private final ComboBox myRecordSeparatorComboBox; + private final ComboBox myQuotationPolicyComboBox; + private final JPanel myRowPrefixSuffixPanel; + private final ActionLink myAddRowPrefixSuffixActionLink; + private final JPanel myQuotesTablePanel; + private final JBLabel myQuotationLabel; private QuotesListTable myQuotesTable; @@ -108,6 +126,136 @@ public class CsvRecordFormatForm implements Disposable { private final EventDispatcher myEventDispatcher = EventDispatcher.create(ChangeListener.class); public CsvRecordFormatForm(@NotNull Disposable parent) { + { + myQuotesTable = new QuotesListTable(this); + myQuotesTable.getTable().getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + fireFormatChanged(); + } + }); + myAddRowPrefixSuffixActionLink = new ActionLink("", e -> { + setRowPrefixSuffixVisible(true); + }); + myAddRowPrefixSuffixActionLink.setBorder(JBUI.Borders.emptyTop(4)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(8, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.value.separator")); + myPanel.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myValueSeparatorComboBox = new ComboBox(); + myValueSeparatorComboBox.setEditable(true); + myPanel.add(myValueSeparatorComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(1, -1), null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.row.separator")); + myPanel.add(jBLabel2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRecordSeparatorComboBox = new ComboBox(); + myRecordSeparatorComboBox.setEditable(true); + myPanel.add(myRecordSeparatorComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(1, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 2, 6, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myRowPrefixSuffixPanel = new JPanel(); + myRowPrefixSuffixPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myRowPrefixSuffixPanel, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, true)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.row.prefix")); + myRowPrefixSuffixPanel.add(jBLabel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myRecordPrefixTextField = new JBTextField(); + myRecordPrefixTextField.setColumns(3); + myRecordPrefixTextField.setText(""); + myRowPrefixSuffixPanel.add(myRecordPrefixTextField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.row.suffix")); + myRowPrefixSuffixPanel.add(jBLabel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myRecordSuffixTextField = new JBTextField(); + myRecordSuffixTextField.setColumns(3); + myRecordSuffixTextField.setText(""); + myRowPrefixSuffixPanel.add(myRecordSuffixTextField, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + this.$$$loadButtonText$$$(myAddRowPrefixSuffixActionLink, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.add.row.prefix.suffix")); + myPanel.add(myAddRowPrefixSuffixActionLink, + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTrimWhitespaceCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myTrimWhitespaceCheckBox, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.trim.whitespaces")); + myPanel.add(myTrimWhitespaceCheckBox, + new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel5, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.null.value.text")); + myPanel.add(jBLabel5, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, true)); + panel1.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myQuotesTablePanel = new JPanel(); + myQuotesTablePanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myQuotesTablePanel, new GridConstraints(0, 0, 2, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myQuotationLabel = new JBLabel(); + this.$$$loadLabelText$$$(myQuotationLabel, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.quotation")); + myQuotesTablePanel.add(myQuotationLabel, BorderLayout.NORTH); + final JBLabel jBLabel6 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel6, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.quote.values")); + panel1.add(jBLabel6, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myQuotationPolicyComboBox = new ComboBox(); + panel1.add(myQuotationPolicyComboBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(1, -1), null, 0, false)); + myNullTextCombo = new ComboBox(); + myNullTextCombo.setEditable(true); + myPanel.add(myNullTextCombo, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(1, -1), null, 0, false)); + jBLabel1.setLabelFor(myValueSeparatorComboBox); + jBLabel2.setLabelFor(myRecordSeparatorComboBox); + jBLabel3.setLabelFor(myRecordPrefixTextField); + jBLabel4.setLabelFor(myRecordSuffixTextField); + jBLabel5.setLabelFor(myNullTextCombo); + jBLabel6.setLabelFor(myQuotationPolicyComboBox); + } Disposer.register(parent, this); myQuotesTablePanel.add(DataGridEditorUtil.labeledDecorator(myQuotationLabel, myQuotesTable.getTable())); ItemListener fireFormatChangedOnItemUpdate = new ItemListener() { @@ -143,20 +291,78 @@ public class CsvRecordFormatForm implements Disposable { myQuotationPolicyComboBox.addItemListener(fireFormatChangedOnItemUpdate); } - private void createUIComponents() { - myQuotesTable = new QuotesListTable(this); - myQuotesTable.getTable().getModel().addTableModelListener(new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - fireFormatChanged(); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); } - }); - myAddRowPrefixSuffixActionLink = new ActionLink("", e -> { - setRowPrefixSuffixVisible(true); - }); - myAddRowPrefixSuffixActionLink.setBorder(JBUI.Borders.emptyTop(4)); + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void reset(@NotNull CsvRecordFormat recordFormat) { myResetting = true; try { @@ -226,7 +432,9 @@ public class CsvRecordFormatForm implements Disposable { return mapping == null ? (V)selected : mapping.value; } - private static > void selectInCombo(@NotNull ComboBox combo, @NotNull List

mappings, final @Nullable V what) { + private static > void selectInCombo(@NotNull ComboBox combo, + @NotNull List

mappings, + final @Nullable V what) { P mapping = ContainerUtil.find(mappings, pair -> Objects.equals(pair.value, what)); if (mapping == null) { if (what != null) combo.setSelectedItem(what); @@ -323,7 +531,8 @@ public class CsvRecordFormatForm implements Disposable { } public void setQuotes(@NotNull List quotesList) { - List quotes = ContainerUtil.map(quotesList, quotes1 -> new String[]{quotes1.leftQuote, quotes1.rightQuote, escapeMethod(quotes1)}); + List quotes = + ContainerUtil.map(quotesList, quotes1 -> new String[]{quotes1.leftQuote, quotes1.rightQuote, escapeMethod(quotes1)}); model(this).setItems(new ArrayList<>(quotes)); } @@ -351,7 +560,7 @@ public class CsvRecordFormatForm implements Disposable { private static @NotNull ListTableModel model(@NotNull JTable t) { //noinspection unchecked - return (ListTableModel) t.getModel(); + return (ListTableModel)t.getModel(); } static class QuotesRowRenderer extends EditorTextFieldJBTableRowRenderer { @@ -374,18 +583,113 @@ public class CsvRecordFormatForm implements Disposable { } static class QuotesRowEditor extends EmbeddableEditorAdapter { - private JPanel myPanel; - private JBTextField myLeftQuoteTextField; - private JBTextField myRightQuoteTextField; - private ComboBox myEscapeMethodComboBox; + private final JPanel myPanel; + private final JBTextField myLeftQuoteTextField; + private final JBTextField myRightQuoteTextField; + private final ComboBox myEscapeMethodComboBox; QuotesRowEditor() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.quotes.left")); + myPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLeftQuoteTextField = new JBTextField(); + myPanel.add(myLeftQuoteTextField, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.quotes.right")); + myPanel.add(jBLabel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myRightQuoteTextField = new JBTextField(); + myPanel.add(myRightQuoteTextField, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.quotes.escape")); + myPanel.add(jBLabel3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myEscapeMethodComboBox = new ComboBox(); + myPanel.add(myEscapeMethodComboBox, + new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + } myLeftQuoteTextField.setColumns(4); myRightQuoteTextField.setColumns(4); myEscapeMethodComboBox.setModel(new DefaultComboBoxModel<>(new String[]{DUPLICATE_ESCAPE_METHOD.get()})); myEscapeMethodComboBox.setEditable(true); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull JComponent getComponent() { return myPanel; @@ -420,7 +724,7 @@ public class CsvRecordFormatForm implements Disposable { @Override public JComponent @NotNull [] getFocusableComponents() { - return new JComponent[] {myLeftQuoteTextField, myRightQuoteTextField, myEscapeMethodComboBox}; + return new JComponent[]{myLeftQuoteTextField, myRightQuoteTextField, myEscapeMethodComboBox}; } void editingStarted(@NotNull TableCellEditor editor) { diff --git a/grid/impl/src/run/ui/CustomPageSizeForm.java b/grid/impl/src/run/ui/CustomPageSizeForm.java index 33f4a6029dd4..ef251f388dee 100644 --- a/grid/impl/src/run/ui/CustomPageSizeForm.java +++ b/grid/impl/src/run/ui/CustomPageSizeForm.java @@ -2,25 +2,108 @@ package com.intellij.database.run.ui; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.fields.IntegerField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; + import static com.intellij.database.datagrid.GridPagingModel.UNLIMITED_PAGE_SIZE; /** * @author Liudmila Kornilova **/ public class CustomPageSizeForm { - private JBCheckBox myLimitCheckBox; - private JPanel myPanel; - private IntegerField myResultPageSizeTextField; + private final JBCheckBox myLimitCheckBox; + private final JPanel myPanel; + private final IntegerField myResultPageSizeTextField; public CustomPageSizeForm() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myLimitCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myLimitCheckBox, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", + "CustomPageSizeForm.checkbox.limit.page.size.to")); + myPanel.add(myLimitCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myResultPageSizeTextField = new IntegerField(); + myResultPageSizeTextField.setColumns(7); + myResultPageSizeTextField.setMinValue(1); + myPanel.add(myResultPageSizeTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myResultPageSizeTextField.setEnabled(false); myLimitCheckBox.addChangeListener(e -> myResultPageSizeTextField.setEnabled(myLimitCheckBox.isSelected())); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public IntegerField getResultPageSizeTextField() { return myResultPageSizeTextField; } diff --git a/grid/impl/src/settings/BytesLimitPerValueForm.java b/grid/impl/src/settings/BytesLimitPerValueForm.java index 1e27e04cd12b..0b9d5b4288bb 100644 --- a/grid/impl/src/settings/BytesLimitPerValueForm.java +++ b/grid/impl/src/settings/BytesLimitPerValueForm.java @@ -1,21 +1,100 @@ package com.intellij.database.settings; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.fields.IntegerField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Liudmila Kornilova **/ public class BytesLimitPerValueForm { - private JPanel myPanel; - private IntegerField myField; + private final JPanel myPanel; + private final IntegerField myField; public BytesLimitPerValueForm() { + { + myField = new IntegerField(null, 1, Integer.MAX_VALUE); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myField.setColumns(6); + myField.setHorizontalAlignment(4); + myField.setMinValue(1); + myPanel.add(myField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.maximum.number.of.bytes.per.value")); + jBLabel1.setToolTipText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.max.lob.tooltip")); + myPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void reset(@NotNull DataGridSettings settings) { myField.setValue(settings.getBytesLimitPerValue()); } @@ -32,10 +111,6 @@ public class BytesLimitPerValueForm { settings.setBytesLimitPerValue(myField.getValue()); } - private void createUIComponents() { - myField = new IntegerField(null, 1, Integer.MAX_VALUE); - } - public @NotNull JPanel getPanel() { return myPanel; } diff --git a/grid/impl/src/view/ui/DumpDataForm.java b/grid/impl/src/view/ui/DumpDataForm.java index 008cd9df65ee..d743d7a78775 100644 --- a/grid/impl/src/view/ui/DumpDataForm.java +++ b/grid/impl/src/view/ui/DumpDataForm.java @@ -62,6 +62,9 @@ import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.JBPanelWithEmptyText; import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ObjectUtils; import com.intellij.util.PathUtil; import com.intellij.util.containers.ContainerUtil; @@ -71,17 +74,22 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JComponent; import javax.swing.JEditorPane; +import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.Window; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.ItemEvent; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; @@ -90,6 +98,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import java.util.function.Supplier; import java.util.stream.IntStream; @@ -122,8 +131,8 @@ public class DumpDataForm { private static final int MAX_SOURCE_HEIGHT = 100; private static final Logger LOG = Logger.getInstance(DumpDataForm.class); private static final Set EXTRACTORS_NO_TRANSPOSE = Set.of("SQL-Insert-Statements.sql.groovy", - "JSON-Groovy.json.groovy", - "Python-DataFrame.py.groovy"); + "JSON-Groovy.json.groovy", + "Python-DataFrame.py.groovy"); private final Project myProject; private final DumpSource mySource; private final @NotNull Supplier myWindowSupplier; @@ -132,20 +141,20 @@ public class DumpDataForm { private final JBPanelWithEmptyText emptyTextPanel = new JBPanelWithEmptyText().withEmptyText(DataGridBundle.message("settings.database.DumpDialog.Preview.NoPreview")); - public JPanel myPanel; - private JBCheckBox myAddComputed; - private JBCheckBox myAddGenerated; - private JBCheckBox myAddTableDefinition; - private LabeledComponent myPreviewLabeledComponent; - private JBCheckBox myTranspose; - private JBLabel myAddColumnsLabel; - private LabeledComponentNoThrow myOutputFileOrDirectory; + public final JPanel myPanel; + private final JBCheckBox myAddComputed; + private final JBCheckBox myAddGenerated; + private final JBCheckBox myAddTableDefinition; + private final LabeledComponent myPreviewLabeledComponent; + private final JBCheckBox myTranspose; + private final JBLabel myAddColumnsLabel; + private final LabeledComponentNoThrow myOutputFileOrDirectory; private final OutputPathManager myOutputPathManager; - private LabeledComponentNoThrow> myExtractorCombobox; - private LabeledComponentNoThrow mySourceLabeledComponent; - private JBCheckBox myAddColumnHeader; - private JBCheckBox myAddRowHeader; - private JBCheckBox myAddQuery; + private final LabeledComponentNoThrow> myExtractorCombobox; + private final LabeledComponentNoThrow mySourceLabeledComponent; + private final JBCheckBox myAddColumnHeader; + private final JBCheckBox myAddRowHeader; + private final JBCheckBox myAddQuery; protected Disposable myDisposable; @@ -159,6 +168,110 @@ public class DumpDataForm { mySource = source; myWindowSupplier = windowSupplier; mySupportsAddQuery = supportsAddQuery; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new BorderLayout(0, 0)); + myPanel.add(panel1, new GridConstraints(0, 1, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(400, 500), null, 0, false)); + myPreviewLabeledComponent = new LabeledComponentNoThrow(); + myPreviewLabeledComponent.setLabelInsets(new Insets(0, 0, 5, 0)); + myPreviewLabeledComponent.setText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.Preview")); + panel1.add(myPreviewLabeledComponent, BorderLayout.CENTER); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(12, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(400, -1), new Dimension(400, -1), new Dimension(400, -1), 0, false)); + myAddComputed = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddComputed, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.ComputedColumns")); + panel2.add(myAddComputed, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddColumnsLabel = new JBLabel(); + this.$$$loadLabelText$$$(myAddColumnsLabel, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.AddColumns")); + panel2.add(myAddColumnsLabel, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddGenerated = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddGenerated, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", + "settings.database.DumpDialog.GeneratedColumns")); + panel2.add(myAddGenerated, + new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(9, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false)); + myTranspose = new JBCheckBox(); + this.$$$loadButtonText$$$(myTranspose, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.Transpose")); + panel2.add(myTranspose, + new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddTableDefinition = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddTableDefinition, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", + "settings.database.DumpDialog.AddTableDefinition")); + panel2.add(myAddTableDefinition, + new GridConstraints(7, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputFileOrDirectory = new LabeledComponentNoThrow(); + myOutputFileOrDirectory.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton"); + myOutputFileOrDirectory.setText( + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.SaveTo.File")); + panel2.add(myOutputFileOrDirectory, new GridConstraints(10, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myExtractorCombobox = new LabeledComponentNoThrow(); + myExtractorCombobox.setComponentClass("com.intellij.openapi.ui.ComboBox"); + myExtractorCombobox.setText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.Extractor")); + panel2.add(myExtractorCombobox, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(295, -1), new Dimension(295, -1), 0, false)); + mySourceLabeledComponent = new LabeledComponentNoThrow(); + mySourceLabeledComponent.setComponentClass("com.intellij.ui.components.JBScrollPane"); + mySourceLabeledComponent.setLabelInsets(new Insets(0, 0, 5, 0)); + mySourceLabeledComponent.setText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.Source")); + panel2.add(mySourceLabeledComponent, new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel2.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel2.add(spacer4, new GridConstraints(11, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myAddColumnHeader = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddColumnHeader, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.AddColumnHeader")); + panel2.add(myAddColumnHeader, + new GridConstraints(5, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddRowHeader = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddRowHeader, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.AddRowHeader")); + panel2.add(myAddRowHeader, + new GridConstraints(6, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddQuery = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddQuery, + this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "settings.database.DumpDialog.Excel.AddQuery")); + panel2.add(myAddQuery, + new GridConstraints(8, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } String sourceText = getSourceText(mySource); if (sourceText == null) { mySourceLabeledComponent.setVisible(false); @@ -258,6 +371,78 @@ public class DumpDataForm { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private @NotNull String getDefaultPath(String defaultFileName, DataExtractorFactory currentFactory) { try { Path path = Path.of(DataExtractorProperties.getOutputDir()); @@ -452,13 +637,23 @@ public class DumpDataForm { } public interface OutputPathManager { - @NotNull Path getFilePath(@NotNull Path dirPath, @NotNull String defaultName, @NotNull String extension); + @NotNull + Path getFilePath(@NotNull Path dirPath, @NotNull String defaultName, @NotNull String extension); + @NlsContexts.Label - @NotNull String getFieldName(); - @NotNull Path updateFileExtension(@NotNull Path filePath, @NotNull String extension); - @NotNull Path adjustChosenFile(@NotNull Path path, @NotNull String defaultName, @NotNull String extension); + @NotNull + String getFieldName(); + + @NotNull + Path updateFileExtension(@NotNull Path filePath, @NotNull String extension); + + @NotNull + Path adjustChosenFile(@NotNull Path path, @NotNull String defaultName, @NotNull String extension); + @NlsContexts.DialogMessage - @Nullable String validatePath(String path); + @Nullable + String validatePath(String path); + void focusGained(@NotNull TextFieldWithBrowseButton field); } diff --git a/images/src/org/intellij/images/editor/actions/BackgroundImageDialog.java b/images/src/org/intellij/images/editor/actions/BackgroundImageDialog.java index f0a9c7dbdd52..7f5a722251bf 100644 --- a/images/src/org/intellij/images/editor/actions/BackgroundImageDialog.java +++ b/images/src/org/intellij/images/editor/actions/BackgroundImageDialog.java @@ -43,6 +43,9 @@ import com.intellij.ui.SideBorder; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBPanelWithEmptyText; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.MathUtil; import com.intellij.util.ObjectUtils; @@ -64,6 +67,7 @@ import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSlider; @@ -79,15 +83,18 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; +import java.lang.reflect.Method; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import static com.intellij.openapi.wm.impl.IdeBackgroundUtil.EDITOR_PROP; import static com.intellij.openapi.wm.impl.IdeBackgroundUtil.FRAME_PROP; @@ -109,16 +116,16 @@ public class BackgroundImageDialog extends DialogWrapper { private String myPreviewTarget; private ActionToolbar myToolbar; - private JPanel myRoot; - private JSlider myOpacitySlider; - private JSpinner myOpacitySpinner; - private JPanel myPreviewPanel; - private ComboboxWithBrowseButton myPathField; - private JBCheckBox myThisProjectOnlyCb; - private JPanel myFlipPanel; - private JPanel myAnchorPanel; - private JPanel myFillPanel; - private JPanel myTargetPanel; + private final JPanel myRoot; + private final JSlider myOpacitySlider; + private final JSpinner myOpacitySpinner; + private final JPanel myPreviewPanel; + private final ComboboxWithBrowseButton myPathField; + private final JBCheckBox myThisProjectOnlyCb; + private final JPanel myFlipPanel; + private final JPanel myAnchorPanel; + private final JPanel myFillPanel; + private final JPanel myTargetPanel; private final JBCheckBox myFlipHorCb = new JBCheckBox(); private final JBCheckBox myFlipVerCb = new JBCheckBox(); @@ -132,6 +139,85 @@ public class BackgroundImageDialog extends DialogWrapper { public BackgroundImageDialog(@NotNull Project project, @Nullable @NlsSafe String selectedPath) { super(project, true); myProject = project; + { + ComboBox comboBox = new ComboBox<>(new CollectionComboBoxModel<>(), 100); + myPathField = new ComboboxWithBrowseButton(comboBox); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + myPreviewPanel = new JPanel(); + myPreviewPanel.setLayout(new BorderLayout(0, 0)); + myRoot.add(myPreviewPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 7, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myPathField, new GridConstraints(0, 2, 1, 5, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOpacitySlider = new JSlider(); + myOpacitySlider.setPaintTicks(false); + panel1.add(myOpacitySlider, new GridConstraints(1, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myOpacitySpinner = new JSpinner(); + panel1.add(myOpacitySpinner, new GridConstraints(1, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(64, 16), null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.text.image")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.text.opacity")); + panel1.add(jBLabel2, + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFillPanel = new JPanel(); + myFillPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myFillPanel, + new GridConstraints(2, 5, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnchorPanel = new JPanel(); + myAnchorPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myAnchorPanel, + new GridConstraints(2, 6, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFlipPanel = new JPanel(); + myFlipPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myFlipPanel, + new GridConstraints(2, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myThisProjectOnlyCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myThisProjectOnlyCb, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "checkbox.text.this.project.only")); + panel1.add(myThisProjectOnlyCb, + new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetPanel = new JPanel(); + myTargetPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myTargetPanel, new GridConstraints(4, 0, 1, 5, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + jBLabel1.setLabelFor(myPathField); + jBLabel2.setLabelFor(myOpacitySpinner); + } setTitle(IdeBundle.message("dialog.title.background.image")); myEditorPreview = createEditorPreview(getDisposable()); myIdePreview = createFramePreview(); @@ -150,6 +236,78 @@ public class BackgroundImageDialog extends DialogWrapper { pack(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override protected Action @NotNull [] createActions() { return ArrayUtil.append(super.createActions(), new AbstractAction(IdeBundle.message("button.clear.and.close")) { @@ -160,14 +318,6 @@ public class BackgroundImageDialog extends DialogWrapper { }); } - /** - * Called by UI Designer - */ - private void createUIComponents() { - ComboBox comboBox = new ComboBox<>(new CollectionComboBoxModel<>(), 100); - myPathField = new ComboboxWithBrowseButton(comboBox); - } - @Override protected void dispose() { super.dispose(); @@ -255,7 +405,8 @@ public class BackgroundImageDialog extends DialogWrapper { ((CardLayout)myPreviewPanel.getLayout()).show(myPreviewPanel, EDITOR); myPathField.getComboBox().setEditable(true); var descriptor = new FileChooserDescriptor(true, false, false, false, true, false) - .withExtensionFilter(IdeCoreBundle.message("file.chooser.files.label", ImagesBundle.message("filetype.images.display.name")), ImageFileTypeManager.getInstance().getImageFileType(), SvgFileType.INSTANCE); + .withExtensionFilter(IdeCoreBundle.message("file.chooser.files.label", ImagesBundle.message("filetype.images.display.name")), + ImageFileTypeManager.getInstance().getImageFileType(), SvgFileType.INSTANCE); myPathField.addBrowseFolderListener(null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT); JTextComponent textComponent = getComboEditor(); textComponent.getDocument().addDocumentListener(new DocumentAdapter() { @@ -265,12 +416,12 @@ public class BackgroundImageDialog extends DialogWrapper { imagePathChanged(); } }); - for (Enumeration e = getFillRbGroup().getElements(); e.hasMoreElements();) { + for (Enumeration e = getFillRbGroup().getElements(); e.hasMoreElements(); ) { AbstractButton button = e.nextElement(); button.setActionCommand(button.getText()); button.addItemListener(this::fillOrAnchorChanged); } - for (Enumeration e = getAnchorRbGroup().getElements(); e.hasMoreElements();) { + for (Enumeration e = getAnchorRbGroup().getElements(); e.hasMoreElements(); ) { AbstractButton button = e.nextElement(); button.setActionCommand(button.getText()); button.addItemListener(this::fillOrAnchorChanged); @@ -523,7 +674,7 @@ public class BackgroundImageDialog extends DialogWrapper { } Color color = getSelectionBackground(); p.setLayout(new GridLayout(3, 3, 1, 1)); - for (int i = 0; i < names.length; i ++) { + for (int i = 0; i < names.length; i++) { JRadioButton button = new JRadioButton(names[i], values[i] == IdeBackgroundUtil.Anchor.CENTER); button.setToolTipText(StringUtil.capitalize(button.getText().replace('-', ' '))); buttonGroup.add(button); @@ -540,7 +691,7 @@ public class BackgroundImageDialog extends DialogWrapper { } Color color = getSelectionBackground(); p.setLayout(new GridLayout(1, values.length, 1, 1)); - for (int i = 0; i < values.length; i ++) { + for (int i = 0; i < values.length; i++) { JRadioButton button = new JRadioButton(names[i], values[i] == Fill.SCALE); buttonGroup.add(button); button.setToolTipText(StringUtil.capitalize(button.getText().replace('-', ' '))); diff --git a/images/src/org/intellij/images/options/impl/ImagesOptionsComponent.java b/images/src/org/intellij/images/options/impl/ImagesOptionsComponent.java index 9b536e3a4207..a20e33748d56 100644 --- a/images/src/org/intellij/images/options/impl/ImagesOptionsComponent.java +++ b/images/src/org/intellij/images/options/impl/ImagesOptionsComponent.java @@ -27,6 +27,10 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ColorPanel; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.images.ImagesBundle; import org.intellij.images.options.EditorOptions; import org.intellij.images.options.ExternalEditorOptions; @@ -35,22 +39,28 @@ import org.intellij.images.options.Options; import org.intellij.images.options.TransparencyChessboardOptions; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Position; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * Options UI form bean. @@ -58,23 +68,122 @@ import java.awt.event.ItemListener; * @author Alexey Efimov */ final class ImagesOptionsComponent { - private JPanel contentPane; - private JCheckBox showGrid; - private JLabel gridLineZoomFactorLabel; - private JSpinner gridLineZoomFactor; - private JLabel gridLineSpanLabel; - private JSpinner gridLineSpan; - private JCheckBox showChessboard; - private JSpinner chessboardSize; - private JLabel chessboardSizeLabel; - private JLabel externalEditorLabel; - private TextFieldWithBrowseButton externalEditorPath; + private final JPanel contentPane; + private final JCheckBox showGrid; + private final JLabel gridLineZoomFactorLabel; + private final JSpinner gridLineZoomFactor; + private final JLabel gridLineSpanLabel; + private final JSpinner gridLineSpan; + private final JCheckBox showChessboard; + private final JSpinner chessboardSize; + private final JLabel chessboardSizeLabel; + private final JLabel externalEditorLabel; + private final TextFieldWithBrowseButton externalEditorPath; // Options private final Options options = new OptionsImpl(); ImagesOptionsComponent() { // Setup labels + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(12, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setEnabled(true); + panel1.setVisible(true); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/ImagesBundle", + "main.page.border.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + showGrid = new JCheckBox(); + this.$$$loadButtonText$$$(showGrid, this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "show.grid.lines")); + panel1.add(showGrid, new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + showChessboard = new JCheckBox(); + this.$$$loadButtonText$$$(showChessboard, this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "show.transparency.chessboard")); + panel1.add(showChessboard, new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + chessboardSizeLabel = new JLabel(); + this.$$$loadLabelText$$$(chessboardSizeLabel, this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "chessboard.cell.size")); + panel1.add(chessboardSizeLabel, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + chessboardSize = new JSpinner(); + panel1.add(chessboardSize, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gridLineSpanLabel = new JLabel(); + this.$$$loadLabelText$$$(gridLineSpanLabel, this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "show.grid.every")); + panel1.add(gridLineSpanLabel, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gridLineSpan = new JSpinner(); + panel1.add(gridLineSpan, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gridLineZoomFactorLabel = new JLabel(); + this.$$$loadLabelText$$$(gridLineZoomFactorLabel, this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "show.grid.zoom.limit")); + panel1.add(gridLineZoomFactorLabel, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gridLineZoomFactor = new JSpinner(); + panel1.add(gridLineZoomFactor, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText(""); + panel1.add(label1, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(22, -1), null, new Dimension(22, -1), 0, + false)); + final Spacer spacer2 = new Spacer(); + contentPane.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + contentPane.add(spacer3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + contentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/ImagesBundle", + "external.editor.border.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + externalEditorLabel = new JLabel(); + this.$$$loadLabelText$$$(externalEditorLabel, + this.$$$getMessageFromBundle$$$("messages/ImagesBundle", "external.editor.executable.path")); + panel2.add(externalEditorLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + externalEditorPath = new TextFieldWithBrowseButton(); + panel2.add(externalEditorPath, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel2.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(22, -1), null, new Dimension(22, -1), 0, + false)); + } gridLineZoomFactorLabel.setLabelFor(gridLineZoomFactor); gridLineSpanLabel.setLabelFor(gridLineSpan); chessboardSizeLabel.setLabelFor(chessboardSize); @@ -99,6 +208,78 @@ final class ImagesOptionsComponent { updateUI(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + public JPanel getContentPane() { return contentPane; } diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java index e1207dc67246..34a0da77de19 100644 --- a/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java @@ -11,30 +11,210 @@ import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class CompilerCacheConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myPanel; + private final JPanel myPanel; private final Project myProject; - private JBLabel myForceUpdateDescription; - private JBCheckBox myCbForceUpdateCaches; - private JBCheckBox myCbDisableCacheDownload; - private JTextField myMaxDownloadDurationField; - private JBLabel myMaxDownloadDurationDescription; - private JBCheckBox myCbCleanupAsynchronously; - private JBLabel myCleanupAsynchronouslyDescription; + private final JBLabel myForceUpdateDescription; + private final JBCheckBox myCbForceUpdateCaches; + private final JBCheckBox myCbDisableCacheDownload; + private final JTextField myMaxDownloadDurationField; + private final JBLabel myMaxDownloadDurationDescription; + private final JBCheckBox myCbCleanupAsynchronously; + private final JBLabel myCleanupAsynchronouslyDescription; public CompilerCacheConfigurable(final Project project) { myProject = project; - myForceUpdateDescription.setText("Turn off the heuristic that determines when it's faster to download cache or build locally and force downloads the nearest cache at each build"); //NON-NLS - myMaxDownloadDurationDescription.setText("Set maximum applicable time of caches download. If the approximate time of work will be higher local build will be executed."); //NON-NLS - myCleanupAsynchronouslyDescription.setText("Removes old cache directories asynchronously. This option might produce garbage under 'system/plugins' and spawn long-living rsync processes."); //NON-NLS + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCbForceUpdateCaches = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbForceUpdateCaches, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "compiler.cache.option.force.update")); + myPanel.add(myCbForceUpdateCaches, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbDisableCacheDownload = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbDisableCacheDownload, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "compiler.cache.option.disable.update")); + myPanel.add(myCbDisableCacheDownload, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel1.setFontColor(UIUtil.FontColor.BRIGHTER); + jBLabel1.setText("Turn off the caches download for example when you have a limited internet connection."); //NON-NLS + myPanel.add(jBLabel1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 2, false)); + myMaxDownloadDurationDescription = new JBLabel(); + myMaxDownloadDurationDescription.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myMaxDownloadDurationDescription.setFontColor(UIUtil.FontColor.BRIGHTER); + myMaxDownloadDurationDescription.setText(""); //NON-NLS + myPanel.add(myMaxDownloadDurationDescription, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myForceUpdateDescription = new JBLabel(); + myForceUpdateDescription.setBackground(new Color(-1907998)); + myForceUpdateDescription.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myForceUpdateDescription.setFontColor(UIUtil.FontColor.BRIGHTER); + myForceUpdateDescription.setHorizontalAlignment(10); + myForceUpdateDescription.setHorizontalTextPosition(11); + myForceUpdateDescription.setText(""); //NON-NLS + myForceUpdateDescription.setVerticalAlignment(0); + myPanel.add(myForceUpdateDescription, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 2, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(883, 34), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "compiler.cache.option.max.download.time")); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMaxDownloadDurationField = new JTextField(); + myMaxDownloadDurationField.setColumns(5); + panel1.add(myMaxDownloadDurationField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "compiler.cache.option.max.download.time.units")); + panel1.add(jBLabel2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myCbCleanupAsynchronously = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbCleanupAsynchronously, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "compiler.cache.option.cleanup.asynchronously")); + myPanel.add(myCbCleanupAsynchronously, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myCleanupAsynchronouslyDescription = new JBLabel(); + myCleanupAsynchronouslyDescription.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myCleanupAsynchronouslyDescription.setFontColor(UIUtil.FontColor.BRIGHTER); + myCleanupAsynchronouslyDescription.setText(""); //NON-NLS + myPanel.add(myCleanupAsynchronouslyDescription, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 2, + false)); + } + myForceUpdateDescription.setText( + "Turn off the heuristic that determines when it's faster to download cache or build locally and force downloads the nearest cache at each build"); //NON-NLS + myMaxDownloadDurationDescription.setText( + "Set maximum applicable time of caches download. If the approximate time of work will be higher local build will be executed."); //NON-NLS + myCleanupAsynchronouslyDescription.setText( + "Removes old cache directories asynchronously. This option might produce garbage under 'system/plugins' and spawn long-living rsync processes."); //NON-NLS } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public String getDisplayName() { return JavaCompilerBundle.message("compiler.cache.description"); @@ -55,7 +235,8 @@ public class CompilerCacheConfigurable implements SearchableConfigurable, Config boolean isModified = ComparingUtils.isModified(myCbForceUpdateCaches, CompilerCacheLoadingSettings.getForceUpdateValue()); isModified |= ComparingUtils.isModified(myCbDisableCacheDownload, CompilerCacheLoadingSettings.getDisableUpdateValue()); isModified |= ComparingUtils.isModified(myCbCleanupAsynchronously, CompilerCacheLoadingSettings.getCleanupAsynchronouslyValue()); - isModified |= ComparingUtils.isModified(myMaxDownloadDurationField, String.valueOf(CompilerCacheLoadingSettings.getMaxDownloadDuration())); + isModified |= + ComparingUtils.isModified(myMaxDownloadDurationField, String.valueOf(CompilerCacheLoadingSettings.getMaxDownloadDuration())); return isModified; } diff --git a/java/compiler/impl/src/com/intellij/compiler/options/RmicConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/RmicConfigurable.java index 32da488afe8e..2a8d5fa5b463 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/RmicConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/RmicConfigurable.java @@ -9,31 +9,91 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.ui.RawCommandLineEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.java.compiler.RmicCompilerOptions; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Eugene Zhuravlev */ public class RmicConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myPanel; - private JCheckBox myCbEnabled; - private JCheckBox myCbGenerateIiopStubs; - private JCheckBox myCbDebuggingInfo; - private JCheckBox myCbGenerateNoWarnings; - private RawCommandLineEditor myAdditionalOptionsField; + private final JPanel myPanel; + private final JCheckBox myCbEnabled; + private final JCheckBox myCbGenerateIiopStubs; + private final JCheckBox myCbDebuggingInfo; + private final JCheckBox myCbGenerateNoWarnings; + private final RawCommandLineEditor myAdditionalOptionsField; private final RmicCompilerOptions myRmicSettings; private final Project myProject; - private JLabel myFieldLabel; + private final JLabel myFieldLabel; public RmicConfigurable(final Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbEnabled = new JCheckBox(); + this.$$$loadButtonText$$$(myCbEnabled, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "rmic.option.enable.rmi.stubs")); + panel1.add(myCbEnabled, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbGenerateIiopStubs = new JCheckBox(); + this.$$$loadButtonText$$$(myCbGenerateIiopStubs, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "rmic.option.generate.iiop.stubs")); + panel1.add(myCbGenerateIiopStubs, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbDebuggingInfo = new JCheckBox(); + myCbDebuggingInfo.setSelected(false); + this.$$$loadButtonText$$$(myCbDebuggingInfo, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "java.compiler.option.generate.debugging.info")); + panel1.add(myCbDebuggingInfo, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbGenerateNoWarnings = new JCheckBox(); + this.$$$loadButtonText$$$(myCbGenerateNoWarnings, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "java.compiler.option.generate.no.warnings")); + panel1.add(myCbGenerateNoWarnings, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(10, 8, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myFieldLabel = new JLabel(); + this.$$$loadLabelText$$$(myFieldLabel, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "java.compiler.option.additional.command.line.parameters")); + panel2.add(myFieldLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAdditionalOptionsField = new RawCommandLineEditor(); + panel2.add(myAdditionalOptionsField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } myRmicSettings = RmicConfiguration.getOptions(project); myProject = project; myCbEnabled.addItemListener(new ItemListener() { @@ -45,6 +105,78 @@ public class RmicConfigurable implements SearchableConfigurable, Configurable.No myAdditionalOptionsField.setDialogCaption(myFieldLabel.getText()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setOptionsEnabled(final boolean selected) { myCbGenerateIiopStubs.setEnabled(selected); myCbGenerateNoWarnings.setEnabled(selected); @@ -87,8 +219,8 @@ public class RmicConfigurable implements SearchableConfigurable, Configurable.No @Override public void apply() throws ConfigurationException { try { - myRmicSettings.IS_EANABLED = myCbEnabled.isSelected(); - myRmicSettings.GENERATE_IIOP_STUBS = myCbGenerateIiopStubs.isSelected(); + myRmicSettings.IS_EANABLED = myCbEnabled.isSelected(); + myRmicSettings.GENERATE_IIOP_STUBS = myCbGenerateIiopStubs.isSelected(); myRmicSettings.DEBUGGING_INFO = myCbDebuggingInfo.isSelected(); myRmicSettings.GENERATE_NO_WARNINGS = myCbGenerateNoWarnings.isSelected(); myRmicSettings.ADDITIONAL_OPTIONS_STRING = myAdditionalOptionsField.getText(); diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ValidationConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/ValidationConfigurable.java index 65c0196c23f7..07f639b61e28 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/ValidationConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/ValidationConfigurable.java @@ -15,9 +15,11 @@ import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.IdeBorderFactory; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.NullableFunction; import com.intellij.util.SmartList; import com.intellij.util.containers.CollectionFactory; @@ -27,13 +29,18 @@ import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; /** @@ -41,33 +48,136 @@ import java.util.Set; */ public class ValidationConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myPanel; - private JCheckBox myValidateBox; - private ElementsChooser myValidators; - private JPanel myExcludedEntriesPanel; - private JPanel myValidatorsPanel; + private final JPanel myPanel; + private final JCheckBox myValidateBox; + private final ElementsChooser myValidators; + private final JPanel myExcludedEntriesPanel; + private final JPanel myValidatorsPanel; private final Project myProject; private final ValidationConfiguration myConfiguration; private final ExcludedEntriesConfigurable myExcludedConfigurable; public ValidationConfigurable(final Project project) { myProject = project; + { + myValidators = new ElementsChooser<>(true) { + @Override + protected String getItemText(final @NotNull Validator validator) { + return validator.getDescription(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myValidateBox = new JCheckBox(); + this.$$$loadButtonText$$$(myValidateBox, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "settings.validate.on.build")); + myPanel.add(myValidateBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, 0)); + myPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myValidatorsPanel = new JPanel(); + myValidatorsPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myValidatorsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndentWithoutInsets"); + panel1.add(myValidatorsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myValidatorsPanel.add(myValidators, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, + null, new Dimension(150, 50), null, 0, false)); + myExcludedEntriesPanel = new JPanel(); + myExcludedEntriesPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myExcludedEntriesPanel.putClientProperty("BorderFactoryClass", + "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndentWithoutInsets"); + panel1.add(myExcludedEntriesPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Splitter splitter1 = new Splitter(); + splitter1.setOrientation(true); + panel1.add(splitter1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + splitter1.setFirstComponent(myValidatorsPanel); + splitter1.setSecondComponent(myExcludedEntriesPanel); + } myConfiguration = ValidationConfiguration.getInstance(myProject); myExcludedConfigurable = createExcludedConfigurable(project); - myValidatorsPanel.setBorder(IdeBorderFactory.createTitledBorder(JavaCompilerBundle.message("settings.validators"), false, JBUI.insetsTop(8)).setShowLine(false)); + myValidatorsPanel.setBorder( + IdeBorderFactory.createTitledBorder(JavaCompilerBundle.message("settings.validators"), false, JBUI.insetsTop(8)).setShowLine(false)); myValidators.getEmptyText().setText(JavaCompilerBundle.message("no.validators")); - myExcludedEntriesPanel.setBorder(IdeBorderFactory.createTitledBorder(JavaCompilerBundle.message("settings.exclude.from.validation"), false, JBUI.insetsTop(8)).setShowLine(false)); + myExcludedEntriesPanel.setBorder( + IdeBorderFactory.createTitledBorder(JavaCompilerBundle.message("settings.exclude.from.validation"), false, JBUI.insetsTop(8)) + .setShowLine(false)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private static ExcludedEntriesConfigurable createExcludedConfigurable(@NotNull Project project) { var index = project.isDefault() ? null : ProjectRootManager.getInstance(project).getFileIndex(); var descriptor = new FileChooserDescriptor(true, true, false, false, false, true) .withFileFilter(file -> index == null || !index.isExcluded(file)); List allContentRoots = new ArrayList<>(); - for (final Module module: ModuleManager.getInstance(project).getModules()) { + for (final Module module : ModuleManager.getInstance(project).getModules()) { final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots(); Collections.addAll(allContentRoots, moduleContentRoots); } @@ -108,18 +218,18 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura Set set = CollectionFactory.createCustomHashingStrategySet(new HashingStrategy<>() { @Override public int hashCode(Validator object) { - return object==null?0:object.getId().hashCode(); + return object == null ? 0 : object.getId().hashCode(); } @Override public boolean equals(Validator o1, Validator o2) { - return (o1==null?"":o1.getId()).equals(o2==null?"":o2.getId()); + return (o1 == null ? "" : o1.getId()).equals(o2 == null ? "" : o2.getId()); } }); set.addAll(selectedElements); return myConfiguration.isValidateOnBuild() != myValidateBox.isSelected() || - set.retainAll(markedValidators) || - myExcludedConfigurable.isModified(); + set.retainAll(markedValidators) || + myExcludedConfigurable.isModified(); } @Override @@ -127,7 +237,7 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura myConfiguration.setValidateOnBuild(myValidateBox.isSelected()); for (int i = 0; i < myValidators.getElementCount(); i++) { final Validator validator = myValidators.getElementAt(i); - myConfiguration.setSelected(validator, myValidators.isElementMarked(validator)); + myConfiguration.setSelected(validator, myValidators.isElementMarked(validator)); } myExcludedConfigurable.apply(); } @@ -143,7 +253,9 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura } private @Unmodifiable List getMarkedValidators(@NotNull List validators) { - return ContainerUtil.mapNotNull(validators, (NullableFunction)validator -> myConfiguration.isSelected(validator) ? validator : null); + return ContainerUtil.mapNotNull(validators, (NullableFunction)validator -> myConfiguration.isSelected(validator) + ? validator + : null); } private List getValidators() { @@ -155,13 +267,4 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura public void disposeUIResources() { myExcludedConfigurable.disposeUIResources(); } - - private void createUIComponents() { - myValidators = new ElementsChooser<>(true) { - @Override - protected String getItemText(final @NotNull Validator validator) { - return validator.getDescription(); - } - }; - } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactFromModulesDialog.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactFromModulesDialog.java index a546e2ab641a..cfd5b3ffbe94 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactFromModulesDialog.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactFromModulesDialog.java @@ -14,36 +14,124 @@ import com.intellij.packaging.elements.PackagingElementResolvingContext; import com.intellij.packaging.impl.elements.ManifestFileUtil; import com.intellij.ui.ComboboxSpeedSearch; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; public class JarArtifactFromModulesDialog extends DialogWrapper { - private JPanel myMainPanel; - private TextFieldWithBrowseButton myMainClassField; - private JComboBox myModuleComboBox; - private JLabel myMainClassLabel; - private TextFieldWithBrowseButton myManifestDirField; - private JLabel myManifestDirLabel; - private JRadioButton myExtractJarsRadioButton; - private JRadioButton myCopyJarsRadioButton; - private JCheckBox myIncludeTestsCheckBox; + private final JPanel myMainPanel; + private final TextFieldWithBrowseButton myMainClassField; + private final JComboBox myModuleComboBox; + private final JLabel myMainClassLabel; + private final TextFieldWithBrowseButton myManifestDirField; + private final JLabel myManifestDirLabel; + private final JRadioButton myExtractJarsRadioButton; + private final JRadioButton myCopyJarsRadioButton; + private final JCheckBox myIncludeTestsCheckBox; private final PackagingElementResolvingContext myContext; public JarArtifactFromModulesDialog(PackagingElementResolvingContext context) { super(context.getProject()); myContext = context; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainClassLabel = new JLabel(); + this.$$$loadLabelText$$$(myMainClassLabel, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "jar.artifacts.dialog.label.main.class")); + myMainPanel.add(myMainClassLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myMainClassField = new TextFieldWithBrowseButton(); + myMainPanel.add(myMainClassField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "jar.artifacts.dialog.label.module")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myModuleComboBox = new JComboBox(); + myMainPanel.add(myModuleComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(400, -1), null, 0, false)); + myManifestDirLabel = new JLabel(); + this.$$$loadLabelText$$$(myManifestDirLabel, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "jar.artifacts.dialog.label.directory.for.metainf")); + myMainPanel.add(myManifestDirLabel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myManifestDirField = new TextFieldWithBrowseButton(); + myMainPanel.add(myManifestDirField, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 2, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myMainPanel.add(panel1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/JavaCompilerBundle", "jar.artifacts.dialog.border.title.jar.files.from.libraries"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myExtractJarsRadioButton = new JRadioButton(); + myExtractJarsRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myExtractJarsRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "jar.artifacts.dialog.radio.button.extract.to.the.target.jar")); + panel1.add(myExtractJarsRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myCopyJarsRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCopyJarsRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "jar.artifacts.dialog.radio.button.copy.to.the.output.directory.and.link.via.manifest")); + panel1.add(myCopyJarsRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIncludeTestsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myIncludeTestsCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "jar.artifacts.dialog.checkbox.include.tests")); + myMainPanel.add(myIncludeTestsCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + label1.setLabelFor(myModuleComboBox); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myExtractJarsRadioButton); + buttonGroup.add(myCopyJarsRadioButton); + } setTitle(JavaCompilerBundle.message("create.jar.from.modules")); myMainClassLabel.setLabelFor(myMainClassField.getTextField()); myManifestDirLabel.setLabelFor(myManifestDirField.getTextField()); @@ -72,6 +160,78 @@ public class JarArtifactFromModulesDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void setupModulesCombobox(PackagingElementResolvingContext context) { final Module[] modules = context.getModulesProvider().getModules().clone(); Arrays.sort(modules, ModulesAlphaComparator.INSTANCE); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/properties/ElementWithManifestPropertiesPanel.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/properties/ElementWithManifestPropertiesPanel.java index 096eade59b50..57b4b7fb10a6 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/properties/ElementWithManifestPropertiesPanel.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/properties/ElementWithManifestPropertiesPanel.java @@ -15,45 +15,135 @@ import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.ManifestFileConfiguration; import com.intellij.packaging.ui.PackagingElementPropertiesPanel; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; import java.awt.CardLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; -public abstract class ElementWithManifestPropertiesPanel> extends PackagingElementPropertiesPanel { +public abstract class ElementWithManifestPropertiesPanel> + extends PackagingElementPropertiesPanel { private final E myElement; private final ArtifactEditorContext myContext; - private JPanel myMainPanel; - private TextFieldWithBrowseButton myMainClassField; - private TextFieldWithBrowseButton myClasspathField; - private JLabel myTitleLabel; - private JButton myCreateManifestButton; - private JButton myUseExistingManifestButton; - private JPanel myPropertiesPanel; - private TextFieldWithBrowseButton myManifestPathField; - private JLabel myManifestNotFoundLabel; + private final JPanel myMainPanel; + private final TextFieldWithBrowseButton myMainClassField; + private final TextFieldWithBrowseButton myClasspathField; + private final JLabel myTitleLabel; + private final JButton myCreateManifestButton; + private final JButton myUseExistingManifestButton; + private final JPanel myPropertiesPanel; + private final TextFieldWithBrowseButton myManifestPathField; + private final JLabel myManifestNotFoundLabel; private ManifestFileConfiguration myManifestFileConfiguration; public ElementWithManifestPropertiesPanel(E element, final ArtifactEditorContext context) { myElement = element; myContext = context; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(5, 5, 5, 5), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myPropertiesPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(panel1, "properties"); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "label.text.main.class")); + panel1.add(label1, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMainClassField = new TextFieldWithBrowseButton(); + panel1.add(myMainClassField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "label.text.class.path")); + panel1.add(label2, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClasspathField = new TextFieldWithBrowseButton(); + panel1.add(myClasspathField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTitleLabel = new JLabel(); + myTitleLabel.setText("element name"); + panel1.add(myTitleLabel, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", "element.with.manifest.label.manifest.file")); + panel1.add(label3, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myManifestPathField = new TextFieldWithBrowseButton(); + panel1.add(myManifestPathField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(panel2, "buttons"); + myCreateManifestButton = new JButton(); + this.$$$loadButtonText$$$(myCreateManifestButton, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "element.with.manifest.button.create.manifest")); + panel2.add(myCreateManifestButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel2.add(spacer3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myUseExistingManifestButton = new JButton(); + this.$$$loadButtonText$$$(myUseExistingManifestButton, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "element.with.manifest.button.use.existing.manifest")); + panel2.add(myUseExistingManifestButton, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myManifestNotFoundLabel = new JLabel(); + this.$$$loadLabelText$$$(myManifestNotFoundLabel, this.$$$getMessageFromBundle$$$("messages/JavaCompilerBundle", + "element.with.manifest.label.meta.inf.manifest.mf.file.not.found")); + panel2.add(myManifestNotFoundLabel, + new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label3.setLabelFor(myManifestPathField); + } ManifestFileUtil.setupMainClassField(context.getProject(), myMainClassField); myClasspathField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - Messages.showTextAreaDialog(myClasspathField.getTextField(), JavaCompilerBundle.message("edit.classpath"), "classpath-attribute-editor"); + Messages.showTextAreaDialog(myClasspathField.getTextField(), JavaCompilerBundle.message("edit.classpath"), + "classpath-attribute-editor"); } }); myClasspathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @@ -78,6 +168,78 @@ public abstract class ElementWithManifestPropertiesPanel chooseManifest()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void createManifest() { final VirtualFile file = ManifestFileUtil.showDialogAndCreateManifest(myContext, myElement); if (file == null) { @@ -129,8 +291,11 @@ public abstract class ElementWithManifestPropertiesPanel markups) { super(parent, defaultText, markups); mySuggestAdditionalMarkup = suggestAdditionalMarkup; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myAdditionalPropertiesPanel = new JPanel(); + myAdditionalPropertiesPanel.setLayout(new GridLayoutManager(2, 1, new Insets(5, 0, 0, 0), -1, -1)); + myDescriptionLabel = new MultiLineLabel(); + myDescriptionLabel.setText(""); + myAdditionalPropertiesPanel.add(myDescriptionLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCbMarkAdditionalFields = new JCheckBox(); + this.$$$loadButtonText$$$(myCbMarkAdditionalFields, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.object.markup.dialog.mark.referenced")); + myAdditionalPropertiesPanel.add(myCbMarkAdditionalFields, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myDescriptionLabel.setText(JavaDebuggerBundle.message("if.the.value.is.referenced.by.a.constant.field")); - myCbMarkAdditionalFields.setSelected(PropertiesComponent.getInstance().getBoolean(MARK_ALL_REFERENCED_VALUES_KEY, MARK_ALL_REFERENCED_VALUES_DEFAULT_VALUE)); + myCbMarkAdditionalFields.setSelected( + PropertiesComponent.getInstance().getBoolean(MARK_ALL_REFERENCED_VALUES_KEY, MARK_ALL_REFERENCED_VALUES_DEFAULT_VALUE)); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myAdditionalPropertiesPanel; } + @Override protected void doOKAction() { if (mySuggestAdditionalMarkup) { - PropertiesComponent.getInstance().setValue(MARK_ALL_REFERENCED_VALUES_KEY, myCbMarkAdditionalFields.isSelected(), MARK_ALL_REFERENCED_VALUES_DEFAULT_VALUE); + PropertiesComponent.getInstance() + .setValue(MARK_ALL_REFERENCED_VALUES_KEY, myCbMarkAdditionalFields.isSelected(), MARK_ALL_REFERENCED_VALUES_DEFAULT_VALUE); } super.doOKAction(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java index 9ffbb33347f8..3f2ae43656dc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java @@ -12,32 +12,119 @@ import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtilRt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xdebugger.impl.settings.DebuggerConfigurable; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor { private static final Logger LOG = Logger.getInstance(GenericDebuggerParametersRunnerConfigurable.class); - private JPanel myPanel; - private JTextField myAddressField; - private JPanel myShMemPanel; - private JPanel myPortPanel; - private JTextField myPortField; + private final JPanel myPanel; + private final JTextField myAddressField; + private final JPanel myShMemPanel; + private final JPanel myPortPanel; + private final JTextField myPortField; private boolean myIsLocal = false; - private JButton myDebuggerSettings; - private JRadioButton mySocketTransport; - private JRadioButton myShmemTransport; - private JPanel myTransportPanel; + private final JButton myDebuggerSettings; + private final JRadioButton mySocketTransport; + private final JRadioButton myShmemTransport; + private final JPanel myTransportPanel; public GenericDebuggerParametersRunnerConfigurable(final Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myShMemPanel = new JPanel(); + myShMemPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myShMemPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.generic.debugger.parameters.patcher.configurable.shmem.address")); + myShMemPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAddressField = new JTextField(); + myAddressField.setText(""); + myShMemPanel.add(myAddressField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + myPortPanel = new JPanel(); + myPortPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myPortPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.generic.debugger.parameters.patcher.configurable.port")); + myPortPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myPortField = new JTextField(); + myPortField.setColumns(5); + myPortPanel.add(myPortField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myDebuggerSettings = new JButton(); + this.$$$loadButtonText$$$(myDebuggerSettings, + this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", "button.debugger.settings")); + myPanel.add(myDebuggerSettings, new GridConstraints(1, 1, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTransportPanel = new JPanel(); + myTransportPanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myTransportPanel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.generic.debugger.parameters.patcher.configurable.transport")); + myTransportPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + mySocketTransport = new JRadioButton(); + mySocketTransport.setSelected(true); + this.$$$loadButtonText$$$(mySocketTransport, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.generic.debugger.parameters.patcher.configurable.socket")); + myTransportPanel.add(mySocketTransport, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myShmemTransport = new JRadioButton(); + this.$$$loadButtonText$$$(myShmemTransport, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.generic.debugger.parameters.patcher.configurable.shmem")); + myTransportPanel.add(myShmemTransport, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myTransportPanel.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } myDebuggerSettings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -70,6 +157,78 @@ public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor< group.add(myShmemTransport); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private boolean isSocket() { return getTransport() == DebuggerSettings.SOCKET_TRANSPORT; } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index aae301770143..c23103c3cd0a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -39,7 +39,11 @@ import com.intellij.ui.AnActionButtonRunnable; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.ArrayUtilRt; import com.intellij.util.PlatformIcons; @@ -55,6 +59,7 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -67,27 +72,116 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumnModel; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.nio.file.Path; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; public final class CaptureConfigurable implements SearchableConfigurable, NoScroll { private static final Logger LOG = Logger.getInstance(CaptureConfigurable.class); private final Project myProject; - private JCheckBox myDebuggerAgent; - private JCheckBox myThrottling; - private JButton myConfigureAnnotationsButton; - private JPanel myCapturePanel; + private final JCheckBox myDebuggerAgent; + private final JCheckBox myThrottling; + private final JButton myConfigureAnnotationsButton; + private final JPanel myCapturePanel; private MyTableModel myTableModel; - private JCheckBox myCaptureVariables; - private JPanel myPanel; + private final JCheckBox myCaptureVariables; + private final JPanel myPanel; public CaptureConfigurable(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myDebuggerAgent = new JBCheckBox(); + this.$$$loadButtonText$$$(myDebuggerAgent, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.capture.configurable.debugger.agent")); + myPanel.add(myDebuggerAgent, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myConfigureAnnotationsButton = new JButton(); + this.$$$loadButtonText$$$(myConfigureAnnotationsButton, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.capture.configurable.annotations.configure")); + myPanel.add(myConfigureAnnotationsButton, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myThrottling = new JBCheckBox(); + this.$$$loadButtonText$$$(myThrottling, + this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", "label.capture.configurable.throttling")); + myPanel.add(myThrottling, + new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myCapturePanel = new JPanel(); + myCapturePanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myCapturePanel, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCaptureVariables = new JBCheckBox(); + this.$$$loadButtonText$$$(myCaptureVariables, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.capture.configurable.capture.variables")); + myCapturePanel.add(myCaptureVariables, BorderLayout.SOUTH); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull String getId() { return getHelpTopic(); @@ -284,7 +378,8 @@ public final class CaptureConfigurable implements SearchableConfigurable, NoScro @Override public void actionPerformed(final @NotNull AnActionEvent e) { VirtualFileWrapper wrapper = FileChooserFactory.getInstance() - .createSaveFileDialog(new FileSaverDescriptor(JavaDebuggerBundle.message("export.selected.capture.points.to.file"), "", "xml"), e.getProject()) + .createSaveFileDialog(new FileSaverDescriptor(JavaDebuggerBundle.message("export.selected.capture.points.to.file"), "", "xml"), + e.getProject()) .save((Path)null, null); if (wrapper == null) return; diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/ThreadsViewConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/ThreadsViewConfigurable.java index 48414b3a57e0..72629ae1eaf9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/ThreadsViewConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/ThreadsViewConfigurable.java @@ -7,30 +7,111 @@ import com.intellij.debugger.impl.DebuggerSession; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.xdebugger.impl.XDebuggerUtilImpl; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Eugene Belyaev */ public class ThreadsViewConfigurable implements Configurable { private final ThreadsViewSettings mySettings; - private JPanel myPanel; - private JCheckBox myShowGroupsCheckBox; - private JCheckBox myLineNumberCheckBox; - private JCheckBox myClassNameCheckBox; - private JCheckBox mySourceCheckBox; - private JCheckBox myShowSyntheticsCheckBox; - private JCheckBox myShowCurrentThreadChechBox; - private JCheckBox myPackageCheckBox; - private JCheckBox myArgsTypesCheckBox; + private final JPanel myPanel; + private final JCheckBox myShowGroupsCheckBox; + private final JCheckBox myLineNumberCheckBox; + private final JCheckBox myClassNameCheckBox; + private final JCheckBox mySourceCheckBox; + private final JCheckBox myShowSyntheticsCheckBox; + private final JCheckBox myShowCurrentThreadChechBox; + private final JCheckBox myPackageCheckBox; + private final JCheckBox myArgsTypesCheckBox; private final CompositeDataBinding myDataBinding = new CompositeDataBinding(); public ThreadsViewConfigurable(ThreadsViewSettings settings) { mySettings = settings; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, 0)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myShowGroupsCheckBox = new JCheckBox(); + myShowGroupsCheckBox.setMargin(new Insets(5, 2, 2, 2)); + this.$$$loadButtonText$$$(myShowGroupsCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.thread.groups")); + panel1.add(myShowGroupsCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowSyntheticsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myShowSyntheticsCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.stack.frames.for.synthetic.methods")); + panel1.add(myShowSyntheticsCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowCurrentThreadChechBox = new JCheckBox(); + this.$$$loadButtonText$$$(myShowCurrentThreadChechBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.current.thread.on.top")); + panel1.add(myShowCurrentThreadChechBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, 0)); + myPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myLineNumberCheckBox = new JCheckBox(); + myLineNumberCheckBox.setMargin(new Insets(5, 2, 2, 2)); + this.$$$loadButtonText$$$(myLineNumberCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.line.number")); + panel2.add(myLineNumberCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClassNameCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myClassNameCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.class.name")); + panel2.add(myClassNameCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySourceCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(mySourceCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.source.file.name")); + panel2.add(mySourceCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPackageCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myPackageCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.package")); + panel2.add(myPackageCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myArgsTypesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myArgsTypesCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.threads.view.configurable.show.prams.types")); + panel2.add(myArgsTypesCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myDataBinding.addBinding(new ToggleButtonBinding("SHOW_CLASS_NAME", myClassNameCheckBox)); myDataBinding.addBinding(new ToggleButtonBinding("SHOW_PACKAGE_NAME", myPackageCheckBox)); @@ -41,6 +122,53 @@ public class ThreadsViewConfigurable implements Configurable { myDataBinding.addBinding(new ToggleButtonBinding("SHOW_CURRENT_THREAD", myShowCurrentThreadChechBox)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public String getDisplayName() { return JavaDebuggerBundle.message("threads.view.configurable.display.name"); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java index 737425c86d6a..6920283578c1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java @@ -22,29 +22,123 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public abstract class AddFieldBreakpointDialog extends DialogWrapper { private final Project myProject; - private JPanel myPanel; - private TextFieldWithBrowseButton myFieldChooser; - private TextFieldWithBrowseButton myClassChooser; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myFieldChooser; + private final TextFieldWithBrowseButton myClassChooser; public AddFieldBreakpointDialog(Project project) { super(project, true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, 6)); + myClassChooser = new TextFieldWithBrowseButton(); + myPanel.add(myClassChooser, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myFieldChooser = new TextFieldWithBrowseButton(); + myPanel.add(myFieldChooser, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JPanel panel1 = new JPanel(); + myPanel.add(panel1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(-1, 1), null, new Dimension(-1, 1), 0, false)); + panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.add.field.breakpoint.dialog.field.name")); + myPanel.add(label1, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", "label.add.field.breakpoint.dialog.fq.name")); + myPanel.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } setTitle(JavaDebuggerBundle.message("add.field.breakpoint.dialog.title")); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected JComponent createCenterPanel() { myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java index bf6903ec1639..25ff07a77709 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java @@ -19,25 +19,112 @@ import com.intellij.debugger.JavaDebuggerBundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Eugene Zhuravlev */ public class AddWildcardBreakpointDialog extends DialogWrapper { - private JPanel myPanel; - private JTextField myClassPatternField; - private JTextField myMethodNameField; + private final JPanel myPanel; + private final JTextField myClassPatternField; + private final JTextField myMethodNameField; public AddWildcardBreakpointDialog(Project project) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myClassPatternField = new JTextField(); + myPanel.add(myClassPatternField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(300, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.add.wildcard.breakpoint.dialog.method.name")); + myPanel.add(label1, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMethodNameField = new JTextField(); + myPanel.add(myMethodNameField, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "label.add.wildcard.breakpoint.dialog.class.pattern")); + myPanel.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myMethodNameField); + label2.setLabelFor(myClassPatternField); + } setTitle(JavaDebuggerBundle.message("add.method.breakpoint")); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void doOKAction() { if (getClassPattern().isEmpty()) { diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java index 65af16ec033d..e459e7846676 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java @@ -13,6 +13,9 @@ import com.intellij.psi.PsiClass; import com.intellij.ui.FieldPanel; import com.intellij.ui.MultiLineTooltipUI; import com.intellij.ui.components.fields.ExtendableTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.text.LiteralFormatUtil; import com.intellij.util.ui.JBUI; import com.intellij.xdebugger.breakpoints.XBreakpoint; @@ -25,6 +28,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; @@ -32,28 +36,33 @@ import javax.swing.JTextField; import javax.swing.JToolTip; import javax.swing.ToolTipManager; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.ResourceBundle; -public class JavaBreakpointFiltersPanel> extends XBreakpointCustomPropertiesPanel { - private JPanel myConditionsPanel; - private JCheckBox myInstanceFiltersCheckBox; - private JPanel myInstanceFiltersFieldPanel; - private JCheckBox myClassFiltersCheckBox; - private ClassFiltersField myClassFiltersField; - private JCheckBox myPassCountCheckbox; - private JTextField myPassCountField; - private JCheckBox myCatchCheckBox; - private ClassFiltersField myCatchClassFilters; - private JPanel myCatchFiltersPanel; - private JPanel myPassCountFieldPanel; - private JCheckBox myCallerFiltersCheckBox; - private CallerFiltersField myCallerFilters; - private JPanel myCallerFiltersPanel; +public class JavaBreakpointFiltersPanel> + extends XBreakpointCustomPropertiesPanel { + private final JPanel myConditionsPanel; + private final JCheckBox myInstanceFiltersCheckBox; + private final JPanel myInstanceFiltersFieldPanel; + private final JCheckBox myClassFiltersCheckBox; + private final ClassFiltersField myClassFiltersField; + private final JCheckBox myPassCountCheckbox; + private final JTextField myPassCountField; + private final JCheckBox myCatchCheckBox; + private final ClassFiltersField myCatchClassFilters; + private final JPanel myCatchFiltersPanel; + private final JPanel myPassCountFieldPanel; + private final JCheckBox myCallerFiltersCheckBox; + private final CallerFiltersField myCallerFilters; + private final JPanel myCallerFiltersPanel; private final FieldPanel myInstanceFiltersField; @@ -64,6 +73,152 @@ public class JavaBreakpointFiltersPanel>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myConditionsPanel = new JPanel(); + myConditionsPanel.setLayout(new GridLayoutManager(6, 2, new Insets(2, 0, 5, 0), -1, 7)); + myConditionsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + panel1.add(myConditionsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myInstanceFiltersCheckBox = new JCheckBox(); + myInstanceFiltersCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myInstanceFiltersCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "breakpoint.properties.panel.option.instance.filters")); + panel2.add(myInstanceFiltersCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myInstanceFiltersFieldPanel = new JPanel(); + panel3.add(myInstanceFiltersFieldPanel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(panel4, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myClassFiltersCheckBox = new JCheckBox(); + myClassFiltersCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myClassFiltersCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "breakpoint.properties.panel.option.class.filters")); + panel4.add(myClassFiltersCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.add(panel5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel5.add(myClassFiltersField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(panel6, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPassCountCheckbox = new JCheckBox(); + myPassCountCheckbox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myPassCountCheckbox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "breakpoint.properties.panel.option.pass.count")); + panel6.add(myPassCountCheckbox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPassCountFieldPanel = new JPanel(); + myPassCountFieldPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel6.add(myPassCountFieldPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myPassCountField = new JTextField(); + myPassCountField.setEnabled(false); + myPassCountField.setHorizontalAlignment(10); + myPassCountFieldPanel.add(myPassCountField, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(15, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myConditionsPanel.add(spacer1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myCatchFiltersPanel = new JPanel(); + myCatchFiltersPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(myCatchFiltersPanel, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCatchCheckBox = new JCheckBox(); + myCatchCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myCatchCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "breakpoint.properties.panel.option.catch.class.filters")); + myCatchFiltersPanel.add(myCatchCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCatchFiltersPanel.add(panel7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel7.add(myCatchClassFilters, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCallerFiltersPanel = new JPanel(); + myCallerFiltersPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(myCallerFiltersPanel, + new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCallerFiltersCheckBox = new JCheckBox(); + myCallerFiltersCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myCallerFiltersCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaDebuggerBundle", + "breakpoint.properties.panel.option.caller.filter")); + myCallerFiltersPanel.add(myCallerFiltersCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCallerFiltersPanel.add(panel8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + panel8.add(myCallerFilters, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null, new ActionListener() { @Override @@ -111,6 +266,50 @@ public class JavaBreakpointFiltersPanel thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + @Override public @NotNull JComponent getComponent() { return myConditionsPanel; @@ -152,16 +351,21 @@ public class JavaBreakpointFiltersPanel implements PanelWithAnchor { - private CommonJavaParametersPanel myCommonProgramParameters; - private LabeledComponent myJarPathComponent; - private LabeledComponentNoThrow myModuleComponent; - private JPanel myWholePanel; + private final CommonJavaParametersPanel myCommonProgramParameters; + private final LabeledComponent myJarPathComponent; + private final LabeledComponentNoThrow myModuleComponent; + private final JPanel myWholePanel; - private JrePathEditor myJrePathEditor; + private final JrePathEditor myJrePathEditor; private final Project myProject; private JComponent myAnchor; public JarApplicationConfigurable(final Project project) { myProject = project; + { + myJarPathComponent = new LabeledComponent<>(); + var textFieldWithBrowseButton = new TextFieldWithBrowseButton(); + textFieldWithBrowseButton.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFileDescriptor("jar") + .withTitle(ExecutionBundle.message("choose.jar.file"))); + myJarPathComponent.setComponent(textFieldWithBrowseButton); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCommonProgramParameters = new CommonJavaParametersPanel(); + myWholePanel.add(myCommonProgramParameters, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myJrePathEditor = new JrePathEditor(); + myWholePanel.add(myJrePathEditor, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myJarPathComponent.setLabelLocation("West"); + myJarPathComponent.setText(this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "label.path.to.jar")); + myWholePanel.add(myJarPathComponent, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myModuleComponent = new LabeledComponentNoThrow(); + myModuleComponent.setComponentClass("com.intellij.application.options.ModulesComboBox"); + myModuleComponent.setLabelLocation("West"); + myModuleComponent.setText(this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "label.search.sources.using.module.classpath")); + myWholePanel.add(myModuleComponent, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myAnchor = UIUtil.mergeComponentsWithAnchor(myJarPathComponent, myCommonProgramParameters, myJrePathEditor); ModulesComboBox modulesComboBox = myModuleComponent.getComponent(); modulesComboBox.allowEmptySelection(JavaCompilerBundle.message("whole.project")); @@ -42,6 +90,28 @@ public class JarApplicationConfigurable extends SettingsEditor thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public void applyEditorTo(final @NotNull JarApplicationConfiguration configuration) throws ConfigurationException { myCommonProgramParameters.applyTo(configuration); @@ -65,14 +135,6 @@ public class JarApplicationConfigurable extends SettingsEditor(); - var textFieldWithBrowseButton = new TextFieldWithBrowseButton(); - textFieldWithBrowseButton.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFileDescriptor("jar") - .withTitle(ExecutionBundle.message("choose.jar.file"))); - myJarPathComponent.setComponent(textFieldWithBrowseButton); - } - @Override public JComponent getAnchor() { return myAnchor; diff --git a/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java b/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java index 8d36e614dbb1..d00ccf5022a0 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java +++ b/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java @@ -11,26 +11,66 @@ import com.intellij.openapi.ide.CopyPasteManager; import com.intellij.openapi.ui.FixedSizeButton; import com.intellij.openapi.util.NlsContexts; import com.intellij.ui.PopupHandler; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.PlatformIcons; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ConfigurationArgumentsHelpArea extends JPanel { - private JTextArea myHelpArea; - private JPanel myPanel; - private JLabel myLabel; - private JPanel myToolbarPanel; + private final JTextArea myHelpArea; + private final JPanel myPanel; + private final JLabel myLabel; + private final JPanel myToolbarPanel; public ConfigurationArgumentsHelpArea() { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myLabel = new JLabel(); + this.$$$loadLabelText$$$(myLabel, this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", + "environment.variables.helper.use.arguments.label")); + myPanel.add(myLabel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_SOUTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + jBScrollPane1.setHorizontalScrollBarPolicy(31); + jBScrollPane1.setVisible(true); + myPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(100, -1), null, null, 0, false)); + myHelpArea = new JTextArea(); + myHelpArea.setEditable(false); + myHelpArea.setLineWrap(true); + myHelpArea.setVisible(true); + myHelpArea.setWrapStyleWord(true); + jBScrollPane1.setViewportView(myHelpArea); + myToolbarPanel = new JPanel(); + myToolbarPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myToolbarPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myLabel.setLabelFor(myHelpArea); + } add(myPanel); setBorder(JBUI.Borders.emptyTop(10)); @@ -51,6 +91,53 @@ public class ConfigurationArgumentsHelpArea extends JPanel { myToolbarPanel.setVisible(false); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void setToolbarVisible() { myToolbarPanel.setVisible(true); } @@ -79,6 +166,4 @@ public class ConfigurationArgumentsHelpArea extends JPanel { CopyPasteManager.getInstance().setContents(contents); } } - - } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java index c2ea1e38e658..647de0099e88 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java @@ -19,22 +19,32 @@ import com.intellij.ui.CheckBoxList; import com.intellij.ui.CheckBoxListListener; import com.intellij.ui.CollectionListModel; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.FormBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -44,22 +54,87 @@ public class DownloadingOptionsDialog extends DialogWrapper { private enum AdditionalDownloadType {SOURCES, DOCUMENTATION} - private JPanel myPanel; - private CheckBoxList myFilesList; - private TextFieldWithBrowseButton myDirectoryField; - private JCheckBox myDownloadSourcesCheckBox; - private JCheckBox myDownloadJavadocsCheckBox; - private JLabel myFilesToDownloadLabel; - private JLabel myCopyDownloadedFilesToLabel; - private JPanel myNameWrappingPanel; + private final JPanel myPanel; + private final CheckBoxList myFilesList; + private final TextFieldWithBrowseButton myDirectoryField; + private final JCheckBox myDownloadSourcesCheckBox; + private final JCheckBox myDownloadJavadocsCheckBox; + private final JLabel myFilesToDownloadLabel; + private final JLabel myCopyDownloadedFilesToLabel; + private final JPanel myNameWrappingPanel; private final JComboBox myVersionComboBox; private final LibraryNameAndLevelPanel myNameAndLevelPanel; private final DownloadableLibraryType myLibraryType; private FrameworkLibraryVersion myLastSelectedVersion; - public DownloadingOptionsDialog(@NotNull Component parent, final @NotNull LibraryDownloadSettings settings, @NotNull List versions, + public DownloadingOptionsDialog(@NotNull Component parent, + final @NotNull LibraryDownloadSettings settings, + @NotNull List versions, final boolean showNameAndLevel) { super(parent, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myFilesToDownloadLabel = new JLabel(); + this.$$$loadLabelText$$$(myFilesToDownloadLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.files.to.download")); + myPanel.add(myFilesToDownloadLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDirectoryField = new TextFieldWithBrowseButton(); + myPanel.add(myDirectoryField, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(350, -1), null, 0, false)); + myCopyDownloadedFilesToLabel = new JLabel(); + this.$$$loadLabelText$$$(myCopyDownloadedFilesToLabel, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.copy.downloaded.files.to")); + myPanel.add(myCopyDownloadedFilesToLabel, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myDownloadSourcesCheckBox = new JCheckBox(); + myDownloadSourcesCheckBox.setFocusable(false); + this.$$$loadButtonText$$$(myDownloadSourcesCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.sources")); + panel1.add(myDownloadSourcesCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myDownloadJavadocsCheckBox = new JCheckBox(); + myDownloadJavadocsCheckBox.setFocusable(false); + this.$$$loadButtonText$$$(myDownloadJavadocsCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.javadocs")); + panel1.add(myDownloadJavadocsCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myNameWrappingPanel = new JPanel(); + myNameWrappingPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myNameWrappingPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFilesList = new CheckBoxList(); + jBScrollPane1.setViewportView(myFilesList); + myFilesToDownloadLabel.setLabelFor(jBScrollPane1); + } setTitle(JavaUiBundle.message("dialog.title.downloading.options")); myLibraryType = settings.getLibraryType(); LOG.assertTrue(!versions.isEmpty()); @@ -122,6 +197,78 @@ public class DownloadingOptionsDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateSourcesAndJavadocCheckboxes() { final FrameworkLibraryVersion version = getSelectedVersion(); boolean sourcesCheckboxEnabled; @@ -145,10 +292,11 @@ public class DownloadingOptionsDialog extends DialogWrapper { checkBox.setEnabled(enabled); } - private static boolean haveAdditionalDownloads(final List descriptions, AdditionalDownloadType type) { + private static boolean haveAdditionalDownloads(final List descriptions, + AdditionalDownloadType type) { for (DownloadableLibraryFileDescription description : descriptions) { if (type == AdditionalDownloadType.SOURCES && description.getSourcesDescription() != null - || type == AdditionalDownloadType.DOCUMENTATION && description.getDocumentationDescription() != null) { + || type == AdditionalDownloadType.DOCUMENTATION && description.getDocumentationDescription() != null) { return true; } } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/EditLibraryDialog.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/EditLibraryDialog.java index 6c5d771be52c..13cd146ab9b1 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/EditLibraryDialog.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/EditLibraryDialog.java @@ -8,21 +8,25 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsCom import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Disposer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.FormBuilder; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Insets; /** * @author Dmitry Avdeev */ public class EditLibraryDialog extends DialogWrapper { - private JPanel myEditorPanel; - private JPanel myPanel; - private JPanel myNameAndLevelPanelWrapper; + private final JPanel myEditorPanel; + private final JPanel myPanel; + private final JPanel myNameAndLevelPanelWrapper; private final LibraryNameAndLevelPanel myNameAndLevelPanel; private final LibraryCompositionSettings mySettings; private final LibraryEditor myLibraryEditor; @@ -33,6 +37,26 @@ public class EditLibraryDialog extends DialogWrapper { super(parent, true); mySettings = settings; myLibraryEditor = libraryEditor; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myEditorPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myNameAndLevelPanelWrapper = new JPanel(); + myNameAndLevelPanelWrapper.setLayout(new BorderLayout(0, 0)); + myPanel.add(myNameAndLevelPanelWrapper, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + } myLibraryRootsComponent = new LibraryRootsComponent(null, libraryEditor); myLibraryRootsComponent.resetProperties(); @@ -42,10 +66,14 @@ public class EditLibraryDialog extends DialogWrapper { setTitle(JavaUiBundle.message(newLibrary ? "dialog.title.create.library" : "dialog.title.edit.library")); myBuilder = LibraryNameAndLevelPanel.createFormBuilder(); - myNameAndLevelPanel = new LibraryNameAndLevelPanel(myBuilder, libraryEditor.getName(), newLibrary ? settings.getNewLibraryLevel() : null); + myNameAndLevelPanel = + new LibraryNameAndLevelPanel(myBuilder, libraryEditor.getName(), newLibrary ? settings.getNewLibraryLevel() : null); init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected JComponent createCenterPanel() { JComponent editor = myLibraryRootsComponent.getComponent(); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java index 2111932885b8..c7c4dda1b4c8 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java @@ -35,15 +35,20 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.SortedComboBoxModel; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.PathUtil; import com.intellij.util.PlatformIcons; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.download.DownloadableFileSetVersions; import com.intellij.util.ui.RadioButtonEnumModel; +import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JComboBox; @@ -55,12 +60,15 @@ import javax.swing.JRadioButton; import javax.swing.SwingUtilities; import java.awt.CardLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -68,21 +76,21 @@ import java.util.List; public class LibraryOptionsPanel implements Disposable { private static final Logger LOG = Logger.getInstance(LibraryOptionsPanel.class); - private JBLabel myMessageLabel; - private JPanel myPanel; - private JButton myConfigureButton; - private JComboBox myExistingLibraryComboBox; - private JRadioButton myDoNotCreateRadioButton; - private JPanel myConfigurationPanel; - private JButton myCreateButton; - private JRadioButton myDownloadRadioButton; - private JRadioButton myUseLibraryRadioButton; - private JLabel myUseLibraryLabel; - private JLabel myHiddenLabel; - private JPanel myRootPanel; - private JRadioButton myUseFromProviderRadioButton; - private JPanel mySimplePanel; - private ButtonGroup myButtonGroup; + private final JBLabel myMessageLabel; + private final JPanel myPanel; + private final JButton myConfigureButton; + private final JComboBox myExistingLibraryComboBox; + private final JRadioButton myDoNotCreateRadioButton; + private final JPanel myConfigurationPanel; + private final JButton myCreateButton; + private final JRadioButton myDownloadRadioButton; + private final JRadioButton myUseLibraryRadioButton; + private final JLabel myUseLibraryLabel; + private final JLabel myHiddenLabel; + private final JPanel myRootPanel; + private final JRadioButton myUseFromProviderRadioButton; + private final JPanel mySimplePanel; + private final ButtonGroup myButtonGroup; private LibraryCompositionSettings mySettings; private final CustomLibraryDescription myLibraryDescription; @@ -116,6 +124,133 @@ public class LibraryOptionsPanel implements Disposable { final boolean showDoNotCreateOption) { myLibraryDescription = libraryDescription; myLibrariesContainer = librariesContainer; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel = new JPanel(); + myRootPanel.setLayout(new CardLayout(0, 0)); + panel1.add(myRootPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setEnabled(false); + myRootPanel.add(myPanel, "editing"); + myDownloadRadioButton = new JRadioButton(); + myDownloadRadioButton.setSelected(false); + this.$$$loadButtonText$$$(myDownloadRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "radio.button.download")); + myPanel.add(myDownloadRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(207, 22), null, 0, + false)); + myDoNotCreateRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myDoNotCreateRadioButton, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "radio.button.set.up.library.later")); + myPanel.add(myDoNotCreateRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + mySimplePanel = new JPanel(); + mySimplePanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(mySimplePanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myExistingLibraryComboBox = new JComboBox(); + mySimplePanel.add(myExistingLibraryComboBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myCreateButton = new JButton(); + this.$$$loadButtonText$$$(myCreateButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.create")); + mySimplePanel.add(myCreateButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseLibraryRadioButton = new JRadioButton(); + myUseLibraryRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myUseLibraryRadioButton, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "radio.button.use.library")); + panel2.add(myUseLibraryRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseLibraryLabel = new JLabel(); + this.$$$loadLabelText$$$(myUseLibraryLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.use.library")); + myUseLibraryLabel.setVisible(true); + panel2.add(myUseLibraryLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myConfigurationPanel = new JPanel(); + myConfigurationPanel.setLayout(new CardLayout(0, 0)); + myPanel.add(myConfigurationPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(10, 0, 0, 0), -1, -1)); + myConfigurationPanel.add(panel3, "configure"); + myConfigureButton = new JButton(); + this.$$$loadButtonText$$$(myConfigureButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.configure")); + panel3.add(myConfigureButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new CardLayout(0, 0)); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myMessageLabel = new JBLabel(); + myMessageLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myMessageLabel.setEnabled(true); + myMessageLabel.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(myMessageLabel, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.library.will.be.created.description.text")); + panel4.add(myMessageLabel, "message"); + myHiddenLabel = new JLabel(); + this.$$$loadLabelText$$$(myHiddenLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.label")); + panel4.add(myHiddenLabel, "hidden"); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myConfigurationPanel.add(panel5, "empty"); + myUseFromProviderRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUseFromProviderRadioButton, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "radio.button.use.library.from.0")); + myPanel.add(myUseFromProviderRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel6, "loading"); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.loading.versions")); + panel6.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel6.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myButtonGroup = new ButtonGroup(); + myButtonGroup.add(myUseLibraryRadioButton); + myButtonGroup.add(myDownloadRadioButton); + myButtonGroup.add(myDoNotCreateRadioButton); + myButtonGroup.add(myUseFromProviderRadioButton); + } final DownloadableLibraryDescription description = getDownloadableDescription(libraryDescription); if (description != null) { showCard("loading"); @@ -137,6 +272,75 @@ public class LibraryOptionsPanel implements Disposable { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + private @Nullable String getPresentableVersion() { switch (myButtonEnumModel.getSelected()) { case DOWNLOAD -> { @@ -329,7 +533,8 @@ public class LibraryOptionsPanel implements Disposable { } public void setLibraryProvider(@Nullable FrameworkLibraryProvider provider) { - if (provider != null && !ContainerUtil.intersects(provider.getAvailableLibraryKinds(), myLibraryDescription.getSuitableLibraryKinds())) { + if (provider != null && + !ContainerUtil.intersects(provider.getAvailableLibraryKinds(), myLibraryDescription.getSuitableLibraryKinds())) { provider = null; } @@ -358,7 +563,8 @@ public class LibraryOptionsPanel implements Disposable { ? myLibraryDescription.createNewLibraryWithDefaultSettings(getBaseDirectory()) : myLibraryDescription.createNewLibrary(myCreateButton, getBaseDirectory()); if (libraryConfiguration != null) { - final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties()); + final NewLibraryEditor libraryEditor = + new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties()); libraryEditor.setName(myLibrariesContainer.suggestUniqueLibraryName(libraryConfiguration.getDefaultLibraryName())); libraryConfiguration.addRoots(libraryEditor); if (myLibraryComboBoxModel.get(0) == null) { @@ -375,7 +581,9 @@ public class LibraryOptionsPanel implements Disposable { for (Library library : myLibrariesContainer.getAllLibraries()) { if (myLibraryDescription instanceof OldCustomLibraryDescription && ((OldCustomLibraryDescription)myLibraryDescription).isSuitableLibrary(library, myLibrariesContainer) - || LibraryPresentationManager.getInstance().isLibraryOfKind(library, myLibrariesContainer, myLibraryDescription.getSuitableLibraryKinds())) { + || + LibraryPresentationManager.getInstance() + .isLibraryOfKind(library, myLibrariesContainer, myLibraryDescription.getSuitableLibraryKinds())) { suitableLibraries.add(library); } } @@ -451,7 +659,7 @@ public class LibraryOptionsPanel implements Disposable { } else { myHiddenLabel.setText(JavaUiBundle.message("label.library.will.be.created.description.text", mySettings.getNewLibraryLevel(), - "name", 10)); + "name", 10)); } ((CardLayout)myConfigurationPanel.getLayout()).show(myConfigurationPanel, showConfigurePanel ? "configure" : "empty"); myMessageLabel.setText(XmlStringUtil.wrapInHtml(message)); diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java index b5fc22eb8668..92e98771d8e7 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java @@ -29,19 +29,26 @@ import com.intellij.ui.DocumentAdapter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ResourceBundle; public class ModuleNameLocationComponent implements ModuleNameLocationSettings { private final WizardContext myWizardContext; - private JTextField myModuleName; - private TextFieldWithBrowseButton myModuleContentRoot; - private TextFieldWithBrowseButton myModuleFileLocation; - private JPanel myModulePanel; + private final JTextField myModuleName; + private final TextFieldWithBrowseButton myModuleContentRoot; + private final TextFieldWithBrowseButton myModuleFileLocation; + private final JPanel myModulePanel; private boolean myModuleNameChangedByUser = false; private boolean myModuleNameDocListenerEnabled = true; @@ -57,8 +64,118 @@ public class ModuleNameLocationComponent implements ModuleNameLocationSettings { public ModuleNameLocationComponent(@NotNull WizardContext wizardContext) { myWizardContext = wizardContext; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myModulePanel = new JPanel(); + myModulePanel.setLayout(new GridBagLayout()); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "project.new.wizard.module.name.title")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + myModulePanel.add(label1, gbc); + myModuleName = new JTextField(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(0, 0, 5, 0); + myModulePanel.add(myModuleName, gbc); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "project.new.wizard.module.root.title")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + myModulePanel.add(label2, gbc); + myModuleContentRoot = new TextFieldWithBrowseButton(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 1; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(0, 0, 5, 0); + myModulePanel.add(myModuleContentRoot, gbc); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "project.new.wizard.module.file.title")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + myModulePanel.add(label3, gbc); + myModuleFileLocation = new TextFieldWithBrowseButton(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 2; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(0, 0, 5, 0); + myModulePanel.add(myModuleFileLocation, gbc); + label1.setLabelFor(myModuleName); + label2.setLabelFor(myModuleContentRoot); + label3.setLabelFor(myModuleFileLocation); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myModulePanel; } + public @Nullable AbstractModuleBuilder getModuleBuilder() { return ((AbstractModuleBuilder)myWizardContext.getProjectBuilder()); } @@ -214,8 +331,9 @@ public class ModuleNameLocationComponent implements ModuleNameLocationSettings { final String moduleName = getModuleName(); final Module module; final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project); - ModifiableModuleModel modifiableModel = fromConfigurable != null ? fromConfigurable.getContext().getModulesConfigurator().getModuleModel() - : null; + ModifiableModuleModel modifiableModel = + fromConfigurable != null ? fromConfigurable.getContext().getModulesConfigurator().getModuleModel() + : null; if (modifiableModel != null) { module = modifiableModel.findModuleByName(moduleName); } diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSettingsStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSettingsStep.java index 68b17d78b16a..d76d29c46834 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSettingsStep.java @@ -19,37 +19,44 @@ import com.intellij.projectImport.ProjectFormatPanel; import com.intellij.ui.HideableDecorator; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; +import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; /** * @author Dmitry Avdeev */ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsStep { - private JPanel mySettingsPanel; + private final JPanel mySettingsPanel; - private JPanel myExpertPlaceholder; - private JPanel myExpertPanel; + private final JPanel myExpertPlaceholder; + private final JPanel myExpertPanel; private final HideableDecorator myExpertDecorator; private final NamePathComponent myNamePathComponent; private final ProjectFormatPanel myFormatPanel; - private JPanel myPanel; - private ModuleNameLocationComponent myModuleNameLocationComponent; + private final JPanel myPanel; + private final ModuleNameLocationComponent myModuleNameLocationComponent; private final WizardContext myWizardContext; private @Nullable ModuleWizardStep mySettingsStep; @@ -57,6 +64,48 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte public ProjectSettingsStep(WizardContext context) { myWizardContext = context; + { + myModuleNameLocationComponent = new ModuleNameLocationComponent(myWizardContext); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myExpertPlaceholder = new JPanel(); + myExpertPlaceholder.setLayout(new BorderLayout(0, 0)); + panel1.add(myExpertPlaceholder, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myExpertPanel = new JPanel(); + myExpertPanel.setLayout(new GridBagLayout()); + myExpertPlaceholder.add(myExpertPanel, BorderLayout.CENTER); + mySettingsPanel = new JPanel(); + mySettingsPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(mySettingsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mySettingsPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + panel1.add(myModuleNameLocationComponent.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + } myFormatPanel = new ProjectFormatPanel(); myNamePathComponent = NamePathComponent.initNamePathComponent(context); @@ -82,6 +131,9 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte } } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + JPanel getExpertPlaceholder() { return myExpertPlaceholder; } @@ -91,7 +143,9 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte } private JTextField getNameComponent() { - return myWizardContext.isCreatingNewProject() ? myNamePathComponent.getNameComponent() : myModuleNameLocationComponent.getModuleNameField(); + return myWizardContext.isCreatingNewProject() + ? myNamePathComponent.getNameComponent() + : myModuleNameLocationComponent.getModuleNameField(); } private void addProjectFormat(JPanel panel) { @@ -258,10 +312,6 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte return null; } - private void createUIComponents() { - myModuleNameLocationComponent = new ModuleNameLocationComponent(myWizardContext); - } - public void setModuleName(String moduleName) { myModuleNameLocationComponent.setModuleName(moduleName); } diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java index 6ff45c7d4366..73879b16972a 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java @@ -14,7 +14,11 @@ import com.intellij.platform.ProjectTemplate; import com.intellij.platform.templates.ArchivedProjectTemplate; import com.intellij.ui.CollectionListModel; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.popup.list.GroupedItemsListRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -23,12 +27,15 @@ import org.jetbrains.annotations.TestOnly; import org.jetbrains.annotations.Unmodifiable; import javax.swing.Icon; +import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JTextPane; import javax.swing.ListModel; import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.util.List; /** @@ -38,12 +45,36 @@ public class ProjectTemplateList extends JPanel { private static final String PROJECT_WIZARD_TEMPLATE = "project.wizard.template"; - private JBList myList; - private JPanel myPanel; - private JTextPane myDescriptionPane; + private final JBList myList; + private final JPanel myPanel; + private final JTextPane myDescriptionPane; public ProjectTemplateList() { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, BorderLayout.CENTER); + myList = new JBList(); + myList.setSelectionMode(0); + jBScrollPane1.setViewportView(myList); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, BorderLayout.SOUTH); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + panel1.add(jBScrollPane2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(500, 100), null, 0, false)); + myDescriptionPane = new JTextPane(); + jBScrollPane2.setViewportView(myDescriptionPane); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 3), null, 0, false)); + } add(myPanel, BorderLayout.CENTER); GroupedItemsListRenderer renderer = new GroupedItemsListRenderer<>(new ListItemDescriptorAdapter() { @@ -77,6 +108,9 @@ public class ProjectTemplateList extends JPanel { } } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateSelection() { final ProjectTemplate template = getSelectedTemplate(); if (template == null || StringUtil.isEmpty(template.getDescription())) { @@ -89,14 +123,15 @@ public class ProjectTemplateList extends JPanel { HtmlChunk.Element fontTag = HtmlChunk.tag("font").addRaw(description); if (!SystemInfo.isMac) { fontTag = fontTag.attr("face", "Verdana") - .attr("size","-1"); + .attr("size", "-1"); } final HtmlChunk.Element descriptionHtml = new HtmlBuilder().append(fontTag).wrapWithHtmlBody(); myDescriptionPane.setText(descriptionHtml.toString()); } public void setTemplates(@Unmodifiable List list, boolean preserveSelection) { - list = ContainerUtil.sorted(list, (o1, o2) -> Boolean.compare(o1 instanceof ArchivedProjectTemplate, o2 instanceof ArchivedProjectTemplate)); + list = + ContainerUtil.sorted(list, (o1, o2) -> Boolean.compare(o1 instanceof ArchivedProjectTemplate, o2 instanceof ArchivedProjectTemplate)); int index = preserveSelection ? myList.getSelectedIndex() : -1; myList.setModel(new CollectionListModel<>(list)); diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java index c304a6a3aa7b..8dbef80334eb 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java @@ -77,12 +77,18 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -96,6 +102,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; @@ -122,14 +129,14 @@ public final class ProjectTypeStep extends ModuleWizardStep implements SettingsS private final Map myBuilders = FactoryMap.create(key -> (ModuleBuilder)key.createModuleBuilder()); private final MultiMap myTemplatesMap; private final Map myCustomSteps = new HashMap<>(); - private JPanel myPanel; - private JPanel myOptionsPanel; - private ProjectTemplateList myTemplatesList; - private JPanel myFrameworksPanelPlaceholder; - private JPanel myHeaderPanel; - private JBLabel myFrameworksLabel; - private JPanel mySettingsPanel; - private JPanel myProjectTypePanel; + private final JPanel myPanel; + private final JPanel myOptionsPanel; + private final ProjectTemplateList myTemplatesList; + private final JPanel myFrameworksPanelPlaceholder; + private final JPanel myHeaderPanel; + private final JBLabel myFrameworksLabel; + private final JPanel mySettingsPanel; + private final JPanel myProjectTypePanel; private @Nullable ModuleWizardStep mySettingsStep; private String myCurrentCard; @@ -137,6 +144,47 @@ public final class ProjectTypeStep extends ModuleWizardStep implements SettingsS public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) { myContext = context; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + mySettingsPanel = new JPanel(); + mySettingsPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(mySettingsPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myHeaderPanel = new JPanel(); + myHeaderPanel.setLayout(new GridBagLayout()); + mySettingsPanel.add(myHeaderPanel, BorderLayout.NORTH); + myHeaderPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new CardLayout(0, 0)); + myOptionsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + mySettingsPanel.add(myOptionsPanel, BorderLayout.CENTER); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new BorderLayout(0, 0)); + myOptionsPanel.add(panel1, "templates card"); + myTemplatesList = new ProjectTemplateList(); + panel1.add(myTemplatesList.$$$getRootComponent$$$(), BorderLayout.CENTER); + myFrameworksPanelPlaceholder = new JPanel(); + myFrameworksPanelPlaceholder.setLayout(new BorderLayout(0, 0)); + myOptionsPanel.add(myFrameworksPanelPlaceholder, "frameworks card"); + myFrameworksLabel = new JBLabel(); + this.$$$loadLabelText$$$(myFrameworksLabel, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.additional.libraries.and.frameworks")); + myFrameworksPanelPlaceholder.add(myFrameworksLabel, BorderLayout.NORTH); + myProjectTypePanel = new JPanel(); + myProjectTypePanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myProjectTypePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myContext.addContextListener(new WizardContext.Listener() { @Override public void switchToRequested(@NotNull String placeId, @NotNull Consumer configure) { @@ -248,6 +296,53 @@ public final class ProjectTypeStep extends ModuleWizardStep implements SettingsS myTemplatesList.restoreSelection(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void initStepListener(Collection steps) { myWizard.setStepListener(steps); } @@ -381,7 +476,10 @@ public final class ProjectTypeStep extends ModuleWizardStep implements SettingsS for (ListIterator iterator = groups.listIterator(); iterator.hasNext(); ) { TemplatesGroup group = iterator.next(); String parentGroup = group.getParentGroup(); - if (parentGroup != null && groupNames.contains(parentGroup) && !group.getName().equals(parentGroup) && groupMap.containsKey(parentGroup)) { + if (parentGroup != null && + groupNames.contains(parentGroup) && + !group.getName().equals(parentGroup) && + groupMap.containsKey(parentGroup)) { subGroups.putValue(parentGroup, group); iterator.remove(); } diff --git a/java/idea-ui/src/com/intellij/ide/util/importProject/FrameworkDetectionStep.java b/java/idea-ui/src/com/intellij/ide/util/importProject/FrameworkDetectionStep.java index b2bec24b4f26..2404d9f99b35 100644 --- a/java/idea-ui/src/com/intellij/ide/util/importProject/FrameworkDetectionStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/importProject/FrameworkDetectionStep.java @@ -24,28 +24,49 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.io.File; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; public abstract class FrameworkDetectionStep extends AbstractStepWithProgress> implements ProjectFromSourcesBuilderImpl.ProjectConfigurationUpdater { private final Icon myIcon; private List myLastRoots; private final DetectedFrameworksComponent myDetectedFrameworksComponent; - private JPanel myMainPanel; - private JPanel myFrameworksPanel; - private JLabel myFrameworksDetectedLabel; + private final JPanel myMainPanel; + private final JPanel myFrameworksPanel; + private final JLabel myFrameworksDetectedLabel; private final FrameworkDetectionContext myContext; protected FrameworkDetectionStep(final Icon icon, final ProjectFromSourcesBuilder builder) { super(JavaUiBundle.message("message.text.stop.searching.for.frameworks", ApplicationNamesInfo.getInstance().getProductName())); myIcon = icon; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new BorderLayout(0, 5)); + myMainPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myFrameworksDetectedLabel = new JLabel(); + this.$$$loadLabelText$$$(myFrameworksDetectedLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", + "label.text.the.following.frameworks.are.detected")); + myMainPanel.add(myFrameworksDetectedLabel, BorderLayout.NORTH); + myFrameworksPanel = new JPanel(); + myFrameworksPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myFrameworksPanel, BorderLayout.CENTER); + } myContext = new FrameworkDetectionInWizardContext() { @Override protected List getModuleDescriptors() { @@ -60,6 +81,53 @@ public abstract class FrameworkDetectionStep extends AbstractStepWithProgress

  • thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public void updateDataModel() { } @@ -134,7 +202,9 @@ public abstract class FrameworkDetectionStep extends AbstractStepWithProgress
  • myProviders; private List> myRoots; @@ -84,6 +93,28 @@ public class AddSupportForFrameworksPanel implements Disposable { final FrameworkSupportModelBase model, boolean vertical, @Nullable JPanel associatedFrameworksPanel) { myModel = model; myAssociatedFrameworksPanel = associatedFrameworksPanel; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myLabel = new JLabel(); + myLabel.setEnabled(true); + Font myLabelFont = this.$$$getFont$$$(null, -1, -1, myLabel.getFont()); + if (myLabelFont != null) myLabel.setFont(myLabelFont); + this.$$$loadLabelText$$$(myLabel, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.text.please.select.desired.technologies")); + myMainPanel.add(myLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFrameworksPanel = new JPanel(); + myFrameworksPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myFrameworksPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myLibrariesContainer = model.getLibrariesContainer(); myLabel.setVisible(!vertical); @@ -133,6 +164,77 @@ public class AddSupportForFrameworksPanel implements Disposable { setProviders(providers); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public void setProviders(List providers) { setProviders(providers, Collections.emptySet(), Collections.emptySet()); } @@ -176,7 +278,7 @@ public class AddSupportForFrameworksPanel implements Disposable { GridBagConstraints.HORIZONTAL, JBInsets.emptyInsets(), 0, 0)); } - protected void onFrameworkStateChanged() {} + protected void onFrameworkStateChanged() { } private void onSelectionChanged() { if (!myFrameworksTree.isProcessingMouseEventOnCheckbox()) { @@ -197,7 +299,8 @@ public class AddSupportForFrameworksPanel implements Disposable { private void applyLibraryOptionsForSelected() { if (myLastSelectedNode instanceof FrameworkSupportNode) { - final FrameworkSupportOptionsComponent optionsComponent = myInitializedOptionsComponents.get((FrameworkSupportNode)myLastSelectedNode); + final FrameworkSupportOptionsComponent optionsComponent = + myInitializedOptionsComponents.get((FrameworkSupportNode)myLastSelectedNode); if (optionsComponent != null) { final LibraryOptionsPanel optionsPanel = optionsComponent.getLibraryOptionsPanel(); if (optionsPanel != null) { @@ -230,7 +333,8 @@ public class AddSupportForFrameworksPanel implements Disposable { JPanel panel = myInitializedGroupPanels.get(group); if (panel == null) { FrameworkVersionComponent component = new FrameworkVersionComponent(myModel, group.getId(), group.getGroupVersions(), - JavaUiBundle.message("add.framework.support.label.version", group.getPresentableName())); + JavaUiBundle.message("add.framework.support.label.version", + group.getPresentableName())); panel = component.getMainPanel(); myInitializedGroupPanels.put(group, panel); if (addToOptions) { @@ -293,8 +397,8 @@ public class AddSupportForFrameworksPanel implements Disposable { } private Collection> createNodes(List providers, - Set associated, - final Collection preselected) { + Set associated, + final Collection preselected) { Map nodes = new HashMap<>(); Map, FrameworkGroupNode> groups = new HashMap<>(); List> roots = new ArrayList<>(); @@ -380,7 +484,8 @@ public class AddSupportForFrameworksPanel implements Disposable { return list; } - private static void addChildFrameworks(final List> list, final List result) { + private static void addChildFrameworks(final List> list, + final List result) { for (FrameworkSupportNodeBase node : list) { if (node.isChecked() || node instanceof FrameworkGroupNode) { if (node instanceof FrameworkSupportNode) { @@ -419,7 +524,8 @@ public class AddSupportForFrameworksPanel implements Disposable { if (!frameworksWithoutRequiredLibraries.isEmpty()) { String frameworksText = StringUtil.join(frameworksWithoutRequiredLibraries, ", "); - Messages.showErrorDialog(myMainPanel, JavaUiBundle.message("error.message.required.library.is.not.configured", frameworksText, frameworksWithoutRequiredLibraries.size()), + Messages.showErrorDialog(myMainPanel, JavaUiBundle.message("error.message.required.library.is.not.configured", frameworksText, + frameworksWithoutRequiredLibraries.size()), JavaUiBundle.message("error.title.required.library.is.not.configured")); return false; } @@ -439,8 +545,9 @@ public class AddSupportForFrameworksPanel implements Disposable { final LibraryCompositionSettings settings = getLibraryCompositionSettings(node); Library library = settings != null ? settings.addLibraries(rootModel, addedLibraries, myLibrariesContainer) : null; if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) { - ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper)configurable).getConfigurable().addSupport(module, rootModel, - library); + ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper)configurable).getConfigurable() + .addSupport(module, rootModel, + library); } else { configurable.addSupport(module, rootModel, modifiableModelsProvider); @@ -461,8 +568,8 @@ public class AddSupportForFrameworksPanel implements Disposable { } private @Unmodifiable List sortFrameworks(@Unmodifiable List nodes) { - final Comparator comparator = FrameworkSupportUtil.getFrameworkSupportProvidersComparator(myProviders); + final Comparator comparator = + FrameworkSupportUtil.getFrameworkSupportProvidersComparator(myProviders); return ContainerUtil.sorted(nodes, (o1, o2) -> comparator.compare(o1.getUserObject(), o2.getUserObject())); } - } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java index 45afbfcde855..0b98764c7fd6 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java @@ -15,15 +15,22 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import javax.swing.AbstractButton; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; import java.util.Collections; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -33,13 +40,34 @@ public class JavaSettingsStep extends SdkSettingsStep { private static final @NotNull @NonNls String MODULE_SOURCE_ROOT_KEY = "java.module.default.source.root"; private static final @NotNull @NonNls String DEFAULT_MODULE_SOURCE_ROOT_PATH = "src"; - private final ModuleBuilder myModuleBuilder; - private JBCheckBox myCreateSourceRoot; - private TextFieldWithBrowseButton mySourcePath; - private JPanel myPanel; + private final ModuleBuilder myModuleBuilder; + private final JBCheckBox myCreateSourceRoot; + private final TextFieldWithBrowseButton mySourcePath; + private final JPanel myPanel; - public JavaSettingsStep(@NotNull SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder, @NotNull Condition sdkFilter) { + public JavaSettingsStep(@NotNull SettingsStep settingsStep, + @NotNull ModuleBuilder moduleBuilder, + @NotNull Condition sdkFilter) { super(settingsStep, moduleBuilder, sdkFilter); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + mySourcePath = new TextFieldWithBrowseButton(); + mySourcePath.setText(""); + myPanel.add(mySourcePath, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myCreateSourceRoot = new JBCheckBox(); + myCreateSourceRoot.setSelected(true); + this.$$$loadButtonText$$$(myCreateSourceRoot, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.create.source.root")); + myPanel.add(myCreateSourceRoot, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } mySourcePath.setText(PropertiesComponent.getInstance().getValue(MODULE_SOURCE_ROOT_KEY, DEFAULT_MODULE_SOURCE_ROOT_PATH)); myModuleBuilder = moduleBuilder; @@ -48,6 +76,53 @@ public class JavaSettingsStep extends SdkSettingsStep { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void addSourcePath(SettingsStep settingsStep) { Project project = settingsStep.getContext().getProject(); FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java index f82eff3e0cda..d85255a26e2b 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java +++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java @@ -24,8 +24,12 @@ import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.JavaXmlDocumentKt; import com.intellij.util.ui.AsyncProcessIcon; +import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; import org.eclipse.aether.version.InvalidVersionSpecificationException; import org.eclipse.aether.version.Version; @@ -40,26 +44,31 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.text.JTextComponent; import javax.xml.parsers.DocumentBuilder; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.io.StringReader; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; public final class RepositoryAttachDialog extends DialogWrapper { private static final @NonNls String PROPERTY_DOWNLOAD_TO_PATH = "Downloaded.Files.Path"; @@ -69,23 +78,24 @@ public final class RepositoryAttachDialog extends DialogWrapper { private static final @NonNls String PROPERTY_ATTACH_ANNOTATIONS = "Repository.Attach.Annotations"; private final @NotNull Mode myMode; - public enum Mode { SEARCH, DOWNLOAD } + public enum Mode {SEARCH, DOWNLOAD} + private final Project myProject; - private JBLabel myInfoLabel; - private JCheckBox myJavaDocCheckBox; - private JCheckBox mySourcesCheckBox; - private AsyncProcessIcon myProgressIcon; - private ComboboxWithBrowseButton myComboComponent; - private JPanel myPanel; - private TextFieldWithBrowseButton myDirectoryField; - private JBCheckBox myDownloadToCheckBox; - private JBLabel myCaptionLabel; - private JPanel myDownloadOptionsPanel; - private JBCheckBox myIncludeTransitiveDepsCheckBox; - private JPanel mySearchOptionsPanel; - private JBCheckBox myIncludeTransitiveDependenciesForSearchCheckBox; - private JBCheckBox myAnnotationsCheckBox; + private final JBLabel myInfoLabel; + private final JCheckBox myJavaDocCheckBox; + private final JCheckBox mySourcesCheckBox; + private final AsyncProcessIcon myProgressIcon; + private final ComboboxWithBrowseButton myComboComponent; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myDirectoryField; + private final JBCheckBox myDownloadToCheckBox; + private final JBLabel myCaptionLabel; + private final JPanel myDownloadOptionsPanel; + private final JBCheckBox myIncludeTransitiveDepsCheckBox; + private final JPanel mySearchOptionsPanel; + private final JBCheckBox myIncludeTransitiveDependenciesForSearchCheckBox; + private final JBCheckBox myAnnotationsCheckBox; private final JComboBox myCombobox; @@ -99,6 +109,114 @@ public final class RepositoryAttachDialog extends DialogWrapper { public RepositoryAttachDialog(@NotNull Project project, final @Nullable String initialFilter, @NotNull Mode mode) { super(project, true); myMode = mode; + { + myProgressIcon = new AsyncProcessIcon("Progress"); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 15, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myComboComponent = new ComboboxWithBrowseButton(); + panel1.add(myComboComponent, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel1.add(myProgressIcon, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInfoLabel = new JBLabel(); + myInfoLabel.setComponentStyle(UIUtil.ComponentStyle.MINI); + myInfoLabel.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(myInfoLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.info")); + panel1.add(myInfoLabel, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCaptionLabel = new JBLabel(); + myCaptionLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myCaptionLabel.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(myCaptionLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.description")); + panel1.add(myCaptionLabel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myDownloadOptionsPanel = new JPanel(); + myDownloadOptionsPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myDownloadOptionsPanel, new GridConstraints(1, 0, 2, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myDirectoryField = new TextFieldWithBrowseButton(); + myDirectoryField.setText(""); + myDownloadOptionsPanel.add(myDirectoryField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1)); + myDownloadOptionsPanel.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + mySourcesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(mySourcesCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.sources")); + panel2.add(mySourcesCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJavaDocCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myJavaDocCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.javadocs")); + panel2.add(myJavaDocCheckBox, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myIncludeTransitiveDepsCheckBox = new JBCheckBox(); + myIncludeTransitiveDepsCheckBox.setSelected(true); + this.$$$loadButtonText$$$(myIncludeTransitiveDepsCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.transitive.dependencies")); + panel2.add(myIncludeTransitiveDepsCheckBox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnnotationsCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myAnnotationsCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.annotations")); + panel2.add(myAnnotationsCheckBox, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDownloadToCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myDownloadToCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.to")); + myDownloadOptionsPanel.add(myDownloadToCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + mySearchOptionsPanel = new JPanel(); + mySearchOptionsPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(mySearchOptionsPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + mySearchOptionsPanel.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myIncludeTransitiveDependenciesForSearchCheckBox = new JBCheckBox(); + myIncludeTransitiveDependenciesForSearchCheckBox.setSelected(true); + this.$$$loadButtonText$$$(myIncludeTransitiveDependenciesForSearchCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.include.transitive.dependencies")); + mySearchOptionsPanel.add(myIncludeTransitiveDependenciesForSearchCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } setTitle(mode == Mode.DOWNLOAD ? JavaUiBundle.message("dialog.title.download.library.from.maven.repository") : JavaUiBundle.message("dialog.title.search.library.in.maven.repositories")); myProject = project; @@ -181,6 +299,78 @@ public final class RepositoryAttachDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private @NlsSafe String getDownloadPath(final @NotNull PropertiesComponent storage) { final String value = storage.getValue(PROPERTY_DOWNLOAD_TO_PATH); if (Strings.isNotEmpty(value)) return value; @@ -218,11 +408,13 @@ public final class RepositoryAttachDialog extends DialogWrapper { } public boolean getIncludeTransitiveDependencies() { - return myMode == Mode.DOWNLOAD ? myIncludeTransitiveDepsCheckBox.isSelected() : myIncludeTransitiveDependenciesForSearchCheckBox.isSelected(); + return myMode == Mode.DOWNLOAD + ? myIncludeTransitiveDepsCheckBox.isSelected() + : myIncludeTransitiveDependenciesForSearchCheckBox.isSelected(); } public @Nullable String getDirectoryPath() { - return myDownloadToCheckBox.isSelected()? myDirectoryField.getText() : null; + return myDownloadToCheckBox.isSelected() ? myDirectoryField.getText() : null; } @Override @@ -241,7 +433,8 @@ public final class RepositoryAttachDialog extends DialogWrapper { myShownItems.clear(); myInUpdate = true; - final boolean itemSelected = myCoordinates.containsKey(myFilterString) && Comparing.strEqual((String)myCombobox.getSelectedItem(), myFilterString, false); + final boolean itemSelected = + myCoordinates.containsKey(myFilterString) && Comparing.strEqual((String)myCombobox.getSelectedItem(), myFilterString, false); final boolean filtered; if (itemSelected) { myShownItems.addAll(myCoordinates.keySet()); @@ -349,12 +542,14 @@ public final class RepositoryAttachDialog extends DialogWrapper { @Override protected ValidationInfo doValidate() { if (!isValidCoordinateSelected()) { - return new ValidationInfo(JavaUiBundle.message("error.message.please.enter.valid.coordinate.discover.it.or.select.one.from.the.list"), myCombobox); + return new ValidationInfo(JavaUiBundle.message("error.message.please.enter.valid.coordinate.discover.it.or.select.one.from.the.list"), + myCombobox); } else if (myDownloadToCheckBox.isSelected()) { final File dir = new File(myDirectoryField.getText()); if (!dir.exists() && !dir.mkdirs() || !dir.isDirectory()) { - return new ValidationInfo(JavaUiBundle.message("error.message.please.enter.valid.library.files.path"), myDirectoryField.getTextField()); + return new ValidationInfo(JavaUiBundle.message("error.message.please.enter.valid.library.files.path"), + myDirectoryField.getTextField()); } } return super.doValidate(); @@ -415,10 +610,6 @@ public final class RepositoryAttachDialog extends DialogWrapper { getIncludeTransitiveDependencies(), Collections.emptyList()); } - private void createUIComponents() { - myProgressIcon = new AsyncProcessIcon("Progress"); - } - private static boolean isMvnDependency(String text) { String trimmed = text.trim(); if (trimmed.startsWith("") && trimmed.endsWith("")) { diff --git a/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java index 65eac3a7df91..0adc5a66c375 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java @@ -23,7 +23,11 @@ import com.intellij.ui.CollectionListModel; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.ListUtil; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import kotlin.Unit; @@ -31,16 +35,21 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.ListSelectionModel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -50,22 +59,22 @@ import static com.intellij.jarRepository.settings.JarRepositoryLibraryBindUtils. import static com.intellij.ui.ListUtil.removeSelectedItems; public final class RemoteRepositoriesConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myMainPanel; + private final JPanel myMainPanel; - private JBList myServiceList; - private JButton myAddServiceButton; - private JButton myEditServiceButton; - private JButton myRemoveServiceButton; - private JButton myTestServiceButton; + private final JBList myServiceList; + private final JButton myAddServiceButton; + private final JButton myEditServiceButton; + private final JButton myRemoveServiceButton; + private final JButton myTestServiceButton; - private JBList myJarRepositoryList; - private JButton myAddRepoButton; - private JButton myEditRepoButton; - private JButton myRemoveRepoButton; - private JButton myResetToDefaultReposButton; - private JButton myResetToDefaultServicesButton; - private JPanel myMavenPanel; - private JPanel myServiceListPanel; + private final JBList myJarRepositoryList; + private final JButton myAddRepoButton; + private final JButton myEditRepoButton; + private final JButton myRemoveRepoButton; + private final JButton myResetToDefaultReposButton; + private final JButton myResetToDefaultServicesButton; + private final JPanel myMavenPanel; + private final JPanel myServiceListPanel; private final Project myProject; private final CollectionListModel myServicesModel = new CollectionListModel<>(); @@ -75,11 +84,160 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura public RemoteRepositoriesConfigurable(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMavenPanel = new JPanel(); + myMavenPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMavenPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myMavenPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, true)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMavenPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myJarRepositoryList = new JBList(); + jBScrollPane1.setViewportView(myJarRepositoryList); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMavenPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myAddRepoButton = new JButton(); + myAddRepoButton.setFocusable(false); + this.$$$loadButtonText$$$(myAddRepoButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.add2")); + panel1.add(myAddRepoButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEditRepoButton = new JButton(); + this.$$$loadButtonText$$$(myEditRepoButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.edit2")); + panel1.add(myEditRepoButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRemoveRepoButton = new JButton(); + this.$$$loadButtonText$$$(myRemoveRepoButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.remove2")); + panel1.add(myRemoveRepoButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myResetToDefaultReposButton = new JButton(); + this.$$$loadButtonText$$$(myResetToDefaultReposButton, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.reset.defaults")); + panel1.add(myResetToDefaultReposButton, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myServiceListPanel = new JPanel(); + myServiceListPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myServiceListPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myServiceListPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + myServiceListPanel.add(jBScrollPane2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(406, 128), null, 0, false)); + myServiceList = new JBList(); + myServiceList.setLayoutOrientation(0); + jBScrollPane2.setViewportView(myServiceList); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + myServiceListPanel.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myAddServiceButton = new JButton(); + myAddServiceButton.setFocusable(false); + this.$$$loadButtonText$$$(myAddServiceButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.add")); + panel2.add(myAddServiceButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRemoveServiceButton = new JButton(); + this.$$$loadButtonText$$$(myRemoveServiceButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.remove")); + panel2.add(myRemoveServiceButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestServiceButton = new JButton(); + this.$$$loadButtonText$$$(myTestServiceButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.test")); + panel2.add(myTestServiceButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEditServiceButton = new JButton(); + this.$$$loadButtonText$$$(myEditServiceButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.edit")); + panel2.add(myEditServiceButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myResetToDefaultServicesButton = new JButton(); + this.$$$loadButtonText$$$(myResetToDefaultServicesButton, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.reset.defaults")); + panel2.add(myResetToDefaultServicesButton, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myWorkspaceModel = WorkspaceModel.getInstance(project); resetMutableEntityStorage(); configControls(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public boolean isModified() { return isServiceListModified() || isRepoListModified() || ((MutableEntityStorageInstrumentation)myMutableEntityStorage).hasChanges(); @@ -95,7 +253,9 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura } private void configControls() { - myMavenPanel.setBorder(IdeBorderFactory.createTitledBorder(JavaUiBundle.message("settings.remote.repo.maven.jar.repositories"), false, JBUI.insetsTop(8)).setShowLine(false)); + myMavenPanel.setBorder( + IdeBorderFactory.createTitledBorder(JavaUiBundle.message("settings.remote.repo.maven.jar.repositories"), false, JBUI.insetsTop(8)) + .setShowLine(false)); myServiceListPanel.setBorder(IdeBorderFactory.createTitledBorder(JavaUiBundle.message( "settings.remote.repo.artifactory.or.nexus.service.urls"), false, JBUI.insetsTop(8)).setShowLine(false)); @@ -129,7 +289,8 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura } else { Messages.showMessageDialog(JavaUiBundle.message("settings.remote.repo.repositories.found", infos.size()), - JavaUiBundle.message("settings.remote.repo.service.connection.successful"), Messages.getInformationIcon()); + JavaUiBundle.message("settings.remote.repo.service.connection.successful"), + Messages.getInformationIcon()); } return true; }); @@ -201,8 +362,12 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura return new RemoteRepositoryDescription(current.getId(), current.getName(), url); } }; - @Nls Presentation toPresentation(Data data); + + @Nls + Presentation toPresentation(Data data); + Data create(Presentation presentation); + Data change(Data current, Presentation changes); } @@ -223,7 +388,8 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura @NonNls String defaultValue = "https://"; String initialValue = value == null ? defaultValue : adapter.toPresentation(value); final String text = Messages.showInputDialog( - modificationDialogTitle, JavaUiBundle.message("dialog.title.add.repository.0", modificationDialogHint), Messages.getQuestionIcon(), + modificationDialogTitle, JavaUiBundle.message("dialog.title.add.repository.0", modificationDialogHint), + Messages.getQuestionIcon(), initialValue, new URLInputValidator() ); if (StringUtil.isNotEmpty(text)) { @@ -238,7 +404,8 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura final int index = list.getSelectedIndex(); final T element = model.getElementAt(index); final String text = Messages.showInputDialog( - modificationDialogTitle, JavaUiBundle.message("dialog.title.edit.repository.0", modificationDialogHint), Messages.getQuestionIcon(), adapter.toPresentation(element), new URLInputValidator() + modificationDialogTitle, JavaUiBundle.message("dialog.title.edit.repository.0", modificationDialogHint), + Messages.getQuestionIcon(), adapter.toPresentation(element), new URLInputValidator() ); if (StringUtil.isNotEmpty(text)) { model.setElementAt(adapter.change(element, text), index); @@ -295,7 +462,8 @@ public final class RemoteRepositoriesConfigurable implements SearchableConfigura @Override public void apply() throws ConfigurationException { List newUrls = ContainerUtil.map(myReposModel.getItems(), RemoteRepositoryDescription::getUrl); - List oldUrls = ContainerUtil.map(RemoteRepositoriesConfiguration.getInstance(myProject).getRepositories(), RemoteRepositoryDescription::getUrl); + List oldUrls = + ContainerUtil.map(RemoteRepositoriesConfiguration.getInstance(myProject).getRepositories(), RemoteRepositoryDescription::getUrl); MavenRepositoryServicesManager.getInstance(myProject).setUrls(myServicesModel.getItems()); RemoteRepositoriesConfiguration.getInstance(myProject).setRepositories(myReposModel.getItems()); applyMutableEntityStorageChanges(); diff --git a/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.java b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.java index 4a8169c4a61c..970790cce4b9 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.java +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.java @@ -18,6 +18,9 @@ import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.components.ActionLink; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.ThreeStateCheckBox; @@ -29,19 +32,27 @@ import org.jetbrains.idea.maven.aether.ArtifactDependencyNode; import org.jetbrains.idea.maven.utils.library.RepositoryLibraryDescription; import org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel; +import javax.swing.AbstractButton; import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; public final class RepositoryLibraryPropertiesEditor { @@ -52,18 +63,18 @@ public final class RepositoryLibraryPropertiesEditor { private final RepositoryLibraryPropertiesModel initialModel; private final RepositoryLibraryPropertiesModel model; private final RepositoryLibraryDescription repositoryLibraryDescription; - private ComboBox versionSelector; - private JPanel mainPanel; - private JButton myReloadButton; - private JBCheckBox downloadSourcesCheckBox; - private JBCheckBox downloadJavaDocsCheckBox; - private JBCheckBox downloadAnnotationsCheckBox; - private JBLabel mavenCoordinates; + private final ComboBox versionSelector; + private final JPanel mainPanel; + private final JButton myReloadButton; + private final JBCheckBox downloadSourcesCheckBox; + private final JBCheckBox downloadJavaDocsCheckBox; + private final JBCheckBox downloadAnnotationsCheckBox; + private final JBLabel mavenCoordinates; private final ThreeStateCheckBox myIncludeTransitiveDepsCheckBox; - private JPanel myPropertiesPanel; - private JPanel myTransitiveDependenciesPanel; - private ComboBox myRemoteRepositoryComboBox; - private JPanel myRemoteRepositoryOptionsPanel; + private final JPanel myPropertiesPanel; + private final JPanel myTransitiveDependenciesPanel; + private final ComboBox myRemoteRepositoryComboBox; + private final JPanel myRemoteRepositoryOptionsPanel; private final @NotNull ModelChangeListener onChangeListener; private final ActionLink myManageDependenciesLink; @@ -90,12 +101,169 @@ public final class RepositoryLibraryPropertiesEditor { boolean allowExcludingTransitiveDependencies, final @NotNull ModelChangeListener onChangeListener, boolean globalLibrary) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.setMinimumSize(new Dimension(400, 128)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.maven")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mavenCoordinates = new JBLabel(); + mavenCoordinates.setOpaque(false); + mavenCoordinates.setRequestFocusEnabled(true); + mavenCoordinates.setText(""); + panel1.add(mavenCoordinates, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new CardLayout(0, 0)); + mainPanel.add(myPropertiesPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(panel2, "Loaded"); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.version")); + panel3.add(jBLabel2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + versionSelector = new ComboBox(); + panel3.add(versionSelector, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel2.add(spacer4, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel4, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + downloadSourcesCheckBox = new JBCheckBox(); + downloadSourcesCheckBox.setLabel(this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "download.sources")); + this.$$$loadButtonText$$$(downloadSourcesCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.sources")); + panel4.add(downloadSourcesCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + panel4.add(spacer5, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + downloadJavaDocsCheckBox = new JBCheckBox(); + downloadJavaDocsCheckBox.setLabel(this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "download.javadocs")); + this.$$$loadButtonText$$$(downloadJavaDocsCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.javadocs2")); + panel4.add(downloadJavaDocsCheckBox, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTransitiveDependenciesPanel = new JPanel(); + myTransitiveDependenciesPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + panel4.add(myTransitiveDependenciesPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + downloadAnnotationsCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(downloadAnnotationsCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.download.annotations")); + panel4.add(downloadAnnotationsCheckBox, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(panel5, "Loading"); + final JBLabel jBLabel3 = new JBLabel(); + jBLabel3.setInheritsPopupMenu(true); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.loading.available.versions")); + panel5.add(jBLabel3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer6 = new Spacer(); + panel5.add(spacer6, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer7 = new Spacer(); + panel5.add(spacer7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(panel6, "FailedToLoad"); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.failed.to.load.versions")); + panel6.add(jBLabel4, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer8 = new Spacer(); + panel6.add(spacer8, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myReloadButton = new JButton(); + this.$$$loadButtonText$$$(myReloadButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.reload")); + panel6.add(myReloadButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer9 = new Spacer(); + panel6.add(spacer9, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myRemoteRepositoryOptionsPanel = new JPanel(); + myRemoteRepositoryOptionsPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(myRemoteRepositoryOptionsPanel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myRemoteRepositoryComboBox = new ComboBox(); + myRemoteRepositoryOptionsPanel.add(myRemoteRepositoryComboBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + jBLabel5.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel5.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(jBLabel5, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.bind.remote.repository")); + myRemoteRepositoryOptionsPanel.add(jBLabel5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + jBLabel3.setLabelFor(versionSelector); + jBLabel5.setLabelFor(myRemoteRepositoryComboBox); + } this.initialModel = model.clone(); this.model = model; this.project = project == null ? ProjectManager.getInstance().getDefaultProject() : project; repositoryLibraryDescription = description; mavenCoordinates.setCopyable(true); - myIncludeTransitiveDepsCheckBox = new ThreeStateCheckBox(UIUtil.replaceMnemonicAmpersand(JavaUiBundle.message("repository.library.properties.include.transitive.dependencies"))); + myIncludeTransitiveDepsCheckBox = new ThreeStateCheckBox( + UIUtil.replaceMnemonicAmpersand(JavaUiBundle.message("repository.library.properties.include.transitive.dependencies"))); myIncludeTransitiveDepsCheckBox.setThirdStateEnabled(false); myTransitiveDependenciesPanel.add(myIncludeTransitiveDepsCheckBox); myManageDependenciesLink = new ActionLink(CommonBundle.message("action.text.configure.ellipsis"), e -> { @@ -107,7 +275,8 @@ public final class RepositoryLibraryPropertiesEditor { if (globalLibrary) { myRemoteRepositoryOptionsPanel.setVisible(false); - } else { + } + else { RepositoryLibrarySettings intSettings = RepositoryLibrarySettings.getInstanceOrDefaults(project); myRemoteRepositoryOptionsPanel.setVisible(intSettings.isBindJarRepositoryUiSettingsDisplayed()); } @@ -141,6 +310,78 @@ public final class RepositoryLibraryPropertiesEditor { reloadVersionsAsync(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + private void configureTransitiveDependencies() { String selectedVersion = getSelectedVersion(); LOG.assertTrue(selectedVersion != null); @@ -246,7 +487,9 @@ public final class RepositoryLibraryPropertiesEditor { private void updateIncludeTransitiveDepsCheckBoxState() { myIncludeTransitiveDepsCheckBox.setState(!model.isIncludeTransitiveDependencies() ? ThreeStateCheckBox.State.NOT_SELECTED : - model.getExcludedDependencies().isEmpty() ? ThreeStateCheckBox.State.SELECTED : ThreeStateCheckBox.State.DONT_CARE); + model.getExcludedDependencies().isEmpty() + ? ThreeStateCheckBox.State.SELECTED + : ThreeStateCheckBox.State.DONT_CARE); } private void updateManageDependenciesLink() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java index 7e5743db662f..22e8e5dc5f1f 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java @@ -67,6 +67,9 @@ import com.intellij.ui.TabbedPaneWrapper; import com.intellij.ui.UIBundle; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.border.CustomLineBorder; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import com.intellij.util.IconUtil; import com.intellij.util.ui.JBUI; @@ -76,6 +79,7 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -89,22 +93,25 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.HyperlinkEvent; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public class ArtifactEditorImpl implements ArtifactEditorEx { - private JPanel myPanel; - private JCheckBox myBuildOnMakeCheckBox; - private TextFieldWithBrowseButton myOutputDirectoryField; - private JPanel myEditorPanel; - private JPanel myErrorPanelPlace; - private ThreeStateCheckBox myShowContentCheckBox; - private FixedSizeButton myShowSpecificContentOptionsButton; - private JPanel myTopPanel; + private final JPanel myPanel; + private final JCheckBox myBuildOnMakeCheckBox; + private final TextFieldWithBrowseButton myOutputDirectoryField; + private final JPanel myEditorPanel; + private final JPanel myErrorPanelPlace; + private final ThreeStateCheckBox myShowContentCheckBox; + private final FixedSizeButton myShowSpecificContentOptionsButton; + private final JPanel myTopPanel; private final ActionGroup myShowSpecificContentOptionsGroup; private final Project myProject; private final ComplexElementSubstitutionParameters mySubstitutionParameters = new ComplexElementSubstitutionParameters(); @@ -120,14 +127,86 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { private final JComponent myMainComponent; - public ArtifactEditorImpl(final @NotNull ArtifactsStructureConfigurableContext context, @NotNull Artifact artifact, @NotNull ArtifactEditorSettings settings) { + public ArtifactEditorImpl(final @NotNull ArtifactsStructureConfigurableContext context, + @NotNull Artifact artifact, + @NotNull ArtifactEditorSettings settings) { + { + myShowContentCheckBox = new ThreeStateCheckBox(); + myShowSpecificContentOptionsButton = new FixedSizeButton(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myTopPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.text.output.directory")); + myTopPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myOutputDirectoryField = new TextFieldWithBrowseButton(); + myTopPanel.add(myOutputDirectoryField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myBuildOnMakeCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myBuildOnMakeCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.text.build.on.make")); + panel1.add(myBuildOnMakeCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + myEditorPanel.setEnabled(true); + myPanel.add(myEditorPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myErrorPanelPlace = new JPanel(); + myErrorPanelPlace.setLayout(new BorderLayout(0, 0)); + myPanel.add(myErrorPanelPlace, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, + null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + this.$$$loadButtonText$$$(myShowContentCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.show.content.of.elements")); + panel2.add(myShowContentCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(myShowSpecificContentOptionsButton, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } myContext = createArtifactEditorContext(context); myOriginalArtifact = artifact; myProject = context.getProject(); myValidationManager = new ArtifactValidationManagerImpl(this); mySubstitutionParameters.setTypesToShowContent(settings.getTypesToShowContent()); mySourceItemsTree = new SourceItemsTree(myContext, this); - myLayoutTreeComponent = new LayoutTreeComponent(this, mySubstitutionParameters, myContext, myOriginalArtifact, settings.isSortElements()); + myLayoutTreeComponent = + new LayoutTreeComponent(this, mySubstitutionParameters, myContext, myOriginalArtifact, settings.isSortElements()); myPropertiesEditors = new ArtifactPropertiesEditors(myContext, myOriginalArtifact, myOriginalArtifact); Disposer.register(this, mySourceItemsTree); Disposer.register(this, myLayoutTreeComponent); @@ -148,7 +227,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { myShowSpecificContentOptionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ActionManager.getInstance().createActionPopupMenu("ArtifactEditor", myShowSpecificContentOptionsGroup).getComponent().show(myShowSpecificContentOptionsButton, 0, 0); + ActionManager.getInstance().createActionPopupMenu("ArtifactEditor", myShowSpecificContentOptionsGroup).getComponent() + .show(myShowSpecificContentOptionsButton, 0, 0); } }); myMainComponent = UiDataProvider.wrapComponent(myPanel, sink -> { @@ -158,6 +238,78 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { updateShowContentCheckbox(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + protected ArtifactEditorContextImpl createArtifactEditorContext(ArtifactsStructureConfigurableContext parentContext) { return new ArtifactEditorContextImpl(parentContext, this); } @@ -175,7 +327,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { } public void apply() { - final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact); + final ModifiableArtifact modifiableArtifact = + myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact); modifiableArtifact.setBuildOnMake(myBuildOnMakeCheckBox.isSelected()); modifiableArtifact.setOutputPath(getConfiguredOutputPath()); myPropertiesEditors.applyProperties(); @@ -237,7 +390,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { JPanel treePanel = myLayoutTreeComponent.getTreePanel(); if (StartupUiUtil.isUnderDarcula()) { treePanel.setBorder(JBUI.Borders.emptyTop(3)); - } else { + } + else { treePanel.setBorder(new LineBorder(JBColor.border())); } leftPanel.add(treePanel, BorderLayout.CENTER); @@ -245,7 +399,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { CompoundBorder border = new CompoundBorder(new CustomLineBorder(0, 0, 0, 1), JBUI.Borders.empty()); leftPanel.setBorder(border); - } else { + } + else { leftPanel.setBorder(JBUI.Borders.empty(3, 3, 3, 0)); } splitter.setFirstComponent(leftPanel); @@ -265,7 +420,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { label.setBorder(HintUtil.createHintBorder()); label.setBackground(HintUtil.getInformationColor()); label.setOpaque(true); - HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); + HintManager.getInstance() + .showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); } }); labelPanel.add(link); @@ -276,14 +432,16 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { scrollPaneWrap.add(scrollPane, BorderLayout.CENTER); if (StartupUiUtil.isUnderDarcula()) { scrollPaneWrap.setBorder(JBUI.Borders.emptyTop(3)); - } else { + } + else { scrollPaneWrap.setBorder(new LineBorder(JBColor.border())); } rightPanel.add(scrollPaneWrap, BorderLayout.CENTER); if (StartupUiUtil.isUnderDarcula()) { rightPanel.setBorder(new CompoundBorder(new CustomLineBorder(0, 1, 0, 0), JBUI.Borders.empty())); - } else { + } + else { rightPanel.setBorder(JBUI.Borders.empty(3, 0, 3, 3)); } splitter.setSecondComponent(rightPanel); @@ -310,7 +468,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { } }); - ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("ProjectStructureArtifactEditor", createToolbarActionGroup(), true); + ActionToolbar toolbar = + ActionManager.getInstance().createActionToolbar("ProjectStructureArtifactEditor", createToolbarActionGroup(), true); JComponent toolbarComponent = toolbar.getComponent(); toolbar.setTargetComponent(treePanel); if (StartupUiUtil.isUnderDarcula()) { @@ -367,8 +526,10 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { toolbarActionGroup.add(new RemovePackagingElementAction(this)); toolbarActionGroup.add(Separator.getInstance()); toolbarActionGroup.add(new SortElementsToggleAction(this.getLayoutTreeComponent())); - toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, UIBundle.message("move.up.action.name"), "", IconUtil.getMoveUpIcon(), -1)); - toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, UIBundle.message("move.down.action.name"), "", IconUtil.getMoveDownIcon(), 1)); + toolbarActionGroup.add( + new MovePackagingElementAction(myLayoutTreeComponent, UIBundle.message("move.up.action.name"), "", IconUtil.getMoveUpIcon(), -1)); + toolbarActionGroup.add( + new MovePackagingElementAction(myLayoutTreeComponent, UIBundle.message("move.down.action.name"), "", IconUtil.getMoveDownIcon(), 1)); return toolbarActionGroup; } @@ -451,7 +612,9 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { doReplaceElement(pathToParent, element, replacement); } - private void doReplaceElement(final @NotNull String pathToParent, final @NotNull PackagingElement element, final @Nullable PackagingElement replacement) { + private void doReplaceElement(final @NotNull String pathToParent, + final @NotNull PackagingElement element, + final @Nullable PackagingElement replacement) { myLayoutTreeComponent.editLayout(() -> { final CompositePackagingElement parent = findCompositeElementByPath(pathToParent); if (parent == null) return; @@ -479,9 +642,9 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { public boolean isModified() { return myBuildOnMakeCheckBox.isSelected() != myOriginalArtifact.isBuildOnMake() - || !Objects.equals(getConfiguredOutputPath(), myOriginalArtifact.getOutputPath()) - || myPropertiesEditors.isModified() - || myLayoutTreeComponent.isPropertiesModified(); + || !Objects.equals(getConfiguredOutputPath(), myOriginalArtifact.getOutputPath()) + || myPropertiesEditors.isModified() + || myLayoutTreeComponent.isPropertiesModified(); } @Override @@ -513,7 +676,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { final String extension = FileUtilRt.getExtension(name); if (fileName.equals(oldFileName) && !extension.isEmpty()) { myLayoutTreeComponent.editLayout( - () -> ((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension)); + () -> ((ArchivePackagingElement)getRootElement()).setArchiveFileName( + ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension)); myLayoutTreeComponent.updateRootNode(); } } @@ -556,7 +720,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { } public void setArtifactType(ArtifactType artifactType) { - final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact); + final ModifiableArtifact modifiableArtifact = + myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact); modifiableArtifact.setArtifactType(artifactType); myPropertiesEditors.removeTabs(myTabbedPane); @@ -573,11 +738,6 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { return myValidationManager; } - private void createUIComponents() { - myShowContentCheckBox = new ThreeStateCheckBox(); - myShowSpecificContentOptionsButton = new FixedSizeButton(); - } - public String getHelpTopic() { final int tab = myTabbedPane.getSelectedIndex(); if (tab == 0) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/InvalidArtifactConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/InvalidArtifactConfigurable.java index e9918959f2bc..62b9d41cd9dd 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/InvalidArtifactConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/InvalidArtifactConfigurable.java @@ -6,10 +6,16 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.ui.ex.MultiLineLabel; import com.intellij.openapi.util.NlsContexts; import com.intellij.packaging.impl.artifacts.InvalidArtifact; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class InvalidArtifactConfigurable extends ArtifactConfigurableBase { private final @NlsContexts.Label String myErrorMessage; @@ -45,13 +51,87 @@ public class InvalidArtifactConfigurable extends ArtifactConfigurableBase { } private static final class InvalidArtifactComponent { - private JPanel myMainPanel; - private MultiLineLabel myDescriptionLabel; - private JLabel myIconLabel; + private final JPanel myMainPanel; + private final MultiLineLabel myDescriptionLabel; + private final JLabel myIconLabel; private InvalidArtifactComponent(@NlsContexts.Label String errorMessage) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.cannot.load.artifact")); + myMainPanel.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myIconLabel = new JLabel(); + myIconLabel.setText(""); + myMainPanel.add(myIconLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + myDescriptionLabel = new MultiLineLabel(); + myMainPanel.add(myDescriptionLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myIconLabel.setIcon(AllIcons.General.BalloonError); myDescriptionLabel.setText(errorMessage); } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java index d89a8a10ddb8..e06ba074dd1a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java @@ -12,23 +12,61 @@ import com.intellij.packaging.impl.artifacts.PlainArtifactType; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ExtractArtifactDialog extends DialogWrapper implements IExtractArtifactDialog { - private JPanel myMainPanel; - private JTextField myNameField; - private JComboBox myTypeBox; + private final JPanel myMainPanel; + private final JTextField myNameField; + private final JComboBox myTypeBox; private final ArtifactEditorContext myContext; public ExtractArtifactDialog(ArtifactEditorContext context, LayoutTreeComponent treeComponent, String initialName) { super(treeComponent.getLayoutTree(), true); myContext = context; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.text.specify.artifact.name")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myNameField = new JTextField(); + myMainPanel.add(myNameField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 1, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.select.artifact.type")); + myMainPanel.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myTypeBox = new JComboBox(); + myMainPanel.add(myTypeBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 1, false)); + label1.setLabelFor(myNameField); + label2.setLabelFor(myTypeBox); + } setTitle(JavaUiBundle.message("dialog.title.extract.artifact")); for (ArtifactType type : ArtifactType.getAllTypes()) { myTypeBox.addItem(type); @@ -48,11 +86,59 @@ public class ExtractArtifactDialog extends DialogWrapper implements IExtractArti init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected void doOKAction() { final String artifactName = getArtifactName(); if (myContext.getArtifactModel().findArtifact(artifactName) != null) { - Messages.showErrorDialog(myContext.getProject(), JavaUiBundle.message("dialog.message.artifact.0.already.exists", artifactName), CommonBundle.getErrorTitle()); + Messages.showErrorDialog(myContext.getProject(), JavaUiBundle.message("dialog.message.artifact.0.already.exists", artifactName), + CommonBundle.getErrorTitle()); return; } super.doOKAction(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChangeLibraryLevelDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChangeLibraryLevelDialog.java index c03de00fba83..b36fd9242979 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChangeLibraryLevelDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChangeLibraryLevelDialog.java @@ -11,22 +11,31 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ChangeLibraryLevelDialog extends DialogWrapper { - private JTextField myNameField; - private JCheckBox myCopyFilesCheckBox; - private TextFieldWithBrowseButton myDirectoryForFilesField; - private JPanel myMainPanel; + private final JTextField myNameField; + private final JCheckBox myCopyFilesCheckBox; + private final TextFieldWithBrowseButton myDirectoryForFilesField; + private final JPanel myMainPanel; private final boolean myAllowEmptyName; private final LibraryTable.ModifiableModel myModifiableModel; @@ -39,8 +48,39 @@ public class ChangeLibraryLevelDialog extends DialogWrapper { LibraryTableModifiableModelProvider provider) { super(parent, true); myAllowEmptyName = allowEmptyName; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.name")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myNameField = new JTextField(); + myMainPanel.add(myNameField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 1, false)); + myCopyFilesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myCopyFilesCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "checkbox.copy.library.files.to")); + myMainPanel.add(myCopyFilesCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDirectoryForFilesField = new TextFieldWithBrowseButton(); + myMainPanel.add(myDirectoryForFilesField, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(350, -1), null, 1, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(myNameField); + } setTitle(JavaUiBundle.message(copy ? "dialog.title.0.library.copy" : "dialog.title.0.library.move")); - myCopyFilesCheckBox.setText(JavaUiBundle.message(copy? "checkbox.0.library.files.to.copy" : "checkbox.0.library.files.to.move")); + myCopyFilesCheckBox.setText(JavaUiBundle.message(copy ? "checkbox.0.library.files.to.copy" : "checkbox.0.library.files.to.move")); myCopyFilesCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -64,6 +104,78 @@ public class ChangeLibraryLevelDialog extends DialogWrapper { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void checkName() { final String name = getLibraryName(); if (name.isEmpty()) { @@ -103,5 +215,4 @@ public class ChangeLibraryLevelDialog extends DialogWrapper { } return FileUtil.toSystemIndependentName(myDirectoryForFilesField.getText()); } - } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryPropertiesEditorBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryPropertiesEditorBase.java index 8bfaeebea9bd..fa3da3353045 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryPropertiesEditorBase.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryPropertiesEditorBase.java @@ -7,26 +7,33 @@ import com.intellij.openapi.roots.libraries.LibraryType; import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent; import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor; import com.intellij.openapi.util.NlsContexts; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public abstract class LibraryPropertiesEditorBase

    > extends LibraryPropertiesEditor { protected final Logger logger = Logger.getInstance(getClass()); private boolean myModified; - private JPanel myMainPanel; - private JLabel myDescriptionLabel; - private JButton myEditButton; - protected JButton myReloadButton; + private final JPanel myMainPanel; + private final JLabel myDescriptionLabel; + private final JButton myEditButton; + protected final JButton myReloadButton; protected final LibraryEditorComponent

    myEditorComponent; protected final T myLibraryType; @@ -34,6 +41,31 @@ public abstract class LibraryPropertiesEditorBase

    >> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myDescriptionLabel = new JLabel(); + this.$$$loadLabelText$$$(myDescriptionLabel, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.label")); + myMainPanel.add(myDescriptionLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(200, -1), null, null, 0, + false)); + myEditButton = new JButton(); + this.$$$loadButtonText$$$(myEditButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.edit3")); + myMainPanel.add(myEditButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myReloadButton = new JButton(); + this.$$$loadButtonText$$$(myReloadButton, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "button.reload")); + myReloadButton.setToolTipText(""); + myReloadButton.setVisible(false); + myMainPanel.add(myReloadButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } updateDescription(); if (editButtonText != null) { myEditButton.setText(UIUtil.replaceMnemonicAmpersand(editButtonText)); @@ -48,6 +80,78 @@ public abstract class LibraryPropertiesEditorBase

    thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + protected JPanel getMainPanel() { return myMainPanel; } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java index f8a073e29984..3b348ceb44e6 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java @@ -53,6 +53,8 @@ import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.tree.AsyncTreeModel; import com.intellij.ui.tree.StructureTreeModel; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtil; import com.intellij.util.IconUtil; import com.intellij.util.containers.ContainerUtil; @@ -72,6 +74,8 @@ import javax.swing.event.TreeModelEvent; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -87,11 +91,11 @@ import java.util.Set; public class LibraryRootsComponent implements Disposable, LibraryEditorComponent { static final UrlComparator ourUrlComparator = new UrlComparator(); - private JPanel myPanel; - private JPanel myTreePanel; - protected MultiLineLabel myPropertiesLabel; - private JPanel myPropertiesPanel; - private JLabel myBottomLabel; + private final JPanel myPanel; + private final JPanel myTreePanel; + protected final MultiLineLabel myPropertiesLabel; + private final JPanel myPropertiesPanel; + private final JLabel myBottomLabel; private LibraryPropertiesEditor myPropertiesEditor; private Tree myTree; private ModificationOfImportedModelWarningComponent myModificationOfImportedModelWarningComponent; @@ -113,6 +117,38 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent public LibraryRootsComponent(@Nullable Project project, @NotNull Computable libraryEditorComputable) { myProject = project; myLibraryEditorComputable = libraryEditorComputable; + { + myModificationOfImportedModelWarningComponent = new ModificationOfImportedModelWarningComponent(); + myBottomLabel = myModificationOfImportedModelWarningComponent.getLabel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, 2)); + myTreePanel = new JPanel(); + myPanel.add(myTreePanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(300, -1), null, 0, false)); + myPropertiesLabel = new MultiLineLabel(); + myPanel.add(myPropertiesLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myPropertiesPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myBottomLabel.setText(""); + myPanel.add(myBottomLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } final LibraryEditor editor = getLibraryEditor(); final LibraryType type = editor.getType(); if (type != null) { @@ -131,6 +167,9 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent updatePropertiesLabel(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull LibraryProperties getProperties() { return getLibraryEditor().getProperties(); @@ -146,8 +185,9 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent final LibraryType type = getLibraryEditor().getType(); final Set excluded = type != null ? Collections.singleton(type.getKind()) : Collections.emptySet(); - for (@Nls String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES), - excluded)) { + for (@Nls String description : LibraryPresentationManager.getInstance() + .getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES), + excluded)) { if (!sb.isEmpty()) { sb.append("\n"); } @@ -169,7 +209,8 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent for (Object childNode : childNodes) { LibraryTableTreeContentElement element = TreeUtil.getUserObject(LibraryTableTreeContentElement.class, childNode); if (element != null && myTree != null) { - myTreeModel.expand(element, myTree, path -> { }); + myTreeModel.expand(element, myTree, path -> { + }); } } } @@ -196,55 +237,57 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent } } toolbarDecorator.addExtraAction(new AddExcludedRootActionButton()); - toolbarDecorator.addExtraAction(new DumbAwareAction(JavaUiBundle.messagePointer("action.AnActionButton.text.remove"), IconUtil.getRemoveIcon()) { - { - setShortcutSet(CommonShortcuts.getDelete()); - } - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - final List selectedElements = getSelectedElements(); - if (selectedElements.isEmpty()) { - return; + toolbarDecorator.addExtraAction( + new DumbAwareAction(JavaUiBundle.messagePointer("action.AnActionButton.text.remove"), IconUtil.getRemoveIcon()) { + { + setShortcutSet(CommonShortcuts.getDelete()); } - ApplicationManager.getApplication().runWriteAction(() -> { - for (Object selectedElement : selectedElements) { - LibraryEditor libraryEditor = getLibraryEditor(); - if (selectedElement instanceof ItemElement itemElement) { - libraryEditor.removeRoot(itemElement.getUrl(), itemElement.getRootType()); - myRootRemovalHandler.onRootRemoved(itemElement.getUrl(), itemElement.getRootType(), libraryEditor); - } - else if (selectedElement instanceof OrderRootTypeElement orderRootTypeElement) { - final OrderRootType rootType = orderRootTypeElement.getOrderRootType(); - final String[] urls = libraryEditor.getUrls(rootType); - for (String url : urls) { - libraryEditor.removeRoot(url, rootType); + @Override + public void actionPerformed(@NotNull AnActionEvent e) { + final List selectedElements = getSelectedElements(); + if (selectedElements.isEmpty()) { + return; + } + + ApplicationManager.getApplication().runWriteAction(() -> { + for (Object selectedElement : selectedElements) { + LibraryEditor libraryEditor = getLibraryEditor(); + if (selectedElement instanceof ItemElement itemElement) { + libraryEditor.removeRoot(itemElement.getUrl(), itemElement.getRootType()); + myRootRemovalHandler.onRootRemoved(itemElement.getUrl(), itemElement.getRootType(), libraryEditor); + } + else if (selectedElement instanceof OrderRootTypeElement orderRootTypeElement) { + final OrderRootType rootType = orderRootTypeElement.getOrderRootType(); + final String[] urls = libraryEditor.getUrls(rootType); + for (String url : urls) { + libraryEditor.removeRoot(url, rootType); + } + } + else if (selectedElement instanceof ExcludedRootElement excludedRootElement) { + libraryEditor.removeExcludedRoot(excludedRootElement.getUrl()); } } - else if (selectedElement instanceof ExcludedRootElement excludedRootElement) { - libraryEditor.removeExcludedRoot(excludedRootElement.getUrl()); - } + }); + libraryChanged(true); + } + + @Override + public void update(@NotNull AnActionEvent e) { + Presentation presentation = e.getPresentation(); + if (ContainerUtil.and(getSelectedElements(), new FilteringIterator.InstanceOf<>(ExcludedRootElement.class))) { + presentation.setText(JavaUiBundle.message("action.text.cancel.exclusion")); + } + else { + presentation.setText(getTemplatePresentation().getText()); } - }); - libraryChanged(true); - } - - @Override - public void update(@NotNull AnActionEvent e) { - Presentation presentation = e.getPresentation(); - if (ContainerUtil.and(getSelectedElements(), new FilteringIterator.InstanceOf<>(ExcludedRootElement.class))) { - presentation.setText(JavaUiBundle.message("action.text.cancel.exclusion")); } - else { - presentation.setText(getTemplatePresentation().getText()); - } - } - @Override - public @NotNull ActionUpdateThread getActionUpdateThread() { - return ActionUpdateThread.EDT; - } - }); + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } + }); toolbarDecorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { @@ -349,11 +392,6 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent updateModificationOfImportedModelWarning(); } - private void createUIComponents() { - myModificationOfImportedModelWarningComponent = new ModificationOfImportedModelWarningComponent(); - myBottomLabel = myModificationOfImportedModelWarningComponent.getLabel(); - } - private static @Nullable Object getPathElement(final TreePath selectionPath) { if (selectionPath == null) { return null; @@ -525,7 +563,9 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent LibraryEditor libraryEditor = getLibraryEditor(); ProjectModelExternalSource externalSource = libraryEditor.getExternalSource(); if (externalSource != null && hasChanges()) { - String name = libraryEditor instanceof ExistingLibraryEditor ? ((ExistingLibraryEditor)libraryEditor).getLibrary().getName() : libraryEditor.getName(); + String name = libraryEditor instanceof ExistingLibraryEditor + ? ((ExistingLibraryEditor)libraryEditor).getLibrary().getName() + : libraryEditor.getName(); final String description; if (name != null) { description = JavaUiBundle.message("library.0", name); diff --git a/java/idea-ui/src/com/intellij/projectImport/ImportChooserStep.java b/java/idea-ui/src/com/intellij/projectImport/ImportChooserStep.java index 99f2c54e6e02..f338239019c0 100644 --- a/java/idea-ui/src/com/intellij/projectImport/ImportChooserStep.java +++ b/java/idea-ui/src/com/intellij/projectImport/ImportChooserStep.java @@ -13,12 +13,18 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.DoubleClickListener; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBRadioButton; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.Icon; @@ -26,13 +32,17 @@ import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.Component; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public class ImportChooserStep extends ProjectImportWizardStep { private static final String PREFERRED = "create.project.preferred.importer"; @@ -40,16 +50,56 @@ public class ImportChooserStep extends ProjectImportWizardStep { private final List myProviders; private final StepSequence mySequence; private @Nullable ProjectImportProvider myFromSourcesProvider; - private JBList myList; - private JPanel myPanel; + private final JBList myList; + private final JPanel myPanel; - private JBRadioButton myCreateFromSources; - private JBRadioButton myImportFrom; + private final JBRadioButton myCreateFromSources; + private final JBRadioButton myImportFrom; - public ImportChooserStep(final List providers, final StepSequence sequence, final WizardContext context) { + public ImportChooserStep(final List providers, + final StepSequence sequence, + final WizardContext context) { super(context); myProviders = providers; mySequence = sequence; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCreateFromSources = new JBRadioButton(); + this.$$$loadButtonText$$$(myCreateFromSources, + this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "project.new.wizard.from.existent.sources.title")); + myPanel.add(myCreateFromSources, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myImportFrom = new JBRadioButton(); + this.$$$loadButtonText$$$(myImportFrom, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "project.new.wizard.import.title")); + myPanel.add(myImportFrom, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myList = new JBList(); + jBScrollPane1.setViewportView(myList); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myCreateFromSources); + buttonGroup.add(myImportFrom); + } myImportFrom.setText(JavaUiBundle.message("project.new.wizard.import.title", context.getPresentationName())); myCreateFromSources.setText(JavaUiBundle.message("project.new.wizard.from.existent.sources.title", context.getPresentationName())); @@ -109,6 +159,53 @@ public class ImportChooserStep extends ProjectImportWizardStep { }.installOn(myList); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public void updateStep() { if (myList.getSelectedValue() != null) return; diff --git a/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java b/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java index 74d6e7d912fc..f4e3755fc8b2 100644 --- a/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java +++ b/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java @@ -11,15 +11,46 @@ import com.intellij.ui.SimpleListCellRenderer; import org.jetbrains.annotations.NotNull; import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ProjectFormatPanel { private static final String STORAGE_FORMAT_PROPERTY = "default.storage.format"; - private JComboBox myStorageFormatCombo; - private JPanel myWholePanel; + private final JComboBox myStorageFormatCombo; + private final JPanel myWholePanel; public ProjectFormatPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridBagLayout()); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaUiBundle", "label.project.format1")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 5, 0, 5); + myWholePanel.add(label1, gbc); + myStorageFormatCombo = new JComboBox(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(5, 0, 0, 0); + myWholePanel.add(myStorageFormatCombo, gbc); + } myStorageFormatCombo.insertItemAt(StorageFormat.DIR_BASED, 0); myStorageFormatCombo.insertItemAt(StorageFormat.FILE_BASED, 1); @@ -32,6 +63,53 @@ public class ProjectFormatPanel { myStorageFormatCombo.setRenderer(renderer); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public JPanel getPanel() { return myWholePanel; } @@ -58,17 +136,20 @@ public class ProjectFormatPanel { } private interface LocalizationAware { - @NlsContexts.Label String getTitle(); + @NlsContexts.Label + String getTitle(); } public enum StorageFormat implements LocalizationAware { DIR_BASED(".idea (directory based)") { - @Override public String getTitle(){ + @Override + public String getTitle() { return JavaUiBundle.message("label.directory.based", Project.DIRECTORY_STORE_FOLDER); } }, FILE_BASED(".ipr (file based)") { - @Override public String getTitle(){ + @Override + public String getTitle() { return JavaUiBundle.message("label.ipr.file.based"); } }; diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java index 1d76a23b3647..18953e0b7e8f 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java @@ -28,6 +28,9 @@ import com.intellij.refactoring.ui.MethodSignatureComponent; import com.intellij.refactoring.util.ParameterTablePanel; import com.intellij.refactoring.util.VariableData; import com.intellij.ui.EditorTextField; +import com.intellij.ui.TitledSeparator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.VisibilityUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.JBUI; @@ -38,12 +41,16 @@ import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Enumeration; +import java.util.ResourceBundle; public class ExtractMethodObjectDialog extends DialogWrapper implements AbstractExtractDialog { private static final String INDENT = " "; @@ -60,27 +67,27 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract private final PsiClass myTargetClass; private final boolean myWasStatic; - private JRadioButton myCreateInnerClassRb; - private JRadioButton myCreateAnonymousClassWrapperRb; - private MethodSignatureComponent mySignatureArea; - private JCheckBox myCbMakeStatic; - private JCheckBox myCbMakeVarargs; - private JCheckBox myCbMakeVarargsAnonymous; + private final JRadioButton myCreateInnerClassRb; + private final JRadioButton myCreateAnonymousClassWrapperRb; + private final MethodSignatureComponent mySignatureArea; + private final JCheckBox myCbMakeStatic; + private final JCheckBox myCbMakeVarargs; + private final JCheckBox myCbMakeVarargsAnonymous; - private JPanel myWholePanel; - private JPanel myParametersTableContainer; - private JRadioButton myPrivateRadioButton; - private JRadioButton myProtectedRadioButton; - private JRadioButton myPackageLocalRadioButton; - private JRadioButton myPublicRadioButton; + private final JPanel myWholePanel; + private final JPanel myParametersTableContainer; + private final JRadioButton myPrivateRadioButton; + private final JRadioButton myProtectedRadioButton; + private final JRadioButton myPackageLocalRadioButton; + private final JRadioButton myPublicRadioButton; - private EditorTextField myInnerClassName; - private EditorTextField myMethodName; + private final EditorTextField myInnerClassName; + private final EditorTextField myMethodName; - private JPanel myInnerClassPanel; - private JPanel myAnonymousClassPanel; - private JCheckBox myFoldCb; - private ButtonGroup myVisibilityGroup; + private final JPanel myInnerClassPanel; + private final JPanel myAnonymousClassPanel; + private final JCheckBox myFoldCb; + private final ButtonGroup myVisibilityGroup; private VariableData[] myInputVariables; public ExtractMethodObjectDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType, @@ -96,12 +103,168 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract myCanBeStatic = canBeStatic; myElementsToExtract = elementsToExtract; myMultipleExitPoints = multipleExitPoints; + { + mySignatureArea = new MethodSignatureComponent("", myProject, JavaFileType.INSTANCE); + mySignatureArea.setPreferredSize(JBUI.size(500, 100)); + mySignatureArea.setMinimumSize(JBUI.size(500, 100)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCreateInnerClassRb = new JRadioButton(); + this.$$$loadButtonText$$$(myCreateInnerClassRb, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.create.inner.class")); + myWholePanel.add(myCreateInnerClassRb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myInnerClassPanel = new JPanel(); + myInnerClassPanel.setLayout(new GridLayoutManager(4, 5, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myInnerClassPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setMinimumSize(new Dimension(62, 24)); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "extract.method.object.class.name")); + myInnerClassPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myInnerClassName = new EditorTextField(); + myInnerClassPanel.add(myInnerClassName, + new GridConstraints(0, 1, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.class.visibility")); + myInnerClassPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myPrivateRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPrivateRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.visibility.private")); + myInnerClassPanel.add(myPrivateRadioButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myProtectedRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myProtectedRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.visibility.protected")); + myInnerClassPanel.add(myProtectedRadioButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPackageLocalRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPackageLocalRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.visibility.package.local")); + myInnerClassPanel.add(myPackageLocalRadioButton, + new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPublicRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPublicRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.visibility.public")); + myInnerClassPanel.add(myPublicRadioButton, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCbMakeVarargs = new JCheckBox(); + this.$$$loadButtonText$$$(myCbMakeVarargs, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.make.varargs.option")); + myInnerClassPanel.add(myCbMakeVarargs, new GridConstraints(2, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCbMakeStatic = new JCheckBox(); + this.$$$loadButtonText$$$(myCbMakeStatic, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.inner.make.static.option")); + myInnerClassPanel.add(myCbMakeStatic, new GridConstraints(3, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCreateAnonymousClassWrapperRb = new JRadioButton(); + this.$$$loadButtonText$$$(myCreateAnonymousClassWrapperRb, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.create.anonymous.class")); + myWholePanel.add(myCreateAnonymousClassWrapperRb, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnonymousClassPanel = new JPanel(); + myAnonymousClassPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myAnonymousClassPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setMinimumSize(new Dimension(73, 24)); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "extract.method.object.method.name")); + myAnonymousClassPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myMethodName = new EditorTextField(); + myAnonymousClassPanel.add(myMethodName, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbMakeVarargsAnonymous = new JCheckBox(); + this.$$$loadButtonText$$$(myCbMakeVarargsAnonymous, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "extract.method.object.anonymous.make.varargs.option")); + myAnonymousClassPanel.add(myCbMakeVarargsAnonymous, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySignatureArea.setMinimumSize(new Dimension(0, 64)); + myWholePanel.add(mySignatureArea, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myParametersTableContainer = new JPanel(); + myParametersTableContainer.setLayout(new BorderLayout(0, 0)); + myWholePanel.add(myParametersTableContainer, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText( + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "extract.method.object.signature.preview")); + myWholePanel.add(titledSeparator1, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFoldCb = new JCheckBox(); + this.$$$loadButtonText$$$(myFoldCb, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "declare.folded.parameters")); + myWholePanel.add(myFoldCb, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator2 = new TitledSeparator(); + titledSeparator2.setText(this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "extract.method.object.parameters")); + myWholePanel.add(titledSeparator2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myInnerClassName); + label3.setLabelFor(myMethodName); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myCreateInnerClassRb); + buttonGroup.add(myCreateAnonymousClassWrapperRb); + myVisibilityGroup = new ButtonGroup(); + myVisibilityGroup.add(myPrivateRadioButton); + myVisibilityGroup.add(myProtectedRadioButton); + myVisibilityGroup.add(myPackageLocalRadioButton); + myVisibilityGroup.add(myPublicRadioButton); + } boolean canBeVarargs = false; for (VariableData data : inputVariables.getInputVariables()) { canBeVarargs |= data.type instanceof PsiArrayType; } - canBeVarargs |= inputVariables.isFoldable() && inputVariables.isFoldingSelectedByDefault(); + canBeVarargs |= inputVariables.isFoldable() && inputVariables.isFoldingSelectedByDefault(); myWasStatic = canBeVarargs; myVariableData = inputVariables; @@ -116,6 +279,78 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public boolean isMakeStatic() { if (myStaticFlag) return true; @@ -197,7 +432,7 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract updateSignature(); final PsiNameHelper helper = PsiNameHelper.getInstance(myProject); setOKActionEnabled((myCreateInnerClassRb.isSelected() && helper.isIdentifier(myInnerClassName.getText())) || - (!myCreateInnerClassRb.isSelected() && helper.isIdentifier(myMethodName.getText()))); + (!myCreateInnerClassRb.isSelected() && helper.isIdentifier(myMethodName.getText()))); } @Override @@ -240,7 +475,7 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract ActionListener updateSignatureListener = e -> { updateSignature(); - IdeFocusManager.getInstance(myProject).requestFocus(myCreateInnerClassRb.isSelected() ? myInnerClassName : myMethodName, false); + IdeFocusManager.getInstance(myProject).requestFocus(myCreateInnerClassRb.isSelected() ? myInnerClassName : myMethodName, false); }; if (myStaticFlag || myCanBeStatic) { @@ -284,7 +519,7 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract return myWholePanel; } - private void enable(boolean innerClassSelected){ + private void enable(boolean innerClassSelected) { UIUtil.setEnabled(myInnerClassPanel, innerClassSelected, true); UIUtil.setEnabled(myAnonymousClassPanel, !innerClassSelected, true); update(); @@ -377,7 +612,10 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract VariableData data = myInputVariables[i]; if (data.passAsParameter) { PsiType type = data.type; - if (i == myInputVariables.length - 1 && type instanceof PsiArrayType && ((myCreateInnerClassRb.isSelected() && myCbMakeVarargs.isSelected()) || (myCreateAnonymousClassWrapperRb.isSelected() && myCbMakeVarargsAnonymous.isSelected()))) { + if (i == myInputVariables.length - 1 && + type instanceof PsiArrayType && + ((myCreateInnerClassRb.isSelected() && myCbMakeVarargs.isSelected()) || + (myCreateAnonymousClassWrapperRb.isSelected() && myCbMakeVarargsAnonymous.isSelected()))) { type = new PsiEllipsisType(((PsiArrayType)type).getComponentType()); } @@ -409,10 +647,4 @@ public class ExtractMethodObjectDialog extends DialogWrapper implements Abstract public boolean createInnerClass() { return myCreateInnerClassRb.isSelected(); } - - private void createUIComponents() { - mySignatureArea = new MethodSignatureComponent("", myProject, JavaFileType.INSTANCE); - mySignatureArea.setPreferredSize(JBUI.size(500, 100)); - mySignatureArea.setMinimumSize(JBUI.size(500, 100)); - } } \ No newline at end of file diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java index 848b84a9e760..594f584eeb1b 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java @@ -52,6 +52,8 @@ import com.intellij.refactoring.util.RefactoringMessageUtil; import com.intellij.ui.RecentsManager; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; import com.intellij.ui.StateRestoringCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.usageView.UsageViewUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; @@ -59,18 +61,22 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.ResourceBundle; import java.util.Set; import static com.intellij.codeInsight.AnnotationUtil.CHECK_EXTERNAL; @@ -93,22 +99,22 @@ class IntroduceConstantDialog extends DialogWrapper { private NameSuggestionsManager myNameSuggestionsManager; private NameSuggestionsField myNameField; - private JCheckBox myCbReplaceAll; + private final JCheckBox myCbReplaceAll; private TypeSelector myTypeSelector; - private StateRestoringCheckBox myCbDeleteVariable; + private final StateRestoringCheckBox myCbDeleteVariable; private final JavaCodeStyleManager myCodeStyleManager; private ReferenceEditorComboWithBrowseButton myTfTargetClassName; private BaseExpressionToFieldHandler.TargetDestination myDestinationClass; - private JPanel myTypePanel; - private JPanel myTargetClassNamePanel; - private JPanel myPanel; - private JLabel myTypeLabel; - private JPanel myNameSuggestionPanel; - private JLabel myNameSuggestionLabel; - private JLabel myTargetClassNameLabel; - private JCheckBox myCbNonNls; - private JPanel myVisibilityPanel; + private final JPanel myTypePanel; + private final JPanel myTargetClassNamePanel; + private final JPanel myPanel; + private final JLabel myTypeLabel; + private final JPanel myNameSuggestionPanel; + private final JLabel myNameSuggestionLabel; + private final JLabel myTargetClassNameLabel; + private final JCheckBox myCbNonNls; + private final JPanel myVisibilityPanel; private final JavaVisibilityPanel myVPanel; private final JCheckBox myIntroduceEnumConstantCb = new JCheckBox(JavaRefactoringBundle.message("introduce.constant.enum.cb"), true); @@ -128,6 +134,81 @@ class IntroduceConstantDialog extends DialogWrapper { myInvokedOnDeclaration = isInvokedOnDeclaration; myOccurrences = occurrences; myEnteredName = enteredName; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(8, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myTypeLabel = new JLabel(); + this.$$$loadLabelText$$$(myTypeLabel, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "introduce.constant.field.of.type")); + panel1.add(myTypeLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTypePanel = new JPanel(); + panel1.add(myTypePanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameSuggestionLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameSuggestionLabel, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "name.prompt")); + panel2.add(myNameSuggestionLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameSuggestionPanel = new JPanel(); + panel2.add(myNameSuggestionPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetClassNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myTargetClassNameLabel, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "introduce.constant.introduce.to.class")); + myPanel.add(myTargetClassNameLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetClassNamePanel = new JPanel(); + myPanel.add(myTargetClassNamePanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbReplaceAll = new JCheckBox(); + myCbReplaceAll.setFocusable(false); + myCbReplaceAll.setSelected(true); + this.$$$loadButtonText$$$(myCbReplaceAll, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "replace.all.occurences.checkbox")); + myPanel.add(myCbReplaceAll, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbDeleteVariable = new StateRestoringCheckBox(); + this.$$$loadButtonText$$$(myCbDeleteVariable, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "delete.variable.declaration")); + myPanel.add(myCbDeleteVariable, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbNonNls = new JCheckBox(); + myCbNonNls.setSelected(false); + this.$$$loadButtonText$$$(myCbNonNls, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "annotate.field.as.nonnls.checkbox")); + myPanel.add(myCbNonNls, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myVisibilityPanel = new JPanel(); + myVisibilityPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myVisibilityPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myOccurrencesCount = occurrences.length; myTargetClass = targetClass; myTypeSelectorManager = typeSelectorManager; @@ -149,6 +230,78 @@ class IntroduceConstantDialog extends DialogWrapper { updateButtons(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public String getEnteredName() { return myNameField.getEnteredName(); } @@ -157,7 +310,7 @@ class IntroduceConstantDialog extends DialogWrapper { return myTfTargetClassName.getText().trim(); } - public BaseExpressionToFieldHandler.TargetDestination getDestinationClass () { + public BaseExpressionToFieldHandler.TargetDestination getDestinationClass() { return myDestinationClass; } @@ -240,7 +393,8 @@ class IntroduceConstantDialog extends DialogWrapper { } myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, createNameSuggestionGenerator(propertyName, myInitializerExpression, - myCodeStyleManager, myEnteredName, myParentClass)); + myCodeStyleManager, myEnteredName, + myParentClass)); myNameSuggestionsManager.setLabelsFor(myTypeLabel, myNameSuggestionLabel); ////////// @@ -269,11 +423,11 @@ class IntroduceConstantDialog extends DialogWrapper { updateCbDeleteVariable(); myCbReplaceAll.addItemListener( new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - updateCbDeleteVariable(); - } - }); + @Override + public void itemStateChanged(ItemEvent e) { + updateCbDeleteVariable(); + } + }); } } else { @@ -292,7 +446,8 @@ class IntroduceConstantDialog extends DialogWrapper { component.setValue(NONNLS_SELECTED_PROPERTY, myCbNonNls.isSelected()); } }); - } else { + } + else { myCbNonNls.setVisible(false); } @@ -316,7 +471,7 @@ class IntroduceConstantDialog extends DialogWrapper { @Override public SuggestedNameInfo getSuggestedNameInfo(PsiType type) { SuggestedNameInfo nameInfo = - codeStyleManager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, propertyName, psiExpression, type); + codeStyleManager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, propertyName, psiExpression, type); if (psiExpression != null) { String[] names = nameInfo.names; PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(psiExpression.getProject()).getResolveHelper(); @@ -328,10 +483,14 @@ class IntroduceConstantDialog extends DialogWrapper { } } final String[] strings = JavaNameSuggestionUtil.appendUnresolvedExprName(JavaCompletionUtil - .completeVariableNameForRefactoring(codeStyleManager, type, VariableKind.LOCAL_VARIABLE, nameInfo), psiExpression); - return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings): strings, nameInfo); + .completeVariableNameForRefactoring(codeStyleManager, + type, + VariableKind.LOCAL_VARIABLE, + nameInfo), + psiExpression); + return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings) : strings, + nameInfo); } - }; } @@ -349,13 +508,15 @@ class IntroduceConstantDialog extends DialogWrapper { private boolean isSuitableForEnumConstant() { return EnumConstantsUtil.isSuitableForEnumConstant(getSelectedType(), myTargetClass) && PsiTreeUtil .getParentOfType(myInitializerExpression, - PsiEnumConstant.class) == null; + PsiEnumConstant.class) == + null; } private void enableEnumDependant(boolean enable) { if (enable) { myVPanel.disableAllButPublic(); - } else { + } + else { updateVisibilityPanel(); } myCbNonNls.setEnabled(!enable); @@ -417,12 +578,13 @@ class IntroduceConstantDialog extends DialogWrapper { visible.add(PsiModifier.PUBLIC); for (PsiExpression occurrence : occurrences) { final PsiManager psiManager = PsiManager.getInstance(project); - for (Iterator iterator = visible.iterator(); iterator.hasNext();) { + for (Iterator iterator = visible.iterator(); iterator.hasNext(); ) { String modifier = iterator.next(); try { final String modifierText = PsiModifier.PACKAGE_LOCAL.equals(modifier) ? "" : modifier + " "; - final PsiField field = JavaPsiFacade.getElementFactory(psiManager.getProject()).createFieldFromText(modifierText + "int xxx;", targetClass); + final PsiField field = + JavaPsiFacade.getElementFactory(psiManager.getProject()).createFieldFromText(modifierText + "int xxx;", targetClass); if (!JavaResolveUtil.isAccessible(field, targetClass, field.getModifierList(), occurrence, targetClass, null)) { iterator.remove(); } @@ -451,7 +613,8 @@ class IntroduceConstantDialog extends DialogWrapper { return; } myDestinationClass = new BaseExpressionToFieldHandler.TargetDestination(targetClassName, myParentClass); - } else { + } + else { myDestinationClass = new BaseExpressionToFieldHandler.TargetDestination(newClass); } } @@ -460,9 +623,11 @@ class IntroduceConstantDialog extends DialogWrapper { String errorString = null; if (fieldName != null && fieldName.isEmpty()) { errorString = RefactoringBundle.message("no.field.name.specified"); - } else if (!PsiNameHelper.getInstance(myProject).isIdentifier(fieldName)) { + } + else if (!PsiNameHelper.getInstance(myProject).isIdentifier(fieldName)) { errorString = RefactoringMessageUtil.getIncorrectIdentifierMessage(fieldName); - } else if (newClass != null && !myParentClass.getLanguage().equals(newClass.getLanguage())) { + } + else if (newClass != null && !myParentClass.getLanguage().equals(newClass.getLanguage())) { errorString = RefactoringBundle.message("move.to.different.language", UsageViewUtil.getType(myParentClass), myParentClass.getQualifiedName(), newClass.getQualifiedName()); } diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java index 3b3b094cf008..faff0f25e1c5 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java @@ -38,50 +38,230 @@ import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.RecentsManager; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.VisibilityUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; -public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterObjectDialog { +public class IntroduceParameterObjectDialog + extends AbstractIntroduceParameterObjectDialog { - private JRadioButton useExistingClassButton; - private JPanel myUseExistingPanel; + private final JRadioButton useExistingClassButton; + private final JPanel myUseExistingPanel; - private JRadioButton createNewClassButton; - private JTextField classNameField; + private final JRadioButton createNewClassButton; + private final JTextField classNameField; - private JPanel myCreateNewClassPanel; + private final JPanel myCreateNewClassPanel; - private JRadioButton myCreateInnerClassRadioButton; - private JTextField myInnerClassNameTextField; - private JPanel myInnerClassPanel; + private final JRadioButton myCreateInnerClassRadioButton; + private final JTextField myInnerClassNameTextField; + private final JPanel myInnerClassPanel; - private JPanel myWholePanel; - private ReferenceEditorComboWithBrowseButton packageTextField; - private ReferenceEditorComboWithBrowseButton existingClassField; - private JCheckBox myGenerateAccessorsCheckBox; - private JCheckBox myEscalateVisibilityCheckBox; - private ComboboxWithBrowseButton myDestinationCb; + private final JPanel myWholePanel; + private final ReferenceEditorComboWithBrowseButton packageTextField; + private final ReferenceEditorComboWithBrowseButton existingClassField; + private final JCheckBox myGenerateAccessorsCheckBox; + private final JCheckBox myEscalateVisibilityCheckBox; + private final ComboboxWithBrowseButton myDestinationCb; private static final String RECENTS_KEY = "IntroduceParameterObject.RECENTS_KEY"; private static final String EXISTING_KEY = "IntroduceParameterObject.EXISTING_KEY"; public IntroduceParameterObjectDialog(PsiMethod sourceMethod) { super(sourceMethod); + { + final PsiFile file = mySourceMethod.getContainingFile(); + packageTextField = + new PackageNameReferenceEditorCombo(file instanceof PsiJavaFile ? ((PsiJavaFile)file).getPackageName() : "", myProject, RECENTS_KEY, + RefactoringBundle.message("choose.destination.package")); + final Document document = packageTextField.getChildComponent().getDocument(); + final com.intellij.openapi.editor.event.DocumentListener adapter = new com.intellij.openapi.editor.event.DocumentListener() { + @Override + public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { + validateButtons(); + } + }; + document.addDocumentListener(adapter); + + existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final Project project = mySourceMethod.getProject(); + final GlobalSearchScope scope = GlobalSearchScope.allScope(project); + final TreeJavaClassChooserDialog chooser = + new TreeJavaClassChooserDialog(RefactorJBundle.message("select.wrapper.class"), project, scope, null, null); + final String classText = existingClassField.getText(); + final PsiClass currentClass = JavaPsiFacade.getInstance(project).findClass(classText, GlobalSearchScope.allScope(project)); + if (currentClass != null) { + chooser.select(currentClass); + } + chooser.show(); + final PsiClass selectedClass = chooser.getSelected(); + if (selectedClass != null) { + final String className = selectedClass.getQualifiedName(); + existingClassField.setText(className); + RecentsManager.getInstance(myProject).registerRecentEntry(EXISTING_KEY, className); + } + } + }, "", myProject, true, EXISTING_KEY); + + existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() { + @Override + public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { + validateButtons(); + enableGenerateAccessors(); + } + }); + myDestinationCb = new DestinationFolderComboBox() { + @Override + public String getTargetPackage() { + return getPackageName(); + } + }; + ((DestinationFolderComboBox)myDestinationCb).setData(myProject, mySourceMethod.getContainingFile().getContainingDirectory(), + packageTextField.getChildComponent()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.putClientProperty("BorderFactoryClass", ""); + createNewClassButton = new JRadioButton(); + this.$$$loadButtonText$$$(createNewClassButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.create.new.class")); + myWholePanel.add(createNewClassButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCreateNewClassPanel = new JPanel(); + myCreateNewClassPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myCreateNewClassPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.new.class.name")); + myCreateNewClassPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + classNameField = new JTextField(); + myCreateNewClassPanel.add(classNameField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.new.class.package.name")); + myCreateNewClassPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myCreateNewClassPanel.add(packageTextField, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "target.destination.folder")); + myCreateNewClassPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myCreateNewClassPanel.add(myDestinationCb, + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUseExistingPanel = new JPanel(); + myUseExistingPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myUseExistingPanel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.existing.class.name")); + myUseExistingPanel.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myUseExistingPanel.add(existingClassField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myGenerateAccessorsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myGenerateAccessorsCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.generate.accessors.option")); + myUseExistingPanel.add(myGenerateAccessorsCheckBox, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEscalateVisibilityCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myEscalateVisibilityCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.escalate.visibility.option")); + myUseExistingPanel.add(myEscalateVisibilityCheckBox, + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCreateInnerClassRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCreateInnerClassRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.create.inner.class")); + myWholePanel.add(myCreateInnerClassRadioButton, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInnerClassPanel = new JPanel(); + myInnerClassPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myInnerClassPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.inner.class.name")); + myInnerClassPanel.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myInnerClassNameTextField = new JTextField(); + myInnerClassPanel.add(myInnerClassNameTextField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + useExistingClassButton = new JRadioButton(); + this.$$$loadButtonText$$$(useExistingClassButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "introduce.parameter.object.use.existing.class")); + myWholePanel.add(useExistingClassButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + label1.setLabelFor(classNameField); + label3.setLabelFor(myDestinationCb); + label5.setLabelFor(myInnerClassNameTextField); + } final DocumentListener docListener = new DocumentAdapter() { @Override protected void textChanged(final @NotNull DocumentEvent e) { @@ -126,6 +306,78 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb toggleRadioEnablement(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override protected boolean isDelegateCheckboxVisible() { final PsiClass containingClass = mySourceMethod.getContainingClass(); @@ -163,10 +415,10 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb } return new ParameterTablePanel(myProject, parameterInfo) { @Override - protected void updateSignature() {} + protected void updateSignature() { } @Override - protected void doEnterAction() {} + protected void doEnterAction() { } @Override protected void doCancelAction() { @@ -189,7 +441,8 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb if (createInnerClass) { className = getInnerClassName(); packageName = ""; - } else if (useExistingClass) { + } + else if (useExistingClass) { final String existingClassName = getExistingClassName(); className = StringUtil.getShortName(existingClassName); packageName = StringUtil.getPackageName(existingClassName); @@ -224,11 +477,16 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project); if (myCreateInnerClassRadioButton.isSelected()) { final String innerClassName = getInnerClassName(); - if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException( - JavaRefactoringBundle.message("introduce.parameter.object.error.invalid.inner.class.name", innerClassName)); - if (mySourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException( - JavaRefactoringBundle.message("introduce.parameter.object.error.inner.class.already.exist", innerClassName)); - } else if (!useExistingClass()) { + if (!nameHelper.isIdentifier(innerClassName)) { + throw new ConfigurationException( + JavaRefactoringBundle.message("introduce.parameter.object.error.invalid.inner.class.name", innerClassName)); + } + if (mySourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) { + throw new ConfigurationException( + JavaRefactoringBundle.message("introduce.parameter.object.error.inner.class.already.exist", innerClassName)); + } + } + else if (!useExistingClass()) { final String className = getClassName(); if (className.isEmpty() || !nameHelper.isIdentifier(className)) { throw new ConfigurationException( @@ -254,7 +512,7 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb } private @NotNull String getInnerClassName() { - return myInnerClassNameTextField.getText().trim(); + return myInnerClassNameTextField.getText().trim(); } public @NotNull String getPackageName() { @@ -283,57 +541,6 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb return useExistingClassButton.isSelected(); } - private void createUIComponents() { - final PsiFile file = mySourceMethod.getContainingFile(); - packageTextField = - new PackageNameReferenceEditorCombo(file instanceof PsiJavaFile ? ((PsiJavaFile)file).getPackageName() : "", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package")); - final Document document = packageTextField.getChildComponent().getDocument(); - final com.intellij.openapi.editor.event.DocumentListener adapter = new com.intellij.openapi.editor.event.DocumentListener() { - @Override - public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { - validateButtons(); - } - }; - document.addDocumentListener(adapter); - - existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final Project project = mySourceMethod.getProject(); - final GlobalSearchScope scope = GlobalSearchScope.allScope(project); - final TreeJavaClassChooserDialog chooser = - new TreeJavaClassChooserDialog(RefactorJBundle.message("select.wrapper.class"), project, scope, null, null); - final String classText = existingClassField.getText(); - final PsiClass currentClass = JavaPsiFacade.getInstance(project).findClass(classText, GlobalSearchScope.allScope(project)); - if (currentClass != null) { - chooser.select(currentClass); - } - chooser.show(); - final PsiClass selectedClass = chooser.getSelected(); - if (selectedClass != null) { - final String className = selectedClass.getQualifiedName(); - existingClassField.setText(className); - RecentsManager.getInstance(myProject).registerRecentEntry(EXISTING_KEY, className); - } - } - }, "", myProject, true, EXISTING_KEY); - - existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() { - @Override - public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { - validateButtons(); - enableGenerateAccessors(); - } - }); - myDestinationCb = new DestinationFolderComboBox() { - @Override - public String getTargetPackage() { - return getPackageName(); - } - }; - ((DestinationFolderComboBox)myDestinationCb).setData(myProject, mySourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent()); - } - private void enableGenerateAccessors() { boolean existingNotALibraryClass = false; if (useExistingClassButton.isSelected()) { @@ -344,7 +551,8 @@ public class IntroduceParameterObjectDialog extends AbstractIntroduceParameterOb if (containingFile != null) { final VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile != null) { - existingNotALibraryClass = ProjectRootManager.getInstance(myProject).getFileIndex().isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES); + existingNotALibraryClass = ProjectRootManager.getInstance(myProject).getFileIndex() + .isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES); } } } diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java index eb7986379ae7..47d6337703dd 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java @@ -50,24 +50,37 @@ import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.EditorComboBox; +import com.intellij.ui.NonFocusableCheckBox; import com.intellij.ui.RecentsManager; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; import com.intellij.ui.ReferenceEditorWithBrowseButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.usageView.UsageViewUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.CardLayout; import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; import java.util.Set; import java.util.function.Consumer; @@ -83,21 +96,21 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { private final boolean mySuggestToMoveToAnotherRoot; private final String myHelpID; - private JLabel myNameLabel; - private ReferenceEditorComboWithBrowseButton myWithBrowseButtonReference; - private JCheckBox myCbSearchInComments; - private JCheckBox myCbSearchTextOccurrences; - private JPanel myMainPanel; - private JRadioButton myToPackageRadioButton; - private JRadioButton myMakeInnerClassOfRadioButton; - private ReferenceEditorComboWithBrowseButton myClassPackageChooser; - private JPanel myCardPanel; - private ReferenceEditorWithBrowseButton myInnerClassChooser; - private JPanel myMoveClassPanel; - private JPanel myMovePackagePanel; - private ComboboxWithBrowseButton myDestinationFolderCB; - private JPanel myTargetPanel; - private JLabel myTargetDestinationLabel; + private final JLabel myNameLabel; + private final ReferenceEditorComboWithBrowseButton myWithBrowseButtonReference; + private final JCheckBox myCbSearchInComments; + private final JCheckBox myCbSearchTextOccurrences; + private final JPanel myMainPanel; + private final JRadioButton myToPackageRadioButton; + private final JRadioButton myMakeInnerClassOfRadioButton; + private final ReferenceEditorComboWithBrowseButton myClassPackageChooser; + private final JPanel myCardPanel; + private final ReferenceEditorWithBrowseButton myInnerClassChooser; + private final JPanel myMoveClassPanel; + private final JPanel myMovePackagePanel; + private final ComboboxWithBrowseButton myDestinationFolderCB; + private final JPanel myTargetPanel; + private final JLabel myTargetDestinationLabel; private boolean myHavePackages; public MoveClassesOrPackagesDialog(@NotNull Project project, @@ -113,6 +126,136 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { myElementsToMove = elementsToMove; myMoveCallback = moveCallback; + { + myWithBrowseButtonReference = createPackageChooser(); + myClassPackageChooser = createPackageChooser(); + + GlobalSearchScope scope = JavaProjectRootsUtil.getScopeWithoutGeneratedSources(ProjectScope.getProjectScope(myProject), myProject); + myInnerClassChooser = new ClassNameReferenceEditor(myProject, null, scope); + myInnerClassChooser.addDocumentListener(new DocumentListener() { + @Override + public void documentChanged(@NotNull DocumentEvent e) { + validateButtons(); + } + }); + + // override CardLayout sizing behavior + myCardPanel = new JPanel() { + @Override + public Dimension getMinimumSize() { + return myHavePackages ? myMovePackagePanel.getMinimumSize() : myMoveClassPanel.getMinimumSize(); + } + + @Override + public Dimension getPreferredSize() { + return myHavePackages ? myMovePackagePanel.getPreferredSize() : myMoveClassPanel.getPreferredSize(); + } + }; + + myDestinationFolderCB = new DestinationFolderComboBox() { + @Override + public String getTargetPackage() { + return MoveClassesOrPackagesDialog.this.getTargetPackage(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + myNameLabel = new JLabel(); + myNameLabel.setEnabled(true); + Font myNameLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, myNameLabel.getFont()); + if (myNameLabelFont != null) myNameLabel.setFont(myNameLabelFont); + this.$$$loadLabelText$$$(myNameLabel, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "move.classes.or.packages.title")); + myMainPanel.add(myNameLabel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myCbSearchInComments = new NonFocusableCheckBox(); + myCbSearchInComments.setSelected(true); + this.$$$loadButtonText$$$(myCbSearchInComments, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.in.comments.and.strings")); + myMainPanel.add(myCbSearchInComments, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myCbSearchTextOccurrences = new NonFocusableCheckBox(); + myCbSearchTextOccurrences.setSelected(true); + this.$$$loadButtonText$$$(myCbSearchTextOccurrences, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.for.text.occurrences")); + myMainPanel.add(myCbSearchTextOccurrences, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCardPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myCardPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myMoveClassPanel = new JPanel(); + myMoveClassPanel.setLayout(new GridLayoutManager(2, 2, new Insets(7, 0, 7, 0), -1, -1)); + myCardPanel.add(myMoveClassPanel, "Class"); + myToPackageRadioButton = new JRadioButton(); + myToPackageRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myToPackageRadioButton, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "move.classes.destination.to.package")); + myMoveClassPanel.add(myToPackageRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myMakeInnerClassOfRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myMakeInnerClassOfRadioButton, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "move.classes.destination.make.inner")); + myMoveClassPanel.add(myMakeInnerClassOfRadioButton, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myMoveClassPanel.add(myClassPackageChooser, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMoveClassPanel.add(myInnerClassChooser, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myMovePackagePanel = new JPanel(); + myMovePackagePanel.setLayout(new GridLayoutManager(1, 2, new Insets(7, 0, 7, 0), -1, -1)); + myCardPanel.add(myMovePackagePanel, "Package"); + myMovePackagePanel.add(myWithBrowseButtonReference, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "move.classes.destination.package.prompt")); + myMovePackagePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetPanel = new JPanel(); + myTargetPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myTargetPanel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myTargetDestinationLabel = new JLabel(); + this.$$$loadLabelText$$$(myTargetDestinationLabel, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "target.destination.folder")); + myTargetPanel.add(myTargetDestinationLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myTargetPanel.add(myDestinationFolderCB, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myTargetDestinationLabel.setLabelFor(myDestinationFolderCB); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myToPackageRadioButton); + buttonGroup.add(myMakeInnerClassOfRadioButton); + } myManager = PsiManager.getInstance(myProject); setTitle(MoveHandler.getRefactoringName()); mySearchTextOccurrencesEnabled = searchTextOccurrences; @@ -140,11 +283,13 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { updateControlsEnabled(); myToPackageRadioButton.addActionListener(e -> { updateControlsEnabled(); - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myClassPackageChooser, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myClassPackageChooser, true)); }); myMakeInnerClassOfRadioButton.addActionListener(e -> { updateControlsEnabled(); - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myInnerClassChooser, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myInnerClassChooser, true)); }); myTargetDirectoryFixed = initialTargetDirectory == null; @@ -169,10 +314,12 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { PsiElement parent = firstElement.getParent(); LOG.assertTrue(parent != null); } - myNameLabel.setText(JavaRefactoringBundle.message("move.single.class.or.package.name.label", UsageViewUtil.getType(firstElement), UsageViewUtil.getLongName(firstElement))); + myNameLabel.setText(JavaRefactoringBundle.message("move.single.class.or.package.name.label", UsageViewUtil.getType(firstElement), + UsageViewUtil.getLongName(firstElement))); } else if (elementsToMove.length > 1) { - myNameLabel.setText(JavaRefactoringBundle.message(elementsToMove[0] instanceof PsiClass ? "move.specified.classes" : "move.specified.packages")); + myNameLabel.setText( + JavaRefactoringBundle.message(elementsToMove[0] instanceof PsiClass ? "move.specified.classes" : "move.specified.packages")); } selectInitialCard(); @@ -203,6 +350,102 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { myHelpID = HelpID.getMoveHelpID(elementsToMove[0]); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + static boolean canBeOpenedInEditor(PsiElement @NotNull [] elementsToMove) { for (PsiElement element : elementsToMove) { if (element.getContainingFile() != null) { @@ -244,40 +487,6 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { return null; } - private void createUIComponents() { - myWithBrowseButtonReference = createPackageChooser(); - myClassPackageChooser = createPackageChooser(); - - GlobalSearchScope scope = JavaProjectRootsUtil.getScopeWithoutGeneratedSources(ProjectScope.getProjectScope(myProject), myProject); - myInnerClassChooser = new ClassNameReferenceEditor(myProject, null, scope); - myInnerClassChooser.addDocumentListener(new DocumentListener() { - @Override - public void documentChanged(@NotNull DocumentEvent e) { - validateButtons(); - } - }); - - // override CardLayout sizing behavior - myCardPanel = new JPanel() { - @Override - public Dimension getMinimumSize() { - return myHavePackages ? myMovePackagePanel.getMinimumSize() : myMoveClassPanel.getMinimumSize(); - } - - @Override - public Dimension getPreferredSize() { - return myHavePackages ? myMovePackagePanel.getPreferredSize() : myMoveClassPanel.getPreferredSize(); - } - }; - - myDestinationFolderCB = new DestinationFolderComboBox() { - @Override - public String getTargetPackage() { - return MoveClassesOrPackagesDialog.this.getTargetPackage(); - } - }; - } - private ReferenceEditorComboWithBrowseButton createPackageChooser() { final ReferenceEditorComboWithBrowseButton packageChooser = new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package")); @@ -323,7 +532,8 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { if (sourceRootForFile != null) { initialRoots.add(sourceRootForFile); } - } else if (element instanceof PsiDirectoryContainer) { + } + else if (element instanceof PsiDirectoryContainer) { collectSourceRoots(((PsiDirectoryContainer)element).getDirectories(), fileIndex, initialRoots); } } @@ -342,8 +552,10 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { } } else { - if (findTargetClass() == null) throw new ConfigurationException( - JavaBundle.message("move.classes.destination.class.not.found.message")); + if (findTargetClass() == null) { + throw new ConfigurationException( + JavaBundle.message("move.classes.destination.class.not.found.message")); + } final String validationError = verifyInnerClassDestination(); if (validationError != null) throw new ConfigurationException(validationError); } @@ -367,7 +579,8 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { return myHavePackages ? myWithBrowseButtonReference.getText() : myClassPackageChooser.getText(); } - private static @Nullable @NlsContexts.DialogMessage String verifyDestinationForElement(@NotNull PsiElement element, @NotNull MoveDestination moveDestination) { + private static @Nullable @NlsContexts.DialogMessage String verifyDestinationForElement(@NotNull PsiElement element, + @NotNull MoveDestination moveDestination) { return switch (element) { case PsiDirectory directory -> moveDestination.verify(directory); case PsiPackage aPackage -> moveDestination.verify(aPackage); @@ -425,7 +638,8 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { protected MoveClassesOrPackagesProcessor createMoveToPackageProcessor(@NotNull MoveDestination destination, PsiElement @NotNull [] elementsToMove, MoveCallback callback) { - return new MoveClassesOrPackagesProcessor(getProject(), elementsToMove, destination, isSearchInComments(), isSearchInNonJavaFiles(), callback); + return new MoveClassesOrPackagesProcessor(getProject(), elementsToMove, destination, isSearchInComments(), isSearchInNonJavaFiles(), + callback); } private void saveRefactoringSettings() { @@ -478,7 +692,8 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { protected MoveClassToInnerProcessor createMoveToInnerProcessor(@NotNull PsiClass destination, PsiClass @NotNull [] classesToMove, @Nullable MoveCallback callback) { - return new MoveClassToInnerProcessor(getProject(), classesToMove, destination, isSearchInComments(), isSearchInNonJavaFiles(), callback); + return new MoveClassToInnerProcessor(getProject(), classesToMove, destination, isSearchInComments(), isSearchInNonJavaFiles(), + callback); } protected final boolean isSearchInNonJavaFiles() { @@ -496,9 +711,9 @@ public class MoveClassesOrPackagesDialog extends MoveDialogBase { PackageWrapper targetPackage = new PackageWrapper(myManager, packageName); if (!targetPackage.exists()) { if (isPreviewUsages()) { - int res = Messages.showOkCancelDialog(myProject, + int res = Messages.showOkCancelDialog(myProject, JavaRefactoringBundle.message("package.does.not.exist.preview", packageName), - RefactoringBundle.message("move.title"), + RefactoringBundle.message("move.title"), CommonBundle.getOkButtonText(), CommonBundle.getCancelButtonText(), null); if (res != Messages.OK) return null; diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java index d374505f7845..db6bda6c7f8f 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java @@ -36,22 +36,31 @@ import com.intellij.refactoring.util.CommonMoveClassesOrPackagesUtil; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.RefactoringMessageUtil; import com.intellij.ui.EditorTextField; +import com.intellij.ui.NonFocusableCheckBox; import com.intellij.ui.RecentsManager; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.CommonJavaRefactoringUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.Set; public class MoveInnerDialog extends MoveDialogBase { @@ -59,16 +68,16 @@ public class MoveInnerDialog extends MoveDialogBase { private final PsiElement myTargetContainer; private final MoveInnerProcessor myProcessor; - private EditorTextField myClassNameField; - private NameSuggestionsField myParameterField; - private JCheckBox myCbPassOuterClass; - private JPanel myPanel; - private JCheckBox myCbSearchInComments; - private JCheckBox myCbSearchForTextOccurences; - private PackageNameReferenceEditorCombo myPackageNameField; - private JLabel myPackageNameLabel; - private JLabel myClassNameLabel; - private JLabel myParameterNameLabel; + private final EditorTextField myClassNameField; + private final NameSuggestionsField myParameterField; + private final JCheckBox myCbPassOuterClass; + private final JPanel myPanel; + private final JCheckBox myCbSearchInComments; + private final JCheckBox myCbSearchForTextOccurences; + private final PackageNameReferenceEditorCombo myPackageNameField; + private final JLabel myPackageNameLabel; + private final JLabel myClassNameLabel; + private final JLabel myParameterNameLabel; private SuggestedNameInfo mySuggestedNameInfo; private final PsiClass myOuterClass; @@ -83,6 +92,89 @@ public class MoveInnerDialog extends MoveDialogBase { super(project, true, true); myInnerClass = innerClass; myTargetContainer = targetContainer; + { + if (!myInnerClass.hasModifierProperty(PsiModifier.STATIC)) { + final PsiManager manager = myInnerClass.getManager(); + PsiType outerType = JavaPsiFacade.getElementFactory(manager.getProject()).createType(myInnerClass.getContainingClass()); + mySuggestedNameInfo = + JavaCodeStyleManager.getInstance(myProject).suggestVariableName(VariableKind.PARAMETER, null, null, outerType); + String[] variants = mySuggestedNameInfo.names; + myParameterField = new NameSuggestionsField(variants, myProject, JavaFileType.INSTANCE); + } + else { + myParameterField = new NameSuggestionsField(new String[]{""}, myProject, JavaFileType.INSTANCE); + myParameterField.getComponent().setEnabled(false); + } + + PsiPackage psiPackage = getTargetPackage(); + myPackageNameField = + new PackageNameReferenceEditorCombo(psiPackage != null ? psiPackage.getQualifiedName() : "", myProject, RECENTS_KEY, + RefactoringBundle.message("choose.destination.package")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 0, 0), -1, -1)); + myClassNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myClassNameLabel, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "class.name.prompt")); + myPanel.add(myClassNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myClassNameField = new EditorTextField(); + myPanel.add(myClassNameField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCbPassOuterClass = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(myCbPassOuterClass, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "pass.outer.class.instance.as.parameter")); + myPanel.add(myCbPassOuterClass, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myParameterNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myParameterNameLabel, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "parameter.name.prompt")); + myPanel.add(myParameterNameLabel, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myPanel.add(myParameterField, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 1, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); + myPanel.add(panel1, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myCbSearchInComments = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(myCbSearchInComments, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.in.comments.and.strings")); + panel1.add(myCbSearchInComments); + myCbSearchForTextOccurences = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(myCbSearchForTextOccurences, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.for.text.occurrences")); + panel1.add(myCbSearchForTextOccurences); + myPackageNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myPackageNameLabel, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "package.name.prompt")); + myPanel.add(myPackageNameLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPanel.add(myPackageNameField, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myOuterClass = myInnerClass.getContainingClass(); myProcessor = processor; setTitle(MoveInnerImpl.getRefactoringName()); @@ -92,6 +184,78 @@ public class MoveInnerDialog extends MoveDialogBase { myParameterNameLabel.setLabelFor(myParameterField); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public boolean isSearchInComments() { return myCbSearchInComments.isSelected(); } @@ -209,7 +373,7 @@ public class MoveInnerDialog extends MoveDialogBase { if (targetPackage != null) { final PsiDirectory[] directories = targetPackage.getDirectories(); final VirtualFile root = projectRootManager.getFileIndex().getSourceRootForFile(psiDirectory.getVirtualFile()); - for(PsiDirectory dir: directories) { + for (PsiDirectory dir : directories) { if (Comparing.equal(projectRootManager.getFileIndex().getSourceRootForFile(dir.getVirtualFile()), root)) { initialDir = dir; break; @@ -325,24 +489,6 @@ public class MoveInnerDialog extends MoveDialogBase { return HelpID.MOVE_INNER_UPPER; } - private void createUIComponents() { - if (!myInnerClass.hasModifierProperty(PsiModifier.STATIC)) { - final PsiManager manager = myInnerClass.getManager(); - PsiType outerType = JavaPsiFacade.getElementFactory(manager.getProject()).createType(myInnerClass.getContainingClass()); - mySuggestedNameInfo = JavaCodeStyleManager.getInstance(myProject).suggestVariableName(VariableKind.PARAMETER, null, null, outerType); - String[] variants = mySuggestedNameInfo.names; - myParameterField = new NameSuggestionsField(variants, myProject, JavaFileType.INSTANCE); - } - else { - myParameterField = new NameSuggestionsField(new String[]{""}, myProject, JavaFileType.INSTANCE); - myParameterField.getComponent().setEnabled(false); - } - - PsiPackage psiPackage = getTargetPackage(); - myPackageNameField = new PackageNameReferenceEditorCombo(psiPackage != null ? psiPackage.getQualifiedName() : "", myProject, RECENTS_KEY, - RefactoringBundle.message("choose.destination.package")); - } - private @Nullable PsiPackage getTargetPackage() { if (myTargetContainer instanceof PsiDirectory directory) { return JavaDirectoryService.getInstance().getPackage(directory); diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderDialog.java b/java/java-impl-refactorings/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderDialog.java index 66aa970eda36..dc3c9b366099 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderDialog.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderDialog.java @@ -50,7 +50,9 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.Box; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; @@ -63,24 +65,29 @@ import javax.swing.event.DocumentEvent; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumnModel; import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.ResourceBundle; public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { private final PsiMethod[] myConstructors; - private JRadioButton myCreateBuilderClassRadioButton; - private JRadioButton myExistingBuilderClassRadioButton; + private final JRadioButton myCreateBuilderClassRadioButton; + private final JRadioButton myExistingBuilderClassRadioButton; - private JPanel myWholePanel; - private JTextField myNewClassName; - private ReferenceEditorComboWithBrowseButton myPackageTextField; - private ReferenceEditorComboWithBrowseButton myExistentClassTF; - private ComboboxWithBrowseButton myDestinationCb; - private JPanel myCreateNewPanel; + private final JPanel myWholePanel; + private final JTextField myNewClassName; + private final ReferenceEditorComboWithBrowseButton myPackageTextField; + private final ReferenceEditorComboWithBrowseButton myExistentClassTF; + private final ComboboxWithBrowseButton myDestinationCb; + private final JPanel myCreateNewPanel; private static final Logger LOG = Logger.getInstance(ReplaceConstructorWithBuilderDialog.class); private final LinkedHashMap myParametersMap; @@ -94,6 +101,175 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { protected ReplaceConstructorWithBuilderDialog(@NotNull Project project, PsiMethod[] constructors) { super(project, false, true); myConstructors = constructors; + { + final DocumentListener adapter = new DocumentListener() { + @Override + public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { + validateButtons(); + } + }; + + myPackageTextField = + new PackageNameReferenceEditorCombo(((PsiJavaFile)myConstructors[0].getContainingFile()).getPackageName(), myProject, RECENT_KEYS, + RefactoringBundle.message("choose.destination.package")); + myPackageTextField.getChildComponent().getDocument().addDocumentListener(adapter); + + myDestinationCb = new DestinationFolderComboBox() { + @Override + public String getTargetPackage() { + return myPackageTextField.getText().trim(); + } + }; + ((DestinationFolderComboBox)myDestinationCb).setData(myProject, myConstructors[0].getContainingFile().getContainingDirectory(), + myPackageTextField.getChildComponent()); + + myExistentClassTF = new ReferenceEditorComboWithBrowseButton(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) + .createWithInnerClassesScopeChooser( + JavaRefactoringBundle.message("replace.constructor.builder.select.builder.class.chooser.title"), + GlobalSearchScope.projectScope(myProject), null, null); + final String classText = myExistentClassTF.getText(); + final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); + if (currentClass != null) { + chooser.select(currentClass); + } + chooser.showDialog(); + final PsiClass selectedClass = chooser.getSelected(); + if (selectedClass != null) { + myExistentClassTF.setText(selectedClass.getQualifiedName()); + } + } + }, "", myProject, true, RECENT_KEYS); + myExistentClassTF.getChildComponent().getDocument().addDocumentListener(adapter); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridBagLayout()); + final JPanel spacer1 = new JPanel(); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.gridheight = 2; + gbc.fill = GridBagConstraints.HORIZONTAL; + myWholePanel.add(spacer1, gbc); + final JPanel spacer2 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 5; + gbc.fill = GridBagConstraints.VERTICAL; + myWholePanel.add(spacer2, gbc); + myCreateBuilderClassRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCreateBuilderClassRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "replace.constructor.builder.create.new")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(10, 0, 0, 0); + myWholePanel.add(myCreateBuilderClassRadioButton, gbc); + myExistingBuilderClassRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myExistingBuilderClassRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "replace.constructor.builder.use.existing")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 0, 0, 0); + myWholePanel.add(myExistingBuilderClassRadioButton, gbc); + myCreateNewPanel = new JPanel(); + myCreateNewPanel.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(5, 20, 0, 0); + myWholePanel.add(myCreateNewPanel, gbc); + myNewClassName = new JTextField(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + myCreateNewPanel.add(myNewClassName, gbc); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "replace.constructor.new.builder.class.name")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + myCreateNewPanel.add(label1, gbc); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.fill = GridBagConstraints.HORIZONTAL; + myCreateNewPanel.add(myPackageTextField, gbc); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "replace.constructor.new.builder.package")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 0, 0, 0); + myCreateNewPanel.add(label2, gbc); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "target.destination.folder")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 4; + gbc.anchor = GridBagConstraints.WEST; + myCreateNewPanel.add(label3, gbc); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 5; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + myCreateNewPanel.add(myDestinationCb, gbc); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 4; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(5, 20, 0, 0); + myWholePanel.add(panel1, gbc); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "replace.constructor.existing.builder.fqn")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + panel1.add(label4, gbc); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 2; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel1.add(myExistentClassTF, gbc); + final JPanel spacer3 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel1.add(spacer3, gbc); + label1.setLabelFor(myNewClassName); + label3.setLabelFor(myDestinationCb); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myCreateBuilderClassRadioButton); + buttonGroup.add(myExistingBuilderClassRadioButton); + } myParametersMap = new LinkedHashMap<>(); mySetterPrefix = PropertiesComponent.getInstance(project).getValue(SETTER_PREFIX_KEY, "set"); for (PsiMethod constructor : constructors) { @@ -103,6 +279,78 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { setTitle(JavaRefactoringBundle.message("replace.constructor.with.builder")); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override protected String getHelpId() { return HelpID.REPLACE_CONSTRUCTOR_WITH_BUILDER; @@ -118,7 +366,8 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { if (createNewBuilder) { className = myNewClassName.getText().trim(); packageName = myPackageTextField.getText().trim(); - } else { + } + else { final String fqName = myExistentClassTF.getText().trim(); className = StringUtil.getShortName(fqName); packageName = StringUtil.getPackageName(fqName); @@ -158,7 +407,8 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { @Override protected @Nullable JComponent createNorthPanel() { JPanel panel = new JPanel(new BorderLayout()); - panel.add(new JLabel(JavaRefactoringBundle.message("constructor.with.builder.parameters.to.pass.to.the.builder.title")), BorderLayout.CENTER); + panel.add(new JLabel(JavaRefactoringBundle.message("constructor.with.builder.parameters.to.pass.to.the.builder.title")), + BorderLayout.CENTER); final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.addAction(new AnAction(JavaRefactoringBundle.message("constructor.with.builder.rename.setters.prefix.action.name")) { @@ -168,7 +418,8 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { } }).setAsSecondary(true); - panel.add(ActionManager.getInstance().createActionToolbar("ReplaceConstructorWithBuilder", actionGroup, true).getComponent(), BorderLayout.EAST); + panel.add(ActionManager.getInstance().createActionToolbar("ReplaceConstructorWithBuilder", actionGroup, true).getComponent(), + BorderLayout.EAST); final JBBox box = JBBox.createHorizontalBox(); box.add(panel); box.add(Box.createHorizontalGlue()); @@ -242,24 +493,35 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { protected void canRun() throws ConfigurationException { final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject); for (ParameterData parameterData : myParametersMap.values()) { - if (!nameHelper.isIdentifier(parameterData.getFieldName())) throw new ConfigurationException( - JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.field.name", parameterData.getFieldName())); - if (!nameHelper.isIdentifier(parameterData.getSetterName())) throw new ConfigurationException( - JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.setter.name", parameterData.getSetterName())); + if (!nameHelper.isIdentifier(parameterData.getFieldName())) { + throw new ConfigurationException( + JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.field.name", parameterData.getFieldName())); + } + if (!nameHelper.isIdentifier(parameterData.getSetterName())) { + throw new ConfigurationException( + JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.setter.name", parameterData.getSetterName())); + } } if (myCreateBuilderClassRadioButton.isSelected()) { final String className = myNewClassName.getText().trim(); if (className.isEmpty()) throw new ConfigurationException(null); - if (!nameHelper.isQualifiedName(className)) throw new ConfigurationException( - JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.class.name", className)); + if (!nameHelper.isQualifiedName(className)) { + throw new ConfigurationException( + JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.class.name", className)); + } final String packageName = myPackageTextField.getText().trim(); - if (!packageName.isEmpty() && !nameHelper.isQualifiedName(packageName)) throw new ConfigurationException( - JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.package.name", packageName)); - } else { + if (!packageName.isEmpty() && !nameHelper.isQualifiedName(packageName)) { + throw new ConfigurationException( + JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.package.name", packageName)); + } + } + else { final String qualifiedName = myExistentClassTF.getText().trim(); if (qualifiedName.isEmpty()) throw new ConfigurationException(null); - if (!nameHelper.isQualifiedName(qualifiedName)) throw new ConfigurationException( - JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.qualified.class.name", qualifiedName)); + if (!nameHelper.isQualifiedName(qualifiedName)) { + throw new ConfigurationException( + JavaRefactoringBundle.message("replace.constructor.builder.error.invalid.builder.qualified.class.name", qualifiedName)); + } } } @@ -303,47 +565,6 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog { private static final int DEFAULT_VALUE = 3; private static final int SKIP_SETTER = 4; - private void createUIComponents() { - final DocumentListener adapter = new DocumentListener() { - @Override - public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { - validateButtons(); - } - }; - - myPackageTextField = - new PackageNameReferenceEditorCombo(((PsiJavaFile)myConstructors[0].getContainingFile()).getPackageName(), myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package")); - myPackageTextField.getChildComponent().getDocument().addDocumentListener(adapter); - - myDestinationCb = new DestinationFolderComboBox() { - @Override - public String getTargetPackage() { - return myPackageTextField.getText().trim(); - } - }; - ((DestinationFolderComboBox)myDestinationCb).setData(myProject, myConstructors[0].getContainingFile().getContainingDirectory(), myPackageTextField.getChildComponent()); - - myExistentClassTF = new ReferenceEditorComboWithBrowseButton(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) - .createWithInnerClassesScopeChooser( - JavaRefactoringBundle.message("replace.constructor.builder.select.builder.class.chooser.title"), GlobalSearchScope.projectScope(myProject), null, null); - final String classText = myExistentClassTF.getText(); - final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); - if (currentClass != null) { - chooser.select(currentClass); - } - chooser.showDialog(); - final PsiClass selectedClass = chooser.getSelected(); - if (selectedClass != null) { - myExistentClassTF.setText(selectedClass.getQualifiedName()); - } - } - }, "", myProject, true, RECENT_KEYS); - myExistentClassTF.getChildComponent().getDocument().addDocumentListener(adapter); - } - private class MyTableModel extends AbstractTableModel { @Override diff --git a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java index d5afadae7bb7..6107fda9dc0f 100644 --- a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java +++ b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java @@ -32,20 +32,34 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.JavaCodeStyleSettings; import com.intellij.refactoring.JavaRefactoringSettings; import com.intellij.refactoring.ui.JavaVisibilityPanel; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SortedListModel; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Comparator; +import java.util.ResourceBundle; import java.util.function.Predicate; import static com.intellij.openapi.options.Configurable.isCheckboxModified; @@ -53,47 +67,388 @@ import static com.intellij.openapi.options.Configurable.isFieldModified; public class CodeStyleGenerationConfigurable implements CodeStyleConfigurable { private final JavaVisibilityPanel myJavaVisibilityPanel; - JPanel myPanel; - private JTextField myFieldPrefixField; - private JTextField myStaticFieldPrefixField; - private JTextField myParameterPrefixField; - private JTextField myLocalVariablePrefixField; + final JPanel myPanel; + private final JTextField myFieldPrefixField; + private final JTextField myStaticFieldPrefixField; + private final JTextField myParameterPrefixField; + private final JTextField myLocalVariablePrefixField; - private JTextField myFieldSuffixField; - private JTextField myStaticFieldSuffixField; - private JTextField myParameterSuffixField; - private JTextField myLocalVariableSuffixField; + private final JTextField myFieldSuffixField; + private final JTextField myStaticFieldSuffixField; + private final JTextField myParameterSuffixField; + private final JTextField myLocalVariableSuffixField; - private JCheckBox myCbPreferLongerNames; + private final JCheckBox myCbPreferLongerNames; private final CodeStyleSettings mySettings; - private JCheckBox myCbGenerateFinalParameters; - private JCheckBox myCbGenerateFinalLocals; - private JCheckBox myCbUseExternalAnnotations; - private JCheckBox myGenerateTypeAnnotationBeforeType; - private JCheckBox myInsertOverrideAnnotationCheckBox; - private JCheckBox myRepeatSynchronizedCheckBox; - private JPanel myVisibilityPanel; + private final JCheckBox myCbGenerateFinalParameters; + private final JCheckBox myCbGenerateFinalLocals; + private final JCheckBox myCbUseExternalAnnotations; + private final JCheckBox myGenerateTypeAnnotationBeforeType; + private final JCheckBox myInsertOverrideAnnotationCheckBox; + private final JCheckBox myRepeatSynchronizedCheckBox; + private final JPanel myVisibilityPanel; - @SuppressWarnings("unused") private JPanel myCommenterPanel; - private JPanel myOverridePanel; - private JBCheckBox myReplaceInstanceOfCb; - private JBCheckBox myReplaceNullCheckCb; - private JTextField myTestClassPrefix; - private JTextField myTestClassSuffix; - private JTextField mySubclassPrefix; - private JTextField mySubclassSuffix; - private JBCheckBox myReplaceSumCb; - private JCheckBox myCbDeclareVarType; + @SuppressWarnings("unused") private final JPanel myCommenterPanel; + private final JPanel myOverridePanel; + private final JBCheckBox myReplaceInstanceOfCb; + private final JBCheckBox myReplaceNullCheckCb; + private final JTextField myTestClassPrefix; + private final JTextField myTestClassSuffix; + private final JTextField mySubclassPrefix; + private final JTextField mySubclassSuffix; + private final JBCheckBox myReplaceSumCb; + private final JCheckBox myCbDeclareVarType; private CommenterForm myCommenterForm; private SortedListModel myRepeatAnnotationsModel; public CodeStyleGenerationConfigurable(CodeStyleSettings settings) { mySettings = settings; + { + myCommenterForm = new CommenterForm(JavaLanguage.INSTANCE); + myCommenterPanel = myCommenterForm.getCommenterPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBScrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 2, new Insets(0, 10, 15, 10), -1, -1)); + jBScrollPane1.setViewportView(panel1); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "title.naming"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCbPreferLongerNames = new JCheckBox(); + this.$$$loadButtonText$$$(myCbPreferLongerNames, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "checkbox.prefer.longer.names")); + panel2.add(myCbPreferLongerNames, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.parameter")); + panel3.add(label1, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.static.field")); + panel3.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.field")); + panel3.add(label3, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.local.variable")); + panel3.add(label4, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFieldPrefixField = new JTextField(); + myFieldPrefixField.setText(""); + panel3.add(myFieldPrefixField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myStaticFieldPrefixField = new JTextField(); + panel3.add(myStaticFieldPrefixField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myParameterPrefixField = new JTextField(); + panel3.add(myParameterPrefixField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myLocalVariablePrefixField = new JTextField(); + myLocalVariablePrefixField.setText(""); + panel3.add(myLocalVariablePrefixField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(60, -1), null, 0, false)); + myFieldSuffixField = new JTextField(); + panel3.add(myFieldSuffixField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myStaticFieldSuffixField = new JTextField(); + panel3.add(myStaticFieldSuffixField, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myParameterSuffixField = new JTextField(); + panel3.add(myParameterSuffixField, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + myLocalVariableSuffixField = new JTextField(); + panel3.add(myLocalVariableSuffixField, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(60, -1), null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.name.suffix")); + panel3.add(label5, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.name.prefix")); + panel3.add(label6, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.test.class")); + panel3.add(label7, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestClassPrefix = new JTextField(); + panel3.add(myTestClassPrefix, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTestClassSuffix = new JTextField(); + panel3.add(myTestClassSuffix, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label8 = new JLabel(); + this.$$$loadLabelText$$$(label8, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "label.naming.subclass")); + panel3.add(label8, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySubclassPrefix = new JTextField(); + panel3.add(mySubclassPrefix, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + mySubclassSuffix = new JTextField(); + panel3.add(mySubclassSuffix, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "title.naming.final.modifier"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCbGenerateFinalLocals = new JCheckBox(); + myCbGenerateFinalLocals.setMargin(new Insets(5, 10, 2, 2)); + this.$$$loadButtonText$$$(myCbGenerateFinalLocals, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "checkbox.make.generated.local.variables.final")); + panel4.add(myCbGenerateFinalLocals, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbGenerateFinalParameters = new JCheckBox(); + myCbGenerateFinalParameters.setMargin(new Insets(5, 10, 2, 2)); + this.$$$loadButtonText$$$(myCbGenerateFinalParameters, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "checkbox.make.generated.parameters.final")); + panel4.add(myCbGenerateFinalParameters, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel4.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myCbDeclareVarType = new JCheckBox(); + myCbDeclareVarType.setMargin(new Insets(5, 10, 2, 2)); + this.$$$loadButtonText$$$(myCbDeclareVarType, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "checkbox.declare.var.type")); + panel4.add(myCbDeclareVarType, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbUseExternalAnnotations = new JCheckBox(); + this.$$$loadButtonText$$$(myCbUseExternalAnnotations, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "use.external.annotations")); + panel1.add(myCbUseExternalAnnotations, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myOverridePanel = new JPanel(); + myOverridePanel.setLayout(new GridBagLayout()); + myOverridePanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(myOverridePanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myOverridePanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/JavaBundle", + "code.style.generation.override.method.signature"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myInsertOverrideAnnotationCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myInsertOverrideAnnotationCheckBox, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "insert.override.annotation")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + myOverridePanel.add(myInsertOverrideAnnotationCheckBox, gbc); + myRepeatSynchronizedCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myRepeatSynchronizedCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "code.style.generation.repeat.synchronized.modifier")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + myOverridePanel.add(myRepeatSynchronizedCheckBox, gbc); + myVisibilityPanel = new JPanel(); + myVisibilityPanel.setLayout(new BorderLayout(0, 0)); + myVisibilityPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(myVisibilityPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myVisibilityPanel.add(spacer3, BorderLayout.WEST); + myCommenterPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(myCommenterPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel5.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel5, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel5.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "title.naming.functional.expressions"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer4 = new Spacer(); + panel5.add(spacer4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myReplaceInstanceOfCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myReplaceInstanceOfCb, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "code.style.generation.use.class.isInstance")); + panel5.add(myReplaceInstanceOfCb, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myReplaceNullCheckCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myReplaceNullCheckCb, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "code.style.generation.replace.null.check")); + panel5.add(myReplaceNullCheckCb, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myReplaceSumCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myReplaceSumCb, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "code.style.generation.use.integer.sum")); + panel5.add(myReplaceSumCb, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myGenerateTypeAnnotationBeforeType = new JBCheckBox(); + this.$$$loadButtonText$$$(myGenerateTypeAnnotationBeforeType, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "generate.type.use.before.type")); + myGenerateTypeAnnotationBeforeType.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "generate.type.use.before.type.description")); + panel1.add(myGenerateTypeAnnotationBeforeType, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myPanel.setBorder(JBUI.Borders.empty(2)); myJavaVisibilityPanel = new JavaVisibilityPanel(false, true, JavaRefactoringBundle.message("default.visibility.border.title")); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent createComponent() { myVisibilityPanel.add(myJavaVisibilityPanel, BorderLayout.CENTER); @@ -103,7 +458,7 @@ public class CodeStyleGenerationConfigurable implements CodeStyleConfigurable { Predicate isApplicable = PsiClass::isAnnotationType; //noinspection Convert2Diamond myRepeatAnnotationsModel = new SortedListModel(Comparator.naturalOrder()); - myOverridePanel.add(SpecialAnnotationsUtil.createSpecialAnnotationsListControl(JavaBundle.message("separator.annotations.to.copy"), + myOverridePanel.add(SpecialAnnotationsUtil.createSpecialAnnotationsListControl(JavaBundle.message("separator.annotations.to.copy"), false, myRepeatAnnotationsModel, isApplicable), gc); return myPanel; } @@ -265,9 +620,4 @@ public class CodeStyleGenerationConfigurable implements CodeStyleConfigurable { public boolean isModified() { return isModified(mySettings); } - - private void createUIComponents() { - myCommenterForm = new CommenterForm(JavaLanguage.INSTANCE); - myCommenterPanel = myCommenterForm.getCommenterPanel(); - } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java index 7e9be5d210d1..4fd8f286a87c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java @@ -16,27 +16,35 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; public class LocateLibraryDialog extends DialogWrapper { private final List myDefaultLibraryPaths; - private JPanel myContentPane; - private TextFieldWithBrowseButton myCopyToDir; - private JBRadioButton myUseBundledRadioButton; - private JBRadioButton myCopyLibraryFilesRadioButton; + private final JPanel myContentPane; + private final TextFieldWithBrowseButton myCopyToDir; + private final JBRadioButton myUseBundledRadioButton; + private final JBRadioButton myCopyLibraryFilesRadioButton; private final Project myProject; private List myResultingLibraryPaths; @@ -44,8 +52,41 @@ public class LocateLibraryDialog extends DialogWrapper { public LocateLibraryDialog(@NotNull Module module, @NotNull List defaultLibraryPaths, final @NotNull @NonNls String presentableName) { - super (module.getProject(), true); + super(module.getProject(), true); myDefaultLibraryPaths = defaultLibraryPaths; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCopyToDir = new TextFieldWithBrowseButton(); + myContentPane.add(myCopyToDir, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 2, false)); + myUseBundledRadioButton = new JBRadioButton(); + myUseBundledRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myUseBundledRadioButton, + this.$$$getMessageFromBundle$$$("messages/QuickFixBundle", "add.library.use.bundled.library.radio.button")); + myContentPane.add(myUseBundledRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCopyLibraryFilesRadioButton = new JBRadioButton(); + this.$$$loadButtonText$$$(myCopyLibraryFilesRadioButton, + this.$$$getMessageFromBundle$$$("messages/QuickFixBundle", "add.library.copy.files.to.radio.button")); + myContentPane.add(myCopyLibraryFilesRadioButton, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myUseBundledRadioButton); + buttonGroup.add(myCopyLibraryFilesRadioButton); + } setTitle(QuickFixBundle.message("add.library.title.dialog", presentableName)); myProject = module.getProject(); @@ -79,6 +120,53 @@ public class LocateLibraryDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + public @NotNull List showAndGetResult() { if (ApplicationManager.getApplication().isHeadlessEnvironment()) { Disposer.dispose(myDisposable); @@ -146,7 +234,8 @@ public class LocateLibraryDialog extends DialogWrapper { } catch (IOException e) { Messages.showErrorDialog(myProject, - QuickFixBundle.message("add.library.error.cannot.copy", srcFile.getPath(), dstFile.getPath(), e.getMessage()), + QuickFixBundle.message("add.library.error.cannot.copy", srcFile.getPath(), dstFile.getPath(), + e.getMessage()), CommonBundle.getErrorTitle()); return Collections.emptyList(); } diff --git a/java/java-impl/src/com/intellij/cyclicDependencies/actions/CyclicDependenciesAction.java b/java/java-impl/src/com/intellij/cyclicDependencies/actions/CyclicDependenciesAction.java index 202cb3c6e36c..00a0c20a8fb8 100644 --- a/java/java-impl/src/com/intellij/cyclicDependencies/actions/CyclicDependenciesAction.java +++ b/java/java-impl/src/com/intellij/cyclicDependencies/actions/CyclicDependenciesAction.java @@ -24,14 +24,23 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiPackage; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class CyclicDependenciesAction extends AnAction{ private final String myAnalysisVerb; @@ -151,24 +160,119 @@ public class CyclicDependenciesAction extends AnAction{ private class ProjectModuleOrPackageDialog extends DialogWrapper { private final String myModuleName; private final AnalysisScope mySelectedScope; - private JRadioButton myProjectButton; - private JRadioButton myModuleButton; - private JRadioButton mySelectedScopeButton; + private final JRadioButton myProjectButton; + private final JRadioButton myModuleButton; + private final JRadioButton mySelectedScopeButton; - private JPanel myScopePanel; - private JPanel myWholePanel; - private JCheckBox myIncludeTestSourcesCb; + private final JPanel myScopePanel; + private final JPanel myWholePanel; + private final JCheckBox myIncludeTestSourcesCb; ProjectModuleOrPackageDialog(String moduleName, AnalysisScope selectedScope) { super(true); myModuleName = moduleName; mySelectedScope = selectedScope; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myScopePanel = new JPanel(); + myScopePanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(myScopePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, + null, null, 0, false)); + myScopePanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myProjectButton = new JRadioButton(); + myProjectButton.setText("###########"); + myScopePanel.add(myProjectButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myModuleButton = new JRadioButton(); + myModuleButton.setText("###########"); + myScopePanel.add(myModuleButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySelectedScopeButton = new JRadioButton(); + mySelectedScopeButton.setText("#############"); + myScopePanel.add(mySelectedScopeButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myIncludeTestSourcesCb = new JCheckBox(); + this.$$$loadButtonText$$$(myIncludeTestSourcesCb, this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "cyclic.dependencies.scope.include.test.sources.option")); + myWholePanel.add(myIncludeTestSourcesCb, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myProjectButton); + buttonGroup.add(myModuleButton); + buttonGroup.add(mySelectedScopeButton); + } init(); setTitle(JavaBundle.message("cyclic.dependencies.scope.dialog.title", myTitle)); setHorizontalStretch(1.75f); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + boolean isIncludeTestSources() { return myIncludeTestSourcesCb.isSelected(); } @@ -209,6 +313,5 @@ public class CyclicDependenciesAction extends AnAction{ public boolean isModuleScopeSelected() { return myModuleButton != null && myModuleButton.isSelected(); } - } } \ No newline at end of file diff --git a/java/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java b/java/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java index 4c0456383960..24c3a9f1b43c 100644 --- a/java/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java +++ b/java/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java @@ -50,12 +50,17 @@ import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.ui.BooleanTableCellRenderer; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.IconManager; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.PlatformIcons; import com.intellij.ui.ReferenceEditorWithBrowseButton; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.TreeTableSpeedSearch; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.dualView.TreeTableView; import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns; import com.intellij.ui.treeStructure.treetable.TreeColumnInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.tree.TreeUtil; @@ -67,17 +72,21 @@ import org.jetbrains.annotations.Nullable; import javax.swing.DefaultCellEditor; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTree; import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import javax.swing.tree.DefaultMutableTreeNode; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -85,16 +94,17 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; public final class MethodParameterPanel extends AbstractInjectionPanel { - LanguagePanel myLanguagePanel; // read by reflection - AdvancedPanel myAdvancedPanel; + final LanguagePanel myLanguagePanel; // read by reflection + final AdvancedPanel myAdvancedPanel; - private JPanel myRoot; - private JPanel myClassPanel; + private final JPanel myRoot; + private final JPanel myClassPanel; - private TreeTableView myParamsTable; + private final TreeTableView myParamsTable; private final ReferenceEditorWithBrowseButton myClassField; private DefaultMutableTreeNode myRootNode; @@ -103,7 +113,49 @@ public final class MethodParameterPanel extends AbstractInjectionPanel>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(myLanguagePanel.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), 0, 0)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myRoot.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "method.parameter.panel.class.methods"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myClassPanel = new JPanel(); + myClassPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myClassPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + jBScrollPane1.setViewportView(myParamsTable); + myRoot.add(myAdvancedPanel.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myClassField = new ReferenceEditorWithBrowseButton(new BrowseClassListener(project), project, s -> { final Document document = PsiUtilEx.createDocument(s, project); @@ -130,29 +182,32 @@ public final class MethodParameterPanel extends AbstractInjectionPanel { final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject(); - return userObject instanceof PsiNamedElement? ((PsiNamedElement)userObject).getName() : null; + return userObject instanceof PsiNamedElement ? ((PsiNamedElement)userObject).getName() : null; }); new AnAction(CommonBundle.message("action.text.toggle")) { @Override @@ -162,6 +217,28 @@ public final class MethodParameterPanel extends AbstractInjectionPanel thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + private void updateInjectionPanelTree() { updateTree(); } @@ -172,7 +249,9 @@ public final class MethodParameterPanel extends AbstractInjectionPanel { final PsiType classType = getClassType(); - final PsiClass[] classes = classType instanceof PsiClassType? JavaPsiFacade.getInstance(myProject). - findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(myProject)) : PsiClass.EMPTY_ARRAY; + final PsiClass[] classes = classType instanceof PsiClassType + ? JavaPsiFacade.getInstance(myProject). + findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(myProject)) + : PsiClass.EMPTY_ARRAY; if (classes.length == 0) return; final Set visitedSignatures = new HashSet<>(); for (PsiClass psiClass : classes) { @@ -281,7 +362,8 @@ public final class MethodParameterPanel extends AbstractInjectionPanel(" ") { // "" for the first column's name isn't a good idea - final BooleanTableCellRenderer myRenderer = new BooleanTableCellRenderer(); + new ColumnInfo(" ") { // "" for the first column's name isn't a good idea + final BooleanTableCellRenderer myRenderer = new BooleanTableCellRenderer(); - @Override - public Boolean valueOf(DefaultMutableTreeNode o) { - return isNodeSelected(o); - } + @Override + public Boolean valueOf(DefaultMutableTreeNode o) { + return isNodeSelected(o); + } - @Override - public int getWidth(JTable table) { - return myRenderer.getPreferredSize().width; - } + @Override + public int getWidth(JTable table) { + return myRenderer.getPreferredSize().width; + } - @Override - public TableCellEditor getEditor(DefaultMutableTreeNode o) { - return new DefaultCellEditor(new JCheckBox()); - } + @Override + public TableCellEditor getEditor(DefaultMutableTreeNode o) { + return new DefaultCellEditor(new JCheckBox()); + } - @Override - public TableCellRenderer getRenderer(DefaultMutableTreeNode o) { - myRenderer.setEnabled(isCellEditable(o)); - return myRenderer; - } + @Override + public TableCellRenderer getRenderer(DefaultMutableTreeNode o) { + myRenderer.setEnabled(isCellEditable(o)); + return myRenderer; + } - @Override - public void setValue(DefaultMutableTreeNode o, Boolean value) { - setNodeSelected(o, Boolean.TRUE.equals(value)); - } + @Override + public void setValue(DefaultMutableTreeNode o, Boolean value) { + setNodeSelected(o, Boolean.TRUE.equals(value)); + } - @Override - public Class getColumnClass() { - return Boolean.class; - } + @Override + public Class getColumnClass() { + return Boolean.class; + } - @Override - public boolean isCellEditable(DefaultMutableTreeNode o) { - return valueOf(o) != null; - } - - }, new TreeColumnInfo(" ") + @Override + public boolean isCellEditable(DefaultMutableTreeNode o) { + return valueOf(o) != null; + } + }, new TreeColumnInfo(" ") }; } @@ -419,8 +495,4 @@ public final class MethodParameterPanel extends AbstractInjectionPanel>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myAccountPanelPlaceHolder = new JPanel(); + myAccountPanelPlaceHolder.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myAccountPanelPlaceHolder, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/CloudBundle", "CloudModuleWizardStep.title.account")); + myMainPanel.add(titledSeparator1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator2 = new TitledSeparator(); + titledSeparator2.setText(this.$$$getMessageFromBundle$$$("messages/CloudBundle", "CloudModuleWizardStep.title.application")); + myMainPanel.add(titledSeparator2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myApplicationPanelPlaceHolder = new JPanel(); + myApplicationPanelPlaceHolder.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myApplicationPanelPlaceHolder, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + } myApplicationConfigurableTypes = new HashSet<>(); @@ -65,6 +107,28 @@ public class CloudModuleWizardStep extends ModuleWizardStep { onAccountSelectionChanged(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private RemoteServer getSelectedAccount() { return myAccountSelectionPanel.getSelectedAccount(); } diff --git a/java/unscramble/src/com/intellij/unscramble/UnscrambleDialog.java b/java/unscramble/src/com/intellij/unscramble/UnscrambleDialog.java index 074baeecdf1a..6a989decaac3 100644 --- a/java/unscramble/src/com/intellij/unscramble/UnscrambleDialog.java +++ b/java/unscramble/src/com/intellij/unscramble/UnscrambleDialog.java @@ -23,6 +23,8 @@ import com.intellij.threadDumpParser.ThreadState; import com.intellij.ui.GuiUtils; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.TextFieldWithHistory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.ApiStatus; @@ -32,17 +34,24 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; import javax.swing.AbstractAction; +import javax.swing.AbstractButton; import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRootPane; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; @ApiStatus.Internal public class UnscrambleDialog extends DialogWrapper { @@ -52,22 +61,102 @@ public class UnscrambleDialog extends DialogWrapper { private final Project myProject; - private JPanel myEditorPanel; - private JPanel myLogFileChooserPanel; - private JComboBox myUnscrambleChooser; - private JPanel myPanel; + private final JPanel myEditorPanel; + private final JPanel myLogFileChooserPanel; + private final JComboBox myUnscrambleChooser; + private final JPanel myPanel; private TextFieldWithHistory myLogFile; - private JCheckBox myUseUnscrambler; - private JPanel myUnscramblePanel; - private JCheckBox myOnTheFly; - private JPanel myBottomPanel; - private JPanel mySettingsPanel; + private final JCheckBox myUseUnscrambler; + private final JPanel myUnscramblePanel; + private final JCheckBox myOnTheFly; + private final JPanel myBottomPanel; + private final JPanel mySettingsPanel; protected AnalyzeStacktraceUtil.StacktraceEditorPanel myStacktraceEditorPanel; private VcsContentAnnotationConfigurable myConfigurable; public UnscrambleDialog(@NotNull Project project) { super(false); myProject = project; + { + myBottomPanel = new JPanel(new BorderLayout()); + if (ProjectLevelVcsManager.getInstance(myProject).hasActiveVcss()) { + myConfigurable = new VcsContentAnnotationConfigurable(myProject); + myBottomPanel.add(myConfigurable.createComponent(), BorderLayout.CENTER); + myConfigurable.reset(); + } + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myEditorPanel = new JPanel(); + myPanel.add(myEditorPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "unscramble.stacktrace.caption")); + myPanel.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUnscramblePanel = new JPanel(); + myUnscramblePanel.setLayout(new GridLayoutManager(4, 2, new Insets(5, 5, 5, 5), -1, -1)); + myPanel.add(myUnscramblePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUnscramblePanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "unscramble.unscrambler.combobox")); + myUnscramblePanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myUnscrambleChooser = new JComboBox(); + myUnscramblePanel.add(myUnscrambleChooser, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaBundle", "unscramble.log.path.label")); + myUnscramblePanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myLogFileChooserPanel = new JPanel(); + myUnscramblePanel.add(myLogFileChooserPanel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseUnscrambler = new JCheckBox(); + myUseUnscrambler.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(myUseUnscrambler, + this.$$$getMessageFromBundle$$$("messages/JavaBundle", "unscramble.use.unscrambler.checkbox")); + myUnscramblePanel.add(myUseUnscrambler, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mySettingsPanel = new JPanel(); + mySettingsPanel.setLayout(new BorderLayout(0, 0)); + myUnscramblePanel.add(mySettingsPanel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myOnTheFly = new JCheckBox(); + myOnTheFly.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(myOnTheFly, this.$$$getMessageFromBundle$$$("messages/JavaBundle", + "unscramble.detect.analyze.threaddump.from.clipboard.item")); + myPanel.add(myOnTheFly, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPanel.add(myBottomPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + label2.setLabelFor(myUnscrambleChooser); + label3.setLabelFor(myLogFileChooserPanel); + } populateRegisteredUnscramblerList(); myUnscrambleChooser.addActionListener(new ActionListener() { @@ -99,6 +188,78 @@ public class UnscrambleDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void useUnscramblerChanged() { boolean selected = myUseUnscrambler.isSelected(); GuiUtils.enableChildren(myUnscramblePanel, selected, myUseUnscrambler); @@ -138,7 +299,8 @@ public class UnscrambleDialog extends DialogWrapper { if (selectedUnscrambler != null) { for (int i = 0; i < count; i++) { final UnscrambleSupport unscrambleSupport = myUnscrambleChooser.getItemAt(i); - if (unscrambleSupport != null && Comparing.strEqual(unscrambleSupport.getPresentableName(), selectedUnscrambler.getPresentableName())) { + if (unscrambleSupport != null && + Comparing.strEqual(unscrambleSupport.getPresentableName(), selectedUnscrambler.getPresentableName())) { index = i; break; } @@ -158,15 +320,6 @@ public class UnscrambleDialog extends DialogWrapper { myStacktraceEditorPanel.pasteTextFromClipboard(); } - private void createUIComponents() { - myBottomPanel = new JPanel(new BorderLayout()); - if (ProjectLevelVcsManager.getInstance(myProject).hasActiveVcss()) { - myConfigurable = new VcsContentAnnotationConfigurable(myProject); - myBottomPanel.add(myConfigurable.createComponent(), BorderLayout.CENTER); - myConfigurable.reset(); - } - } - private @Nullable UnscrambleSupport getSavedUnscrambler() { final String savedUnscramblerName = getPropertyValue(PROPERTY_UNSCRAMBLER_NAME_USED); UnscrambleSupport selectedUnscrambler = null; @@ -220,7 +373,8 @@ public class UnscrambleDialog extends DialogWrapper { @Override public void actionPerformed(ActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); - FileChooser.chooseFiles(descriptor, myProject, null, files -> myLogFile.setText(FileUtil.toSystemDependentName(files.getLast().getPath()))); + FileChooser.chooseFiles(descriptor, myProject, null, + files -> myLogFile.setText(FileUtil.toSystemDependentName(files.getLast().getPath()))); } }); myLogFileChooserPanel.setLayout(new BorderLayout()); @@ -242,9 +396,10 @@ public class UnscrambleDialog extends DialogWrapper { @Override public void dispose() { - if (isOK()){ + if (isOK()) { final List list = myLogFile.getHistory(); - PropertiesComponent.getInstance().setValue(PROPERTY_LOG_FILE_HISTORY_URLS, list.isEmpty() ? null : StringUtil.join(list, ":::"), null); + PropertiesComponent.getInstance() + .setValue(PROPERTY_LOG_FILE_HISTORY_URLS, list.isEmpty() ? null : StringUtil.join(list, ":::"), null); UnscrambleSupport selectedUnscrambler = getSelectedUnscrambler(); saveProperty(PROPERTY_UNSCRAMBLER_NAME_USED, selectedUnscrambler == null ? null : selectedUnscrambler.getPresentableName()); saveProperty(PROPERTY_LOG_FILE_LAST_URL, StringUtil.nullize(myLogFile.getText())); @@ -253,7 +408,7 @@ public class UnscrambleDialog extends DialogWrapper { } // IDEA-125302 The Analyze Stacktrace menu option remembers only one log file across multiple projects - private void saveProperty(@NotNull String name, @Nullable String value) { + private void saveProperty(@NotNull String name, @Nullable String value) { PropertiesComponent.getInstance(myProject).setValue(name, value); PropertiesComponent.getInstance().setValue(name, value); } @@ -275,13 +430,13 @@ public class UnscrambleDialog extends DialogWrapper { } private final class NormalizeTextAction extends AbstractAction { - NormalizeTextAction(){ + NormalizeTextAction() { putValue(NAME, JavaBundle.message("unscramble.normalize.button")); putValue(DialogWrapper.DEFAULT_ACTION, Boolean.FALSE); } @Override - public void actionPerformed(ActionEvent e){ + public void actionPerformed(ActionEvent e) { String text = myStacktraceEditorPanel.getText(); myStacktraceEditorPanel.setText(ThreadDumpParser.normalizeText(text)); } @@ -308,18 +463,19 @@ public class UnscrambleDialog extends DialogWrapper { @VisibleForTesting public static @Nullable RunContentDescriptor showUnscrambledText(@Nullable UnscrambleSupport unscrambleSupport, - String logName, - @Nullable T settings, - Project project, - String textToUnscramble) { - String unscrambledTrace = unscrambleSupport == null ? textToUnscramble : unscrambleSupport.unscramble(project,textToUnscramble, logName, settings); + String logName, + @Nullable T settings, + Project project, + String textToUnscramble) { + String unscrambledTrace = + unscrambleSupport == null ? textToUnscramble : unscrambleSupport.unscramble(project, textToUnscramble, logName, settings); if (unscrambledTrace == null) return null; List threadStates = ThreadDumpParser.parse(unscrambledTrace); return UnscrambleUtils.addConsole(project, threadStates, unscrambledTrace); } @Override - protected String getDimensionServiceKey(){ + protected String getDimensionServiceKey() { return "#com.intellij.unscramble.UnscrambleDialog"; } } diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/settings/DiffColorDescriptionPanel.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/settings/DiffColorDescriptionPanel.java index 27a66f6bc0a9..7301c771477e 100644 --- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/settings/DiffColorDescriptionPanel.java +++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/settings/DiffColorDescriptionPanel.java @@ -12,33 +12,88 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.ui.ColorPanel; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; class DiffColorDescriptionPanel extends JPanel implements OptionsPanelImpl.ColorDescriptionPanel { private final EventDispatcher myDispatcher = EventDispatcher.create(Listener.class); - private JPanel myPanel; + private final JPanel myPanel; - private ColorPanel myBackgroundColorPanel; - private ColorPanel myIgnoredColorPanel; - private ColorPanel myStripeMarkColorPanel; - private JBCheckBox myInheritIgnoredCheckBox; + private final ColorPanel myBackgroundColorPanel; + private final ColorPanel myIgnoredColorPanel; + private final ColorPanel myStripeMarkColorPanel; + private final JBCheckBox myInheritIgnoredCheckBox; private final @NotNull ColorAndFontOptions myOptions; DiffColorDescriptionPanel(@NotNull ColorAndFontOptions options) { super(new BorderLayout()); myOptions = options; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 10, 10, 10), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/DiffBundle", "merge.color.options.background.color.label")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBackgroundColorPanel = new ColorPanel(); + myPanel.add(myBackgroundColorPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.color.error.stripe.mark")); + myPanel.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myStripeMarkColorPanel = new ColorPanel(); + myPanel.add(myStripeMarkColorPanel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/DiffBundle", "merge.color.options.ignored.color.label")); + myPanel.add(label3, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIgnoredColorPanel = new ColorPanel(); + myPanel.add(myIgnoredColorPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myInheritIgnoredCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myInheritIgnoredCheckBox, + this.$$$getMessageFromBundle$$$("messages/DiffBundle", "option.inherit.ignored.color")); + myPanel.add(myInheritIgnoredCheckBox, + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } add(myPanel, BorderLayout.CENTER); myBackgroundColorPanel.addActionListener(this::onSettingsChanged); @@ -64,6 +119,78 @@ class DiffColorDescriptionPanel extends JPanel implements OptionsPanelImpl.Color }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull JComponent getPanel() { return this; diff --git a/platform/execution-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java b/platform/execution-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java index 6924f423e906..c8d10b161423 100644 --- a/platform/execution-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java +++ b/platform/execution-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java @@ -10,30 +10,142 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.NlsSafe; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.UIBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public final class EditLogPatternDialog extends DialogWrapper { - private JPanel myWholePanel; - private JTextField myNameField; - private JCheckBox myShowFilesCombo; - private TextFieldWithBrowseButton myFilePattern; + private final JPanel myWholePanel; + private final JTextField myNameField; + private final JCheckBox myShowFilesCombo; + private final TextFieldWithBrowseButton myFilePattern; public EditLogPatternDialog() { super(true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/DiagnosticBundle", "log.monitor.edit.aliases.name")); + myWholePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myNameField = new JTextField(); + myWholePanel.add(myNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/DiagnosticBundle", "log.monitor.edit.aliases.location")); + myWholePanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFilePattern = new TextFieldWithBrowseButton(); + myWholePanel.add(myFilePattern, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myShowFilesCombo = new JCheckBox(); + this.$$$loadButtonText$$$(myShowFilesCombo, this.$$$getMessageFromBundle$$$("messages/DiagnosticBundle", + "log.monitor.edit.aliases.show.all.checkbox.title")); + myWholePanel.add(myShowFilesCombo, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myNameField); + } setTitle(DiagnosticBundle.message("log.monitor.edit.aliases.title")); init(); } - public void init(@NlsSafe String name, @NlsSafe String pattern, boolean showAll){ + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + + public void init(@NlsSafe String name, @NlsSafe String pattern, boolean showAll) { myNameField.setText(name); myFilePattern.setText(pattern); myShowFilesCombo.setSelected(showAll); @@ -42,7 +154,8 @@ public final class EditLogPatternDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - var descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor().withTitle(UIBundle.message("file.chooser.default.title")); + var descriptor = + FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor().withTitle(UIBundle.message("file.chooser.default.title")); myFilePattern.addBrowseFolderListener(null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override @@ -62,15 +175,15 @@ public final class EditLogPatternDialog extends DialogWrapper { return myShowFilesCombo.isSelected(); } - public String getName(){ + public String getName() { final String name = myNameField.getText(); - if (name != null && !name.isEmpty()){ + if (name != null && !name.isEmpty()) { return name; } return myFilePattern.getText(); } - public String getLogPattern(){ + public String getLogPattern() { return myFilePattern.getText(); } diff --git a/platform/execution-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java b/platform/execution-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java index 5d31871b14e3..c174cfc5a9b6 100644 --- a/platform/execution-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java +++ b/platform/execution-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java @@ -15,10 +15,13 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.BooleanTableCellRenderer; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.table.TableView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.SmartList; import com.intellij.util.ui.AbstractTableCellEditor; import com.intellij.util.ui.CellEditorComponentWithBrowseButton; @@ -26,11 +29,13 @@ import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; @@ -40,25 +45,74 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.FontMetrics; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; public final class LogConfigurationPanel extends SettingsEditor { private final TableView myFilesTable; private final ListTableModel myModel; - private JPanel myWholePanel; - private JPanel myScrollPanel; - private JBCheckBox myRedirectOutputCb; - private TextFieldWithBrowseButton myOutputFile; - private JCheckBox myShowConsoleOnStdOutCb; - private JCheckBox myShowConsoleOnStdErrCb; + private final JPanel myWholePanel; + private final JPanel myScrollPanel; + private final JBCheckBox myRedirectOutputCb; + private final TextFieldWithBrowseButton myOutputFile; + private final JCheckBox myShowConsoleOnStdOutCb; + private final JCheckBox myShowConsoleOnStdErrCb; private final Map myLog2Predefined = new HashMap<>(); private final List myUnresolvedPredefined = new SmartList<>(); public LogConfigurationPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, 10)); + myWholePanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myWholePanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/DiagnosticBundle", "log.monitor.group"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + myScrollPanel = new JPanel(); + myScrollPanel.setLayout(new BorderLayout(0, 0)); + myWholePanel.add(myScrollPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + new Dimension(-1, 150), null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRedirectOutputCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myRedirectOutputCb, + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "save.output.console.to.file")); + panel1.add(myRedirectOutputCb, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputFile = new TextFieldWithBrowseButton(); + panel1.add(myOutputFile, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myShowConsoleOnStdOutCb = new JCheckBox(); + this.$$$loadButtonText$$$(myShowConsoleOnStdOutCb, + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "logs.show.console.on.stdout")); + myWholePanel.add(myShowConsoleOnStdOutCb, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myShowConsoleOnStdErrCb = new JCheckBox(); + this.$$$loadButtonText$$$(myShowConsoleOnStdErrCb, + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "logs.show.console.on.stderr")); + myWholePanel.add(myShowConsoleOnStdErrCb, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } ColumnInfo IS_SHOW = new MyIsActiveColumnInfo(); ColumnInfo FILE = new MyLogFileColumnInfo(); ColumnInfo IS_SKIP_CONTENT = new MyIsSkipColumnInfo(); @@ -113,7 +167,8 @@ public final class LogConfigurationPanel extends if (selection >= 0) { myFilesTable.setRowSelectionInterval(selection, selection); } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myFilesTable, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myFilesTable, true)); }).setEditAction(button -> { final int selectedRow = myFilesTable.getSelectedRow(); //noinspection ConstantConditions @@ -121,9 +176,9 @@ public final class LogConfigurationPanel extends myModel.fireTableDataChanged(); myFilesTable.setRowSelectionInterval(selectedRow, selectedRow); }).setRemoveActionUpdater(e -> myFilesTable.getSelectedRowCount() >= 1 && - !myLog2Predefined.containsKey(myFilesTable.getSelectedObject())).setEditActionUpdater( - e -> myFilesTable.getSelectedRowCount() >= 1 && - !myLog2Predefined.containsKey(myFilesTable.getSelectedObject()) && + !myLog2Predefined.containsKey(myFilesTable.getSelectedObject())).setEditActionUpdater( + e -> myFilesTable.getSelectedRowCount() >= 1 && + !myLog2Predefined.containsKey(myFilesTable.getSelectedObject()) && myFilesTable.getSelectedObject() != null).disableUpDownActions().createPanel(), BorderLayout.CENTER); myWholePanel.setPreferredSize(new Dimension(-1, 150)); @@ -134,6 +189,53 @@ public final class LogConfigurationPanel extends myRedirectOutputCb.addActionListener(e -> myOutputFile.setEnabled(myRedirectOutputCb.isSelected())); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + private void setUpColumnWidth(final JTableHeader tableHeader, final int preferredWidth, int columnIdx) { myFilesTable.getColumnModel().getColumn(columnIdx).setCellRenderer(new BooleanTableCellRenderer()); final TableColumn tableColumn = tableHeader.getColumnModel().getColumn(columnIdx); diff --git a/platform/execution-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java b/platform/execution-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java index 10a903430ffe..c3b644244f70 100644 --- a/platform/execution-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java +++ b/platform/execution-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java @@ -24,7 +24,10 @@ import com.intellij.openapi.util.NlsContexts.TabTitle; import com.intellij.openapi.util.Pair; import com.intellij.ui.ScrollingUtil; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.update.Activatable; @@ -42,6 +45,8 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -250,15 +255,35 @@ public final class ConfigurationSettingsEditor extends CompositeSettingsEditor myRunnersList; - private JPanel myRunnerPanel; + private final JList myRunnersList; + private final JPanel myRunnerPanel; private final CardLayout myLayout = new CardLayout(); private final DefaultListModel myListModel = new DefaultListModel<>(); private final JLabel myNoRunner = new JLabel(ExecutionBundle.message("run.configuration.no.runner.selected.label")); - private JPanel myRunnersPanel; - private JBScrollPane myScrollPane; + private final JPanel myRunnersPanel; + private final JBScrollPane myScrollPane; RunnersEditorComponent() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRunnersPanel = new JPanel(); + myRunnersPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myScrollPane = new JBScrollPane(); + myRunnersPanel.add(myScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(-1, 50), null, 1, false)); + myRunnersList = new JBList(); + myRunnersList.setSelectionMode(0); + myScrollPane.setViewportView(myRunnersList); + myRunnerPanel = new JPanel(); + myRunnersPanel.add(myRunnerPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myRunnerPanel.setLayout(myLayout); myRunnerPanel.add(myNoRunner, NO_RUNNER_COMPONENT); myRunnersList.setModel(myListModel); @@ -278,6 +303,9 @@ public final class ConfigurationSettingsEditor extends CompositeSettingsEditor extends BaseRCSettingsConfigurable { @@ -450,27 +458,109 @@ public final class SingleConfigurationConfigurable>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 5, new Insets(0, 5, 3, 0), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", + "edit.run.configuration.run.configuration.name.label")); + panel1.add(myNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameText = new JTextField(); + myNameText.setColumns(15); + panel1.add(myNameText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIsAllowRunningInParallelCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myIsAllowRunningInParallelCheckBox, this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", + "run.configuration.allow.running.parallel.tag")); + panel1.add(myIsAllowRunningInParallelCheckBox, + new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(20, -1), new Dimension(20, -1), null, 0, + false)); + myRCStoragePanel = new JPanel(); + myRCStoragePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5)); + panel1.add(myRCStoragePanel, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myJBScrollPane.setHorizontalScrollBarPolicy(31); + myWholePanel.add(myJBScrollPane, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myJBScrollPane.setViewportView(myComponentPlace); + myRunOnPanel = new JPanel(); + myRunOnPanel.setLayout(new GridBagLayout()); + myWholePanel.add(myRunOnPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, + null, null, 0, false)); + myValidationPanel = new JPanel(); + myValidationPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(myValidationPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myWarningLabel = new JBLabel(); + myWarningLabel.setText("####################"); + myValidationPanel.add(myWarningLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(10, -1), new Dimension(10, -1), null, 0, false)); + myFixButton = new JButton(); + this.$$$loadButtonText$$$(myFixButton, + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "fix.run.configuration.problem.button")); + myValidationPanel.add(myFixButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySeparator = new JSeparator(); + myValidationPanel.add(mySeparator, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, + null, 0, false)); + myNameLabel.setLabelFor(myNameText); + } myNameLabel.setLabelFor(myNameText); myNameText.setDocument(myNameDocument); @@ -514,6 +604,78 @@ public final class SingleConfigurationConfigurable thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + private void doReset() { RunConfiguration configuration = getSettings().getConfiguration(); boolean isManagedRunConfiguration = configuration.getType().isManaged(); @@ -571,11 +733,6 @@ public final class SingleConfigurationConfigurable myTreeModel; - private ComboBox projectCombobox; + private final ComboBox projectCombobox; private final @NotNull ExternalSystemUiAware uiAware; private RootNode myRootNode; @@ -86,6 +91,30 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { super(project, true); myProject = project; myProjectSystemId = externalSystemId; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new BorderLayout(10, 10)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, BorderLayout.NORTH); + projectFieldPanel = new JPanel(); + projectFieldPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(projectFieldPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + projectCombobox = new ComboBox(); + projectFieldPanel.add(projectCombobox, BorderLayout.CENTER); + tasksPanel = new JPanel(); + tasksPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(tasksPanel, new GridConstraints(1, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(300, 300), null, null, 0, false)); + } uiAware = ExternalSystemUiUtil.getUiAware(myProjectSystemId); setUpDialog(projectPath); setModal(true); @@ -94,6 +123,9 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { myTaskActivator = ExternalProjectsManagerImpl.getInstance(myProject).getTaskActivator(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + @Override protected Action @NotNull [] createActions() { return new Action[]{getOKAction()}; @@ -104,7 +136,9 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { //noinspection unchecked Collection projectsSettings = externalSystemSettings.getLinkedProjectsSettings(); List projects = ContainerUtil.map(projectsSettings, - settings -> new ProjectItem(uiAware.getProjectRepresentationName(settings.getExternalProjectPath(), null), settings)); + settings -> new ProjectItem( + uiAware.getProjectRepresentationName(settings.getExternalProjectPath(), null), + settings)); myTree = new SimpleTree(); myRootNode = new RootNode(); @@ -130,7 +164,7 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree). setAddAction(button -> { ProjectItem projectItem = (ProjectItem)projectCombobox.getSelectedItem(); - if(projectItem == null) return; + if (projectItem == null) return; final ExternalProjectInfo projectData = ProjectDataManager.getInstance() .getExternalProjectData(myProject, myProjectSystemId, projectItem.myProjectSettings.getExternalProjectPath()); @@ -140,7 +174,7 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { final List popupItems = new ArrayList<>(); for (DataNode moduleDataNode : ExternalSystemApiUtil .findAllRecursively(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) { - if(moduleDataNode.isIgnored()) continue; + if (moduleDataNode.isIgnored()) continue; final List tasks = ContainerUtil.map( ExternalSystemApiUtil.findAll(moduleDataNode, ProjectKeys.TASK), node -> node.getData().getName()); @@ -277,7 +311,9 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { private MyNode[] buildProjectPhasesNodes(final String projectPath, final TaskActivationState tasksActivation, final MyNode parent) { - return ContainerUtil.mapNotNull(Phase.values(), phase -> tasksActivation.getTasks(phase).isEmpty() ? null : new PhaseNode(projectPath, phase, tasksActivation, parent), new MyNode[]{}); + return ContainerUtil.mapNotNull(Phase.values(), phase -> tasksActivation.getTasks(phase).isEmpty() + ? null + : new PhaseNode(projectPath, phase, tasksActivation, parent), new MyNode[]{}); } private static class ProjectItem { @@ -438,7 +474,7 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { @Override protected MyNode[] buildChildren() { ProjectItem item = (ProjectItem)projectCombobox.getSelectedItem(); - if(item == null) return new MyNode[]{}; + if (item == null) return new MyNode[]{}; if (item.myProjectSettings.getModules().isEmpty() || item.myProjectSettings.getModules().size() == 1) { final TaskActivationState tasksActivation = myStateProvider.getTasksActivation(myProjectSystemId, item.myProjectSettings.getExternalProjectPath()); @@ -457,9 +493,9 @@ public final class ConfigureTasksActivationDialog extends DialogWrapper { private final String myProjectName; ProjectNode(RootNode parent, - ExternalProjectsStateProvider stateProvider, - String rootProjectPath, - String projectPath) { + ExternalProjectsStateProvider stateProvider, + String rootProjectPath, + String projectPath) { super(parent); myStateProvider = stateProvider; myProjectPath = projectPath; diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalProjectDataSelectorDialog.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalProjectDataSelectorDialog.java index 5bcc0ed6fa06..c9d3725d8588 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalProjectDataSelectorDialog.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalProjectDataSelectorDialog.java @@ -59,6 +59,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeModel; @@ -66,6 +67,8 @@ import javax.swing.tree.TreeModel; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; @@ -74,6 +77,7 @@ import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; import java.util.TreeMap; @@ -88,11 +92,11 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { com.intellij.openapi.util.Key.create("connectedUiNode"); private final @NotNull Project myProject; private JBLoadingPanel loadingPanel; - private JPanel mainPanel; - private JPanel contentPanel; + private final JPanel mainPanel; + private final JPanel contentPanel; @SuppressWarnings("unused") - private JBLabel myDescriptionLbl; - private JBLabel mySelectionStatusLbl; + private final JBLabel myDescriptionLbl; + private final JBLabel mySelectionStatusLbl; private ExternalSystemUiAware myExternalSystemUiAware; private ExternalProjectInfo myProjectInfo; private final Set> myIgnorableKeys; @@ -119,6 +123,29 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { @Nullable Object preselectedNodeDataObject) { super(project, true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(5, 5)); + mainPanel.setEnabled(true); + mainPanel.setMinimumSize(new Dimension(300, 100)); + mainPanel.setOpaque(false); + mainPanel.setPreferredSize(new Dimension(400, 300)); + contentPanel = new JPanel(); + contentPanel.setLayout(new BorderLayout(0, 0)); + contentPanel.setAutoscrolls(true); + contentPanel.setMinimumSize(new Dimension(0, 0)); + contentPanel.setPreferredSize(new Dimension(0, 0)); + mainPanel.add(contentPanel, BorderLayout.CENTER); + mySelectionStatusLbl = new JBLabel(); + contentPanel.add(mySelectionStatusLbl, BorderLayout.SOUTH); + myDescriptionLbl = new JBLabel(); + this.$$$loadLabelText$$$(myDescriptionLbl, this.$$$getMessageFromBundle$$$("messages/ExternalSystemBundle", + "label.please.select.the.modules.data.to.include.in.the.project")); + mainPanel.add(myDescriptionLbl, BorderLayout.NORTH); + } myIgnorableKeys = getIgnorableKeys(); myPublicKeys = getPublicKeys(); myDependencyAwareDataKeys = getDependencyAwareDataKeys(); @@ -126,6 +153,53 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { init(projectInfo); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + private void init(@NotNull ExternalProjectInfo projectInfo) { myProjectInfo = projectInfo; myExternalSystemUiAware = ExternalSystemUiUtil.getUiAware(myProjectInfo.getProjectSystemId()); @@ -267,7 +341,8 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { }, "
    "); if (StringUtil.isNotEmpty(listOfUncheckedDependencies)) { hasErrors = true; - tooltip = ExternalSystemBundle.message("there.are.not.selected.module.dependencies.of.the.module.br.b.0.b", listOfUncheckedDependencies); + tooltip = ExternalSystemBundle.message("there.are.not.selected.module.dependencies.of.the.module.br.b.0.b", + listOfUncheckedDependencies); } } } @@ -353,12 +428,13 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { } String ideGrouping = moduleData.getIdeGrouping(); ideGroupingMap.put(ideGrouping, node); - } else { + } + else { // add elements under module node like web/enterprise artifacts DataNode parentModule = node.getParent(ModuleData.class); - if(parentModule != null) { + if (parentModule != null) { DataNodeCheckedTreeNode moduleTreeNode = treeNodeMap.get(parentModule); - if(moduleTreeNode != null) { + if (moduleTreeNode != null) { moduleTreeNode.add(treeNode); treeNode.setParent(moduleTreeNode); } @@ -515,7 +591,8 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { if (moduleNode != null) { moduleNode.isChecked = true; } - ExternalSystemApiUtil.visit(moduleNode == null ? myDataNode : moduleNode.myDataNode, node -> getModifiableDataNode(node).setIgnored(false)); + ExternalSystemApiUtil.visit(moduleNode == null ? myDataNode : moduleNode.myDataNode, + node -> getModifiableDataNode(node).setIgnored(false)); } else { ExternalSystemApiUtil.visit(myDataNode, node -> getModifiableDataNode(node).setIgnored(true)); @@ -601,13 +678,15 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { } } - private @Nls String getEnableMessage(List> selectedModules, Set> deps) { + private @Nls String getEnableMessage(List> selectedModules, + Set> deps) { if (deps.size() > MAX_DEPENDENCIES_TO_DESCRIBE || selectedModules.size() > MAX_DEPENDENCIES_TO_DESCRIBE) { return ExternalSystemBundle.message("enable.dependant.modules.max.message", deps.size(), selectedModules.size()); } final String listOfSelectedModules = StringUtil.join(selectedModules, node -> node.getData().getId(), ", "); final String listOfDependencies = StringUtil.join(deps, node -> node.getData().getId(), "
    "); - return ExternalSystemBundle.message("enable.dependant.modules.message", deps.size(), listOfSelectedModules, selectedModules.size(), listOfDependencies); + return ExternalSystemBundle.message("enable.dependant.modules.message", deps.size(), listOfSelectedModules, selectedModules.size(), + listOfDependencies); } private @Nls String getDisableMessage(Set> deps) { @@ -800,9 +879,10 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper { @Override public boolean showAndGet() { final BooleanValueHolder result = new BooleanValueHolder(false); - UnindexedFilesScannerExecutor.getInstance(myProject).suspendScanningAndIndexingThenRun(ExternalSystemBundle.message("activity.name.select.external.data"), - () -> result.setValue(super.showAndGet()) - ); + UnindexedFilesScannerExecutor.getInstance(myProject) + .suspendScanningAndIndexingThenRun(ExternalSystemBundle.message("activity.name.select.external.data"), + () -> result.setValue(super.showAndGet()) + ); return result.getValue(); } } diff --git a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java index 38e48d23668b..3157739fbbea 100644 --- a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java +++ b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java @@ -8,6 +8,9 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.NlsContexts; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,21 +20,24 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.FontMetrics; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev -*/ + */ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurable { - private JComboBox myVersionComboBox; + private final JComboBox myVersionComboBox; private final FrameworkSupportProviderBase myFrameworkSupportProvider; protected final FrameworkSupportModel myFrameworkSupportModel; private final List myVersions; - private JPanel myMainPanel; - private JLabel myDescriptionLabel; + private final JPanel myMainPanel; + private final JLabel myDescriptionLabel; public FrameworkSupportConfigurableBase(FrameworkSupportProviderBase frameworkSupportProvider, FrameworkSupportModel model) { this(frameworkSupportProvider, model, Collections.emptyList(), null); @@ -42,6 +48,26 @@ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurab myFrameworkSupportProvider = frameworkSupportProvider; myFrameworkSupportModel = model; myVersions = versions; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), 2, -1)); + myDescriptionLabel = new JLabel(); + this.$$$loadLabelText$$$(myDescriptionLabel, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.framework.version")); + myMainPanel.add(myDescriptionLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myVersionComboBox = new JComboBox(); + myMainPanel.add(myVersionComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myDescriptionLabel.setLabelFor(myVersionComboBox); + } myDescriptionLabel.setText(versionLabelText); myVersionComboBox.setRenderer(SimpleListCellRenderer.create("", FrameworkVersion::getVersionName)); updateAvailableVersions(versions); @@ -53,6 +79,53 @@ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurab }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + protected void updateAvailableVersions(List versions) { if (!versions.isEmpty()) { String maxValue = ""; diff --git a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java index 77fc7a0e3bf6..2671f3b5bd50 100644 --- a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java @@ -43,31 +43,51 @@ import javax.swing.event.AncestorEvent; import java.awt.BorderLayout; import java.awt.Point; import java.awt.Rectangle; +import java.lang.reflect.Method; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @ApiStatus.Internal public final class GeneralCodeStylePanel extends CodeStyleAbstractPanel { - private static final ExtensionPointName EP_NAME = new ExtensionPointName<>("com.intellij.generalCodeStyleOptionsProvider"); + private static final ExtensionPointName EP_NAME = + new ExtensionPointName<>("com.intellij.generalCodeStyleOptionsProvider"); @SuppressWarnings("UnusedDeclaration") private static final Logger LOG = Logger.getInstance(GeneralCodeStylePanel.class); private List myAdditionalOptions; - private JPanel myPanel; - private JBTabbedPane myTabbedPane; - private JPanel myGeneralTab; - private JPanel myFormatterTab; - private final JScrollPane myScrollPane; + private final JPanel myPanel; + private final JBTabbedPane myTabbedPane; + private final JPanel myGeneralTab; + private final JPanel myFormatterTab; + private final JScrollPane myScrollPane; private static int ourSelectedTabIndex = -1; private final GeneralCodeStyleGeneralTab generalTab; private final GeneralCodeStyleFormatterTab formatterTab; public GeneralCodeStylePanel(CodeStyleSettings settings) { super(settings); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + myTabbedPane = new JBTabbedPane(); + myPanel.add(myTabbedPane, BorderLayout.CENTER); + myGeneralTab = new JPanel(); + myGeneralTab.setLayout(new BorderLayout(0, 0)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "settings.code.style.general.tab.title"), + myGeneralTab); + myFormatterTab = new JPanel(); + myFormatterTab.setLayout(new BorderLayout(0, 0)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "settings.code.style.formatter.control.tab.title"), + myFormatterTab); + } generalTab = new GeneralCodeStyleGeneralTab(settings); formatterTab = new GeneralCodeStyleFormatterTab(); @@ -116,6 +136,28 @@ public final class GeneralCodeStylePanel extends CodeStyleAbstractPanel { }, this); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateGeneralOptionsPanel() { myAdditionalOptions = ConfigurableWrapper.createConfigurables(EP_NAME); generalTab.updateGeneralOptions(myAdditionalOptions); @@ -208,7 +250,9 @@ public final class GeneralCodeStylePanel extends CodeStyleAbstractPanel { !settings.FORMATTER_TAGS_ENABLED || settings.FORMATTER_TAGS_ACCEPT_REGEXP != formatterTab.acceptRegularExpressionsCheckBox.isSelected() || !StringUtil.equals(formatterTab.formatterOffTagField.getText(), settings.FORMATTER_OFF_TAG) || - !StringUtil.equals(formatterTab.formatterOnTagField.getText(), settings.FORMATTER_ON_TAG)) return true; + !StringUtil.equals(formatterTab.formatterOnTagField.getText(), settings.FORMATTER_ON_TAG)) { + return true; + } } else { if (settings.FORMATTER_TAGS_ENABLED) return true; diff --git a/platform/lang-impl/src/com/intellij/application/options/ImportSchemeChooserDialog.java b/platform/lang-impl/src/com/intellij/application/options/ImportSchemeChooserDialog.java index a30382383e49..d93945fc4573 100644 --- a/platform/lang-impl/src/com/intellij/application/options/ImportSchemeChooserDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/ImportSchemeChooserDialog.java @@ -8,37 +8,96 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.Pair; import com.intellij.psi.codeStyle.CodeStyleScheme; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.openapi.util.Pair.pair; public final class ImportSchemeChooserDialog extends DialogWrapper { - private JPanel contentPane; - private JBList mySchemeList; - private JTextField myTargetNameField; - private JCheckBox myUseCurrentScheme; + private final JPanel contentPane; + private final JBList mySchemeList; + private final JTextField myTargetNameField; + private final JCheckBox myUseCurrentScheme; private String mySelectedName; private final List myNames = new ArrayList<>(); - public ImportSchemeChooserDialog(@NotNull Project project, @NlsContexts.Label String @NotNull [] schemeNames, @Nullable String currentScheme) { + public ImportSchemeChooserDialog(@NotNull Project project, + @NlsContexts.Label String @NotNull [] schemeNames, + @Nullable String currentScheme) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1)); + contentPane.putClientProperty("BorderFactoryClass", ""); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", ""); + contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(200, -1), null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "import.scheme.chooser.destination")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetNameField = new JTextField(); + panel1.add(myTargetNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myUseCurrentScheme = new JCheckBox(); + this.$$$loadButtonText$$$(myUseCurrentScheme, + this.$$$getMessageFromBundle$$$("messages/LangBundle", "checkbox.import.scheme.current.scheme")); + panel1.add(myUseCurrentScheme, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + contentPane.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mySchemeList = new JBList(); + jBScrollPane1.setViewportView(mySchemeList); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "import.scheme.chooser.source")); + contentPane.add(jBLabel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } if (schemeNames.length > 0) { myNames.addAll(Arrays.asList(schemeNames)); } @@ -87,11 +146,83 @@ public final class ImportSchemeChooserDialog extends DialogWrapper { } } }); - mySchemeList.getSelectionModel().setSelectionInterval(0,0); + mySchemeList.getSelectionModel().setSelectionInterval(0, 0); init(); setTitle(ApplicationBundle.message("title.import.scheme.chooser")); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + public String getSelectedName() { return mySelectedName; } @@ -113,12 +244,15 @@ public final class ImportSchemeChooserDialog extends DialogWrapper { public static @Nullable Pair selectOrCreateTargetScheme(@NotNull Project project, @NotNull CodeStyleScheme currentScheme, @NotNull SchemeFactory schemeFactory, - @NlsContexts.Label String @NotNull... schemeNames) { - ImportSchemeChooserDialog dialog = new ImportSchemeChooserDialog(project, schemeNames, !currentScheme.isDefault() ? currentScheme.getName() : null); + @NlsContexts.Label String @NotNull ... schemeNames) { + ImportSchemeChooserDialog dialog = + new ImportSchemeChooserDialog(project, schemeNames, !currentScheme.isDefault() ? currentScheme.getName() : null); if (dialog.showAndGet()) { return pair( dialog.getSelectedName(), - dialog.isUseCurrentScheme() && (!currentScheme.isDefault()) ? currentScheme : schemeFactory.createNewScheme(dialog.getTargetName())); + dialog.isUseCurrentScheme() && (!currentScheme.isDefault()) + ? currentScheme + : schemeFactory.createNewScheme(dialog.getTargetName())); } return null; } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CommenterForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CommenterForm.java index 40b3fca3ef45..561003b5ca4c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CommenterForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CommenterForm.java @@ -10,22 +10,30 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * Reusable commenter settings form. */ public final class CommenterForm implements CodeStyleSettingsCustomizable { - private JPanel myCommenterPanel; + private final JPanel myCommenterPanel; - private JBCheckBox myLineCommentAtFirstColumnCb; - private JBCheckBox myLineCommentAddSpaceCb; - private JBCheckBox myLineCommentAddSpaceOnReformatCb; - private JBCheckBox myBlockCommentAtFirstJBCheckBox; - private JBCheckBox myBlockCommentAddSpaceCb; + private final JBCheckBox myLineCommentAtFirstColumnCb; + private final JBCheckBox myLineCommentAddSpaceCb; + private final JBCheckBox myLineCommentAddSpaceOnReformatCb; + private final JBCheckBox myBlockCommentAtFirstJBCheckBox; + private final JBCheckBox myBlockCommentAddSpaceCb; private final Language myLanguage; @@ -35,6 +43,49 @@ public final class CommenterForm implements CodeStyleSettingsCustomizable { public CommenterForm(Language language, @Nullable @NlsContexts.BorderTitle String title) { myLanguage = language; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myCommenterPanel = new JPanel(); + myCommenterPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + myLineCommentAtFirstColumnCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myLineCommentAtFirstColumnCb, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.line.comment.at.first.column")); + myCommenterPanel.add(myLineCommentAtFirstColumnCb, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myCommenterPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLineCommentAddSpaceCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myLineCommentAddSpaceCb, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.line.comment.add.space")); + myCommenterPanel.add(myLineCommentAddSpaceCb, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myLineCommentAddSpaceOnReformatCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myLineCommentAddSpaceOnReformatCb, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", + "checkbox.line.comment.add.space.on.reformat")); + myCommenterPanel.add(myLineCommentAddSpaceOnReformatCb, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, + false)); + myBlockCommentAtFirstJBCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myBlockCommentAtFirstJBCheckBox, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.block.comment.at.first.column")); + myCommenterPanel.add(myBlockCommentAtFirstJBCheckBox, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myBlockCommentAddSpaceCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myBlockCommentAddSpaceCb, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.block.comment.add.space")); + myCommenterPanel.add(myBlockCommentAddSpaceCb, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } if (title != null) { myCommenterPanel.setBorder(IdeBorderFactory.createTitledBorder(title)); } @@ -55,6 +106,53 @@ public final class CommenterForm implements CodeStyleSettingsCustomizable { customizeSettings(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myCommenterPanel; } + public void reset(@NotNull CodeStyleSettings settings) { CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage); myLineCommentAtFirstColumnCb.setSelected(langSettings.LINE_COMMENT_AT_FIRST_COLUMN); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OtherFileTypesCodeStyleOptionsForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OtherFileTypesCodeStyleOptionsForm.java index 151b7b2275e3..f0b443d939f4 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OtherFileTypesCodeStyleOptionsForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OtherFileTypesCodeStyleOptionsForm.java @@ -11,14 +11,22 @@ import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.options.ConfigurationException; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * Used for non-language settings (if file type is not supported by Intellij IDEA), for example, plain text. @@ -26,16 +34,85 @@ import java.awt.BorderLayout; @ApiStatus.Internal public final class OtherFileTypesCodeStyleOptionsForm extends CodeStyleAbstractPanel { private final IndentOptionsEditorWithSmartTabs myIndentOptionsEditor; - private JPanel myIndentOptionsPanel; - private JPanel myTopPanel; + private final JPanel myIndentOptionsPanel; + private final JPanel myTopPanel; OtherFileTypesCodeStyleOptionsForm(@NotNull CodeStyleSettings settings) { super(settings); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 20, 0, 0), -1, -1)); + myIndentOptionsPanel = new JPanel(); + myIndentOptionsPanel.setLayout(new BorderLayout(0, 0)); + myIndentOptionsPanel.putClientProperty("BorderFactoryClass", ""); + myTopPanel.add(myIndentOptionsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myTopPanel.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "code.style.other.label")); + myTopPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } myIndentOptionsEditor = new IndentOptionsEditorWithSmartTabs(); myIndentOptionsPanel.add(myIndentOptionsEditor.createPanel(), BorderLayout.CENTER); addPanelToWatch(myIndentOptionsPanel); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + @Override protected int getRightMargin() { return 0; diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java index da43705e9daf..fe3c1c87c187 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java @@ -14,20 +14,29 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.ui.JBColor; import com.intellij.ui.components.AnActionLink; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.fields.CommaSeparatedIntegersField; import com.intellij.ui.components.fields.IntegerField; import com.intellij.ui.components.fields.valueEditors.CommaSeparatedIntegersValueEditor; import com.intellij.ui.components.fields.valueEditors.ValueEditor; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.psi.codeStyle.CodeStyleSettingsCustomizableOptions.getInstance; @@ -46,20 +55,111 @@ import static com.intellij.psi.codeStyle.CodeStyleSettingsCustomizableOptions.ge * */ public final class RightMarginForm { - private IntegerField myRightMarginField; - private JPanel myTopPanel; - private JComboBox myWrapOnTypingCombo; - private CommaSeparatedIntegersField myVisualGuidesField; - @SuppressWarnings("unused") private AnActionLink myResetLink; - private JLabel myVisualGuidesHint; - private JLabel myVisualGuidesLabel; - private AnActionLink myResetGuidesLink; + private final IntegerField myRightMarginField; + private final JPanel myTopPanel; + private final JComboBox myWrapOnTypingCombo; + private final CommaSeparatedIntegersField myVisualGuidesField; + @SuppressWarnings("unused") private final AnActionLink myResetLink; + private final JLabel myVisualGuidesHint; + private final JLabel myVisualGuidesLabel; + private final AnActionLink myResetGuidesLink; private final Language myLanguage; private final CodeStyleSettings mySettings; public RightMarginForm(@NotNull Language language, @NotNull CodeStyleSettings settings) { myLanguage = language; mySettings = settings; + { + myRightMarginField = new IntegerField(ApplicationBundle.message("editbox.right.margin.columns"), + 0, CodeStyleConstraints.MAX_RIGHT_MARGIN); + myRightMarginField.getValueEditor().addListener(new ValueEditor.Listener<>() { + @Override + public void valueChanged(@NotNull Integer newValue) { + myResetLink.setVisible(!newValue.equals(myRightMarginField.getDefaultValue())); + myRightMarginField.getEmptyText().setText(MarginOptionsUtil.getDefaultRightMarginText(mySettings)); + } + }); + myRightMarginField.setCanBeEmpty(true); + myRightMarginField.setDefaultValue(-1); + myRightMarginField.setMinimumSize(new Dimension(JBUIScale.scale(120), myRightMarginField.getMinimumSize().height)); + myVisualGuidesField = new CommaSeparatedIntegersField(ApplicationBundle.message("settings.code.style.visual.guides"), + 0, CodeStyleConstraints.MAX_RIGHT_MARGIN, + ApplicationBundle.message("settings.code.style.visual.guides.optional")); + myVisualGuidesField.getValueEditor().addListener(new ValueEditor.Listener<>() { + @Override + public void valueChanged(@NotNull List newValue) { + myResetGuidesLink.setVisible(!myVisualGuidesField.isEmpty()); + myVisualGuidesField.getEmptyText().setText(getDefaultVisualGuidesText(mySettings)); + } + }); + myResetLink = new AnActionLink(LangBundle.message("action.link.reset"), new ResetRightMarginAction()); + myVisualGuidesLabel = new JLabel(); + myResetGuidesLink = new AnActionLink(LangBundle.message("action.link.reset"), new ResetGuidesAction()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(5, 5, new Insets(10, 10, 10, 10), -1, -1)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "editbox.right.margin.columns")); + myTopPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myTopPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "wrapping.wrap.on.typing")); + myTopPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myWrapOnTypingCombo = new JComboBox(); + myTopPanel.add(myWrapOnTypingCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myTopPanel.add(spacer2, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myRightMarginField.setColumns(12); + myTopPanel.add(myRightMarginField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(50, -1), null, 0, false)); + myTopPanel.add(myVisualGuidesField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + this.$$$loadLabelText$$$(myVisualGuidesLabel, + this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.right.margin.visual.guides")); + myTopPanel.add(myVisualGuidesLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "margin.columns")); + myTopPanel.add(jBLabel2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "margin.columns")); + myTopPanel.add(jBLabel3, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + this.$$$loadButtonText$$$(myResetLink, this.$$$getMessageFromBundle$$$("messages/LangBundle", "link.right.margin.reset")); + myTopPanel.add(myResetLink, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myVisualGuidesHint = new JLabel(); + this.$$$loadLabelText$$$(myVisualGuidesHint, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", + "settings.code.style.general.visual.guides.hint")); + myTopPanel.add(myVisualGuidesHint, new GridConstraints(3, 1, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + this.$$$loadButtonText$$$(myResetGuidesLink, this.$$$getMessageFromBundle$$$("messages/LangBundle", "link.right.margin.reset")); + myTopPanel.add(myResetGuidesLink, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } //noinspection unchecked myWrapOnTypingCombo.setModel(new DefaultComboBoxModel( @@ -71,34 +171,78 @@ public final class RightMarginForm { myVisualGuidesLabel.setText(ApplicationBundle.message("settings.code.style.visual.guides") + ":"); } - void createUIComponents() { - myRightMarginField = new IntegerField(ApplicationBundle.message("editbox.right.margin.columns"), - 0, CodeStyleConstraints.MAX_RIGHT_MARGIN); - myRightMarginField.getValueEditor().addListener(new ValueEditor.Listener<>() { - @Override - public void valueChanged(@NotNull Integer newValue) { - myResetLink.setVisible(!newValue.equals(myRightMarginField.getDefaultValue())); - myRightMarginField.getEmptyText().setText(MarginOptionsUtil.getDefaultRightMarginText(mySettings)); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); } - }); - myRightMarginField.setCanBeEmpty(true); - myRightMarginField.setDefaultValue(-1); - myRightMarginField.setMinimumSize(new Dimension(JBUIScale.scale(120), myRightMarginField.getMinimumSize().height)); - myVisualGuidesField = new CommaSeparatedIntegersField(ApplicationBundle.message("settings.code.style.visual.guides"), - 0, CodeStyleConstraints.MAX_RIGHT_MARGIN, - ApplicationBundle.message("settings.code.style.visual.guides.optional")); - myVisualGuidesField.getValueEditor().addListener(new ValueEditor.Listener<>() { - @Override - public void valueChanged(@NotNull List newValue) { - myResetGuidesLink.setVisible(!myVisualGuidesField.isEmpty()); - myVisualGuidesField.getEmptyText().setText(getDefaultVisualGuidesText(mySettings)); - } - }); - myResetLink = new AnActionLink(LangBundle.message("action.link.reset"), new ResetRightMarginAction()); - myVisualGuidesLabel = new JLabel(); - myResetGuidesLink = new AnActionLink(LangBundle.message("action.link.reset"), new ResetGuidesAction()); + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private final class ResetRightMarginAction extends DumbAwareAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { @@ -116,7 +260,7 @@ public final class RightMarginForm { public void reset(@NotNull CodeStyleSettings settings) { CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage); myRightMarginField.setValue(langSettings.RIGHT_MARGIN); - for (int i = 0; i < CodeStyleSettingsCustomizable.WRAP_ON_TYPING_VALUES.length; i ++) { + for (int i = 0; i < CodeStyleSettingsCustomizable.WRAP_ON_TYPING_VALUES.length; i++) { if (langSettings.WRAP_ON_TYPING == CodeStyleSettingsCustomizable.WRAP_ON_TYPING_VALUES[i]) { myWrapOnTypingCombo.setSelectedIndex(i); break; @@ -166,5 +310,4 @@ public final class RightMarginForm { CommaSeparatedIntegersValueEditor.intListToString(margins.subList(0, 2)) + ",..."; return MarginOptionsUtil.getDefaultValueText(marginsString); } - } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java index 7548b2e8576c..568c3811d6d6 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java @@ -2,19 +2,41 @@ package com.intellij.application.options.codeStyle.excludedFiles; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.Dimension; +import java.awt.Insets; public final class ExcludedFilesScopeForm { - private JPanel myTopPanel; - private JBList myScopesList; + private final JPanel myTopPanel; + private final JBList myScopesList; public ExcludedFilesScopeForm() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myTopPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myScopesList = new JBList(); + jBScrollPane1.setViewportView(myScopesList); + } myTopPanel.setMinimumSize(new Dimension(myTopPanel.getMinimumSize().width, JBUIScale.scale(100))); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + public JPanel getTopPanel() { return myTopPanel; } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/PluginInfoForm.java b/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/PluginInfoForm.java index 03327256ac84..f12c0b0bb998 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/PluginInfoForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/PluginInfoForm.java @@ -4,23 +4,172 @@ package com.intellij.application.options.colors.pluginExport; import com.intellij.openapi.editor.colors.EditorColorsUtil; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.ui.EditorTextField; +import com.intellij.ui.TitledSeparator; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTextField; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.ScrollPaneConstants; import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class PluginInfoForm { - private JTextField myVendorMailField; - private JTextField myVendorNameField; - private JBTextField myVendorUrl; - private JBTextField myVersionField; - private EditorTextField myDescriptionArea; - private EditorTextField myChangeNotesArea; - private JPanel myTopPanel; + private final JTextField myVendorMailField; + private final JTextField myVendorNameField; + private final JBTextField myVendorUrl; + private final JBTextField myVersionField; + private final EditorTextField myDescriptionArea; + private final EditorTextField myChangeNotesArea; + private final JPanel myTopPanel; + + public PluginInfoForm() { + { + myDescriptionArea = createDescriptionEditor(); + myChangeNotesArea = createDescriptionEditor(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.version")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myVersionField = new JBTextField(); + myVersionField.setColumns(6); + panel1.add(myVersionField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, + null, null, 0, false)); + panel1.add(myDescriptionArea, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.description")); + panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, + false)); + panel1.add(myChangeNotesArea, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.change.notes")); + panel1.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, + false)); + myVendorNameField = new JTextField(); + myVendorNameField.setColumns(20); + panel1.add(myVendorNameField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, + null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.name")); + panel1.add(label3, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.e.mail")); + panel1.add(jBLabel2, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myVendorMailField = new JTextField(); + myVendorMailField.setColumns(20); + panel1.add(myVendorMailField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, + null, null, null, 0, false)); + myVendorUrl = new JBTextField(); + myVendorUrl.setColumns(20); + panel1.add(myVendorUrl, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, + null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.export.plugin.url")); + panel1.add(jBLabel3, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/LangBundle", "separator.title.export.plugin.vendor")); + panel1.add(titledSeparator1, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator2 = new TitledSeparator(); + titledSeparator2.setText(this.$$$getMessageFromBundle$$$("messages/LangBundle", "separator.title.plugin")); + myTopPanel.add(titledSeparator2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jBLabel2.setLabelFor(myVendorMailField); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } public JPanel getTopPanel() { return myTopPanel; @@ -44,11 +193,6 @@ public final class PluginInfoForm { exportData.setChangeNotes(myChangeNotesArea.getText()); } - private void createUIComponents() { - myDescriptionArea = createDescriptionEditor(); - myChangeNotesArea = createDescriptionEditor(); - } - private static EditorTextField createDescriptionEditor() { EditorTextField descriptionEditor = new EditorTextField() { @Override diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/GutterIconsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/GutterIconsConfigurable.java index 124afba5c77d..3ebef6278c0e 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/GutterIconsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/GutterIconsConfigurable.java @@ -30,7 +30,10 @@ import com.intellij.ui.CheckBoxList; import com.intellij.ui.ListSpeedSearch; import com.intellij.ui.SeparatorWithText; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.speedSearch.SpeedSearchSupply; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; @@ -42,6 +45,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; +import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JCheckBox; @@ -54,7 +58,9 @@ import javax.swing.SwingUtilities; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.Point; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -63,6 +69,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.Set; /** @@ -72,9 +79,120 @@ import java.util.Set; public final class GutterIconsConfigurable implements SearchableConfigurable, Configurable.NoScroll { public static final @NonNls String ID = "editor.preferences.gutterIcons"; - private JPanel myPanel; - private CheckBoxList myList; - private JBCheckBox myShowGutterIconsJBCheckBox; + private final JPanel myPanel; + private final CheckBoxList myList; + private final JBCheckBox myShowGutterIconsJBCheckBox; + + public GutterIconsConfigurable() { + { + myList = new CheckBoxList<>() { + @Override + protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder()); + GutterIconDescriptor descriptor = myList.getItemAt(index); + Icon icon = descriptor == null ? null : descriptor.getIcon(); + JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon); + label.setOpaque(true); + label.setPreferredSize(new Dimension(25, -1)); + label.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(label, BorderLayout.WEST); + panel.add(checkBox, BorderLayout.CENTER); + panel.setBackground(getBackground(false)); + label.setBackground(getBackground(selected)); + if (!checkBox.isOpaque()) { + checkBox.setOpaque(true); + } + checkBox.setBorder(null); + + PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor); + if (pluginDescriptor != null) { + SeparatorWithText separator = new SeparatorWithText(); + String name = getPluginDisplayName(pluginDescriptor); + separator.setCaption(name); + panel.add(separator, BorderLayout.NORTH); + } + + return panel; + } + + @Override + protected @Nullable Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) { + return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index); + } + }; + myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + myList.setBorder(BorderFactory.createEmptyBorder()); + ListSpeedSearch.installOn(myList, JCheckBox::getText); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBScrollPane1.setViewportView(myList); + myShowGutterIconsJBCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myShowGutterIconsJBCheckBox, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.show.gutter.icons")); + myPanel.add(myShowGutterIconsJBCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private final List myDescriptors = new ArrayList<>(); private final Map myFirstDescriptors = new HashMap<>(); @@ -94,7 +212,9 @@ public final class GutterIconsConfigurable implements SearchableConfigurable, Co NullableFunction, PluginDescriptor> function = point1 -> { LineMarkerProvider instance = point1.getInstance(); - return instance instanceof LineMarkerProviderDescriptor && ((LineMarkerProviderDescriptor)instance).getName() != null ? point1.getPluginDescriptor() : null; + return instance instanceof LineMarkerProviderDescriptor && ((LineMarkerProviderDescriptor)instance).getName() != null + ? point1.getPluginDescriptor() + : null; }; MultiMap> map = ContainerUtil.groupBy(Arrays.asList(extensions), function); Map pluginDescriptorMap = new HashMap<>(); @@ -180,7 +300,8 @@ public final class GutterIconsConfigurable implements SearchableConfigurable, Co for (Project project : ProjectManager.getInstance().getOpenProjects()) { DaemonCodeAnalyzerEx.getInstanceEx(project).restart("GutterIconsConfigurable.apply"); } - ApplicationManager.getApplication().getMessageBus().syncPublisher(EditorOptionsListener.GUTTER_ICONS_CONFIGURABLE_TOPIC).changesApplied(); + ApplicationManager.getApplication().getMessageBus().syncPublisher(EditorOptionsListener.GUTTER_ICONS_CONFIGURABLE_TOPIC) + .changesApplied(); } @Override @@ -207,48 +328,6 @@ public final class GutterIconsConfigurable implements SearchableConfigurable, Co pluginDescriptor.getName(); } - private void createUIComponents() { - myList = new CheckBoxList<>() { - @Override - protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) { - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createEmptyBorder()); - GutterIconDescriptor descriptor = myList.getItemAt(index); - Icon icon = descriptor == null ? null : descriptor.getIcon(); - JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon); - label.setOpaque(true); - label.setPreferredSize(new Dimension(25, -1)); - label.setHorizontalAlignment(SwingConstants.CENTER); - panel.add(label, BorderLayout.WEST); - panel.add(checkBox, BorderLayout.CENTER); - panel.setBackground(getBackground(false)); - label.setBackground(getBackground(selected)); - if (!checkBox.isOpaque()) { - checkBox.setOpaque(true); - } - checkBox.setBorder(null); - - PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor); - if (pluginDescriptor != null) { - SeparatorWithText separator = new SeparatorWithText(); - String name = getPluginDisplayName(pluginDescriptor); - separator.setCaption(name); - panel.add(separator, BorderLayout.NORTH); - } - - return panel; - } - - @Override - protected @Nullable Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) { - return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index); - } - }; - myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - myList.setBorder(BorderFactory.createEmptyBorder()); - ListSpeedSearch.installOn(myList, JCheckBox::getText); - } - @Override public @NotNull String getId() { return ID; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java index d664d5a60e0e..21508b37151d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java @@ -11,14 +11,26 @@ import com.intellij.openapi.util.NlsContexts; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.arrangement.Rearranger; import com.intellij.testFramework.LightVirtualFile; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class LayoutCodeDialog extends DialogWrapper { private final PsiFile myPsiFile; @@ -27,20 +39,108 @@ public final class LayoutCodeDialog extends DialogWrapper { private final LastRunReformatCodeOptionsProvider myLastRunOptions; private final LayoutCodeOptions myRunOptions; - private JPanel myButtonsPanel; - private JCheckBox myOptimizeImportsCb; - private JCheckBox myRearrangeCodeCb; - private JCheckBox myApplyCodeCleanup; - private JRadioButton myOnlyVCSChangedTextRb; - private JRadioButton mySelectedTextRadioButton; - private JRadioButton myWholeFileRadioButton; - private JBCheckBox myDoNotKeepLineBreaks; + private final JPanel myButtonsPanel; + private final JCheckBox myOptimizeImportsCb; + private final JCheckBox myRearrangeCodeCb; + private final JCheckBox myApplyCodeCleanup; + private final JRadioButton myOnlyVCSChangedTextRb; + private final JRadioButton mySelectedTextRadioButton; + private final JRadioButton myWholeFileRadioButton; + private final JBCheckBox myDoNotKeepLineBreaks; public LayoutCodeDialog(@NotNull Project project, @NotNull PsiFile psiFile, boolean textSelected, String helpId) { super(project, true); myPsiFile = psiFile; myTextSelected = textSelected; myHelpId = helpId; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myButtonsPanel = new JPanel(); + myButtonsPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myButtonsPanel.setMinimumSize(new Dimension(400, 222)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myButtonsPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/CodeInsightBundle", "reformat.scope.panel"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOnlyVCSChangedTextRb = new JRadioButton(); + myOnlyVCSChangedTextRb.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myOnlyVCSChangedTextRb, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", + "radio.button.reformat.only.vcs.changed.text")); + panel1.add(myOnlyVCSChangedTextRb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySelectedTextRadioButton = new JRadioButton(); + mySelectedTextRadioButton.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(mySelectedTextRadioButton, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "radio.button.reformat.selected.text")); + panel1.add(mySelectedTextRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWholeFileRadioButton = new JRadioButton(); + myWholeFileRadioButton.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myWholeFileRadioButton, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "radio.button.reformat.whole.file")); + panel1.add(myWholeFileRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myButtonsPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myButtonsPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/CodeInsightBundle", + "reformat.options.panel"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOptimizeImportsCb = new JCheckBox(); + myOptimizeImportsCb.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myOptimizeImportsCb, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.optimize.imports")); + panel2.add(myOptimizeImportsCb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRearrangeCodeCb = new JCheckBox(); + myRearrangeCodeCb.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myRearrangeCodeCb, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.rearrange.code")); + panel2.add(myRearrangeCodeCb, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myApplyCodeCleanup = new JCheckBox(); + myApplyCodeCleanup.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myApplyCodeCleanup, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.code.cleanup")); + panel2.add(myApplyCodeCleanup, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDoNotKeepLineBreaks = new JBCheckBox(); + this.$$$loadButtonText$$$(myDoNotKeepLineBreaks, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "do.not.keep.line.breaks")); + panel2.add(myDoNotKeepLineBreaks, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(mySelectedTextRadioButton); + buttonGroup.add(myWholeFileRadioButton); + buttonGroup.add(myOnlyVCSChangedTextRb); + } myLastRunOptions = new LastRunReformatCodeOptionsProvider(PropertiesComponent.getInstance()); myRunOptions = createOptionsBundledOnDialog(); @@ -51,6 +151,53 @@ public final class LayoutCodeDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myButtonsPanel; } + @Override protected void init() { super.init(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java index 0d4ed697d26f..1a720025b821 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java @@ -14,19 +14,28 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.NlsContexts; import com.intellij.psi.search.SearchScope; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import java.util.regex.PatternSyntaxException; @ApiStatus.Internal @@ -34,38 +43,173 @@ public class LayoutProjectCodeDialog extends DialogWrapper implements ReformatFi private static final @NonNls String HELP_ID = "Reformat Code on Directory Dialog"; private final Project myProject; - private final @NlsContexts.Label String myText; + private final @NlsContexts.Label String myText; private final boolean myEnableOnlyVCSChangedTextCb; private final LastRunReformatCodeOptionsProvider myLastRunOptions; - private JLabel myTitle; - protected JCheckBox myIncludeSubdirsCb; + private final JLabel myTitle; + protected final JCheckBox myIncludeSubdirsCb; - private JCheckBox myUseScopeFilteringCb; - private ScopeChooserCombo myScopeCombo; + private final JCheckBox myUseScopeFilteringCb; + private final ScopeChooserCombo myScopeCombo; - private JCheckBox myEnableFileNameFilterCb; - private ComboBox myFileFilter; + private final JCheckBox myEnableFileNameFilterCb; + private final ComboBox myFileFilter; - private JCheckBox myCbOptimizeImports; - private JCheckBox myCbRearrangeEntries; - private JCheckBox myCbOnlyVcsChangedRegions; + private final JCheckBox myCbOptimizeImports; + private final JCheckBox myCbRearrangeEntries; + private final JCheckBox myCbOnlyVcsChangedRegions; - private JPanel myWholePanel; - private JPanel myOptionsPanel; - private JPanel myFiltersPanel; - private JLabel myMaskWarningLabel; - private JCheckBox myCbCleanupCode; + private final JPanel myWholePanel; + private final JPanel myOptionsPanel; + private final JPanel myFiltersPanel; + private final JLabel myMaskWarningLabel; + private final JCheckBox myCbCleanupCode; public LayoutProjectCodeDialog(@NotNull Project project, @NotNull @NlsContexts.DialogTitle String title, @NotNull @NlsContexts.Label String text, - boolean enableOnlyVCSChangedTextCb) - { + boolean enableOnlyVCSChangedTextCb) { super(project, false); myText = text; myProject = project; myEnableOnlyVCSChangedTextCb = enableOnlyVCSChangedTextCb; + { + myScopeCombo = new ScopeChooserCombo(myProject, false, false, FindSettings.getInstance().getDefaultScopeName()); + Disposer.register(myDisposable, myScopeCombo); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(5, 4, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(myOptionsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCbOptimizeImports = new JCheckBox(); + this.$$$loadButtonText$$$(myCbOptimizeImports, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.optimize.imports")); + myOptionsPanel.add(myCbOptimizeImports, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCbRearrangeEntries = new JCheckBox(); + this.$$$loadButtonText$$$(myCbRearrangeEntries, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.rearrange.entries")); + myOptionsPanel.add(myCbRearrangeEntries, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCbOnlyVcsChangedRegions = new JCheckBox(); + this.$$$loadButtonText$$$(myCbOnlyVcsChangedRegions, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", + "radio.button.reformat.only.vcs.changed.text")); + myOptionsPanel.add(myCbOnlyVcsChangedRegions, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myOptionsPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myIncludeSubdirsCb = new JCheckBox(); + this.$$$loadButtonText$$$(myIncludeSubdirsCb, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", + "checkbox.reformat.project.include.subdirectories")); + myOptionsPanel.add(myIncludeSubdirsCb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCbCleanupCode = new JCheckBox(); + this.$$$loadButtonText$$$(myCbCleanupCode, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.reformat.project.cleanup.code")); + myOptionsPanel.add(myCbCleanupCode, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myWholePanel.add(spacer3, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel2, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myFiltersPanel = new JPanel(); + myFiltersPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(myFiltersPanel, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myFiltersPanel.add(panel3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myEnableFileNameFilterCb = new JBCheckBox(); + this.$$$loadButtonText$$$(myEnableFileNameFilterCb, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.reformat.project.file.masks")); + panel3.add(myEnableFileNameFilterCb, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFileFilter = new ComboBox(); + panel3.add(myFileFilter, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final Spacer spacer4 = new Spacer(); + panel3.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myFiltersPanel.add(panel4, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUseScopeFilteringCb = new JCheckBox(); + this.$$$loadButtonText$$$(myUseScopeFilteringCb, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.reformat.project.scope")); + panel4.add(myUseScopeFilteringCb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + panel4.add(spacer5, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + panel4.add(myScopeCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myMaskWarningLabel = new JLabel(); + this.$$$loadLabelText$$$(myMaskWarningLabel, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "label.file.mask.is.invalid")); + myFiltersPanel.add(myMaskWarningLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 3, false)); + final Spacer spacer6 = new Spacer(); + myFiltersPanel.add(spacer6, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myTitle = new JLabel(); + myTitle.setText(""); + myWholePanel.add(myTitle, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel5, new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(-1, 5), null, null, 0, false)); + } myLastRunOptions = new LastRunReformatCodeOptionsProvider(PropertiesComponent.getInstance()); setOKButtonText(CodeInsightBundle.message("reformat.code.accept.button.text")); @@ -73,6 +217,78 @@ public class LayoutProjectCodeDialog extends DialogWrapper implements ReformatFi init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override protected JComponent createCenterPanel() { myTitle.setText(myText); @@ -201,11 +417,6 @@ public class LayoutProjectCodeDialog extends DialogWrapper implements ReformatFi return null; } - protected void createUIComponents() { - myScopeCombo = new ScopeChooserCombo(myProject, false, false, FindSettings.getInstance().getDefaultScopeName()); - Disposer.register(myDisposable, myScopeCombo); - } - @Override public @Nullable SearchScope getSearchScope() { if (myUseScopeFilteringCb.isSelected()) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.java index 20c42dfe3424..2c8a560df90f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.java @@ -13,14 +13,22 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiManager; import com.intellij.psi.codeStyle.arrangement.Rearranger; import com.intellij.psi.search.SearchScope; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Objects; +import java.util.ResourceBundle; import java.util.stream.Stream; import static com.intellij.codeInsight.actions.TextRangeType.VCS_CHANGED_TEXT; @@ -28,16 +36,65 @@ import static com.intellij.codeInsight.actions.TextRangeType.WHOLE_FILE; @ApiStatus.Internal public final class ReformatFilesDialog extends DialogWrapper implements ReformatFilesOptions { - private JPanel myPanel; - private JCheckBox myOptimizeImports; - private JCheckBox myOnlyChangedText; - private JCheckBox myRearrangeEntriesCb; - private JCheckBox myCleanupCode; + private final JPanel myPanel; + private final JCheckBox myOptimizeImports; + private final JCheckBox myOnlyChangedText; + private final JCheckBox myRearrangeEntriesCb; + private final JCheckBox myCleanupCode; private final LastRunReformatCodeOptionsProvider myLastRunSettings; public ReformatFilesDialog(@NotNull Project project, VirtualFile @NotNull [] files) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 4, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", + "dialog.reformat.files.reformat.selected.files.label")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOptimizeImports = new JCheckBox(); + this.$$$loadButtonText$$$(myOptimizeImports, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", + "dialog.reformat.files.optimize.imports.checkbox")); + panel1.add(myOptimizeImports, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOnlyChangedText = new JCheckBox(); + this.$$$loadButtonText$$$(myOnlyChangedText, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "reformat.option.vcs.changed.region")); + panel1.add(myOnlyChangedText, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myRearrangeEntriesCb = new JCheckBox(); + this.$$$loadButtonText$$$(myRearrangeEntriesCb, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "checkbox.rearrange.entries")); + panel1.add(myRearrangeEntriesCb, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCleanupCode = new JCheckBox(); + this.$$$loadButtonText$$$(myCleanupCode, + this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "reformat.option.code.cleanup")); + panel1.add(myCleanupCode, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } myLastRunSettings = new LastRunReformatCodeOptionsProvider(PropertiesComponent.getInstance()); boolean canTargetVcsChanges = VcsFacade.getInstance().hasChanges(files, project); @@ -56,6 +113,78 @@ public final class ReformatFilesDialog extends DialogWrapper implements Reformat init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private static boolean areImportOptimizersAvailable(VirtualFile @NotNull [] files, @NotNull Project project) { PsiManager psiManager = PsiManager.getInstance(project); return Stream.of(files) @@ -74,7 +203,6 @@ public final class ReformatFilesDialog extends DialogWrapper implements Reformat return true; } } - } return false; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileIncludeContextHectorPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileIncludeContextHectorPanel.java index b0d54d2710df..f77db1997bbc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileIncludeContextHectorPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileIncludeContextHectorPanel.java @@ -12,6 +12,9 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.include.FileIncludeManager; import com.intellij.ui.ComboboxWithBrowseButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -20,27 +23,98 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import java.awt.Component; import java.awt.FontMetrics; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public final class FileIncludeContextHectorPanel extends HectorComponentPanel { - private ComboboxWithBrowseButton myContextFile; - private JPanel myPanel; + private final ComboboxWithBrowseButton myContextFile; + private final JPanel myPanel; private final PsiFile myPsiFile; private final FileIncludeManager myIncludeManager; public FileIncludeContextHectorPanel(PsiFile psiFile, FileIncludeManager includeManager) { myPsiFile = psiFile; myIncludeManager = includeManager; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/CodeInsightBundle", "label.file.included.into")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myContextFile = new ComboboxWithBrowseButton(); + myPanel.add(myContextFile, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myPanel.setBackground(UIUtil.getToolTipActionBackground()); myContextFile.setBackground(UIUtil.getToolTipActionBackground()); reset(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent createComponent() { @@ -133,7 +207,5 @@ public final class FileIncludeContextHectorPanel extends HectorComponentPanel { } return result.toString(); } - } - } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java index f373fb1995bd..5a1fb7b957a9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java @@ -14,6 +14,8 @@ import com.intellij.openapi.ui.Splitter; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.treeStructure.SimpleTree; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -30,6 +32,8 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.util.Collection; /** @@ -39,16 +43,30 @@ import java.util.Collection; public final class GenerateByPatternDialog extends DialogWrapper { private final Project myProject; - private JPanel myPanel; - private Splitter mySplitter; + private final JPanel myPanel; + private final Splitter mySplitter; private final Tree myTree; private final Editor myEditor; - private final MultiMap myMap; + private final MultiMap myMap; public GenerateByPatternDialog(Project project, PatternDescriptor[] descriptors) { super(project); myProject = project; + { + mySplitter = new Splitter(false, 0.3f); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(mySplitter, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(400, 300), null, 0, false)); + } setTitle(CodeInsightBundle.message("button.generate.by.pattern")); setOKButtonText(CodeInsightBundle.message("button.generate")); @@ -73,7 +91,7 @@ public final class GenerateByPatternDialog extends DialogWrapper { boolean hasFocus) { Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, - hasFocus); + hasFocus); Object object = ((DefaultMutableTreeNode)value).getUserObject(); if (object instanceof PatternDescriptor) { setText(((PatternDescriptor)object).getName()); @@ -104,6 +122,9 @@ public final class GenerateByPatternDialog extends DialogWrapper { init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void update() { DefaultMutableTreeNode node = getSelectedNode(); getOKAction().setEnabled(node != null && node.isLeaf()); @@ -180,8 +201,4 @@ public final class GenerateByPatternDialog extends DialogWrapper { super.dispose(); EditorFactory.getInstance().releaseEditor(myEditor); } - - private void createUIComponents() { - mySplitter = new Splitter(false, 0.3f); - } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java index d72df6170c84..bb563d97fdd0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java @@ -7,6 +7,8 @@ import com.intellij.openapi.options.MasterDetails; import com.intellij.openapi.ui.DetailsComponent; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.GuiUtils; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.ApiStatus; @@ -15,8 +17,11 @@ import org.jetbrains.annotations.NotNull; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.JSplitPane; import javax.swing.JTree; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -26,17 +31,43 @@ import java.util.Set; @ApiStatus.Internal public final class IntentionSettingsPanel implements MasterDetails { - private JPanel myPanel; + private final JPanel myPanel; private final IntentionSettingsTree myIntentionSettingsTree; private final IntentionDescriptionPanel myIntentionDescriptionPanel = new IntentionDescriptionPanel(); - private JPanel myTreePanel; - private JPanel myDescriptionPanel; + private final JPanel myTreePanel; + private final JPanel myDescriptionPanel; private DetailsComponent myDetailsComponent; private final Alarm myResetAlarm = new Alarm(); public IntentionSettingsPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JSplitPane splitPane1 = new JSplitPane(); + splitPane1.setDividerLocation(557); + splitPane1.setOneTouchExpandable(true); + splitPane1.setResizeWeight(1.0); + myPanel.add(splitPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(200, 200), null, 0, false)); + myDescriptionPanel = new JPanel(); + myDescriptionPanel.setLayout(new GridLayoutManager(1, 1, new Insets(5, 5, 5, 5), -1, -1)); + splitPane1.setRightComponent(myDescriptionPanel); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 5), -1, -1)); + splitPane1.setLeftComponent(panel1); + myTreePanel = new JPanel(); + panel1.add(myTreePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + } myIntentionSettingsTree = new IntentionSettingsTree() { @Override protected void selectionChanged(Object selected) { @@ -92,6 +123,9 @@ public final class IntentionSettingsPanel implements MasterDetails { myDescriptionPanel.add(myIntentionDescriptionPanel.getComponent(), BorderLayout.CENTER); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void intentionSelected(IntentionActionMetaData actionMetaData) { myIntentionDescriptionPanel.reset(actionMetaData, myIntentionSettingsTree.getFilter()); } diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java index bcfbab05daa9..85bc6c9d72a0 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java @@ -14,6 +14,9 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.io.NioFiles; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; @@ -23,6 +26,7 @@ import javax.swing.JTextPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.Dimension; +import java.awt.Insets; import java.io.IOException; import java.nio.file.Path; import java.util.HashSet; @@ -32,8 +36,8 @@ import java.util.Set; public final class ConvertProjectDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance(ConvertProjectDialog.class); private final CachedConversionResult conversionResult; - private JPanel myMainPanel; - private JTextPane myTextPane; + private final JPanel myMainPanel; + private final JTextPane myTextPane; private boolean myConverted; private final ConversionContextImpl context; private final List conversionRunners; @@ -41,9 +45,25 @@ public final class ConvertProjectDialog extends DialogWrapper { private final Set affectedFiles; private boolean myNonExistingFilesMessageShown; - public ConvertProjectDialog(ConversionContextImpl context, CachedConversionResult conversionResult, List conversionRunners) { + public ConvertProjectDialog(ConversionContextImpl context, + CachedConversionResult conversionResult, + List conversionRunners) { super(true); this.conversionResult = conversionResult; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myTextPane = new JTextPane(); + myMainPanel.add(myTextPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(350, -1), null, 0, false)); + } setTitle(IdeBundle.message("dialog.title.convert.project")); setModal(true); this.context = context; @@ -57,7 +77,7 @@ public final class ConvertProjectDialog extends DialogWrapper { myTextPane.setSize(new Dimension(350, Integer.MAX_VALUE)); StringBuilder message = new StringBuilder(); message.append(IdeBundle.message("conversion.dialog.text.1", context.getProjectFile().getFileName().toString(), - ApplicationNamesInfo.getInstance().getFullProductName())); + ApplicationNamesInfo.getInstance().getFullProductName())); message.append(IdeBundle.message("conversion.dialog.text.2", backupDir.toString())); Messages.configureMessagePaneUi(myTextPane, XmlStringUtil.wrapInHtml(message), null); @@ -78,6 +98,9 @@ public final class ConvertProjectDialog extends DialogWrapper { setOKButtonText(IdeBundle.message("convert.project.dialog.button.text")); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected JComponent createCenterPanel() { return myMainPanel; @@ -89,7 +112,8 @@ public final class ConvertProjectDialog extends DialogWrapper { if (!nonexistentFiles.isEmpty() && !myNonExistingFilesMessageShown) { final String filesString = getFilesString(nonexistentFiles); final String message = IdeBundle.message("message.text.files.do.not.exist", filesString); - final int res = Messages.showYesNoDialog(getContentPane(), message, IdeBundle.message("dialog.title.convert.project"), Messages.getQuestionIcon()); + final int res = + Messages.showYesNoDialog(getContentPane(), message, IdeBundle.message("dialog.title.convert.project"), Messages.getQuestionIcon()); if (res != Messages.YES) { super.doOKAction(); return; @@ -137,7 +161,8 @@ public final class ConvertProjectDialog extends DialogWrapper { ApplicationNamesInfo.getInstance().getFullProductName(), getFilesString(files)); final String[] options = {CommonBundle.getContinueButtonText(), CommonBundle.getCancelButtonText()}; - if (Messages.showOkCancelDialog(myMainPanel, message, IdeBundle.message("dialog.title.convert.project"), options[0], options[1], null) != Messages.OK) { + if (Messages.showOkCancelDialog(myMainPanel, message, IdeBundle.message("dialog.title.convert.project"), options[0], options[1], + null) != Messages.OK) { return false; } unlockFiles(files); diff --git a/platform/lang-impl/src/com/intellij/facet/impl/invalid/InvalidFacetEditor.java b/platform/lang-impl/src/com/intellij/facet/impl/invalid/InvalidFacetEditor.java index cbdc763967c4..9865e8c0eafa 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/invalid/InvalidFacetEditor.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/invalid/InvalidFacetEditor.java @@ -6,31 +6,140 @@ import com.intellij.facet.ui.FacetEditorTab; import com.intellij.icons.AllIcons; import com.intellij.openapi.ui.ex.MultiLineLabel; import com.intellij.openapi.util.NlsContexts; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public final class InvalidFacetEditor extends FacetEditorTab { private final @NlsContexts.DialogMessage String myErrorMessage; - private JPanel myMainPanel; - private MultiLineLabel myDescriptionLabel; - private JCheckBox myIgnoreCheckBox; - private JLabel myIconLabel; + private final JPanel myMainPanel; + private final MultiLineLabel myDescriptionLabel; + private final JCheckBox myIgnoreCheckBox; + private final JLabel myIconLabel; private final InvalidFacetManager myInvalidFacetManager; private final InvalidFacet myFacet; public InvalidFacetEditor(FacetEditorContext context, @NlsContexts.DialogMessage String errorMessage) { myErrorMessage = errorMessage; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.cannot.load.facet")); + myMainPanel.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myDescriptionLabel = new MultiLineLabel(); + myMainPanel.add(myDescriptionLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myIconLabel = new JLabel(); + myIconLabel.setText(""); + myMainPanel.add(myIconLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myIgnoreCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myIgnoreCheckBox, this.$$$getMessageFromBundle$$$("messages/LangBundle", "checkbox.ignore.invalid.facet")); + myMainPanel.add(myIgnoreCheckBox, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myFacet = (InvalidFacet)context.getFacet(); myInvalidFacetManager = InvalidFacetManager.getInstance(context.getProject()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public @Nls String getDisplayName() { return ""; diff --git a/platform/lang-impl/src/com/intellij/facet/impl/invalid/MultipleInvalidFacetEditor.java b/platform/lang-impl/src/com/intellij/facet/impl/invalid/MultipleInvalidFacetEditor.java index b73187a9f683..36549de712c8 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/invalid/MultipleInvalidFacetEditor.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/invalid/MultipleInvalidFacetEditor.java @@ -4,21 +4,93 @@ package com.intellij.facet.impl.invalid; import com.intellij.facet.impl.ui.MultipleFacetEditorHelperImpl; import com.intellij.facet.ui.FacetEditor; import com.intellij.facet.ui.MultipleFacetSettingsEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.ThreeStateCheckBox; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class MultipleInvalidFacetEditor extends MultipleFacetSettingsEditor { private final MultipleFacetEditorHelperImpl myHelper; - private JPanel myMainPanel; - private ThreeStateCheckBox myIgnoreFacetsCheckBox; + private final JPanel myMainPanel; + private final ThreeStateCheckBox myIgnoreFacetsCheckBox; public MultipleInvalidFacetEditor(FacetEditor[] editors) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myIgnoreFacetsCheckBox = new ThreeStateCheckBox(); + this.$$$loadButtonText$$$(myIgnoreFacetsCheckBox, + this.$$$getMessageFromBundle$$$("messages/LangBundle", "checkbox.ignore.invalid.facets")); + myMainPanel.add(myIgnoreFacetsCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + } myHelper = new MultipleFacetEditorHelperImpl(); myHelper.bind(myIgnoreFacetsCheckBox, editors, editor -> editor.getEditorTab(InvalidFacetEditor.class).getIgnoreCheckBox()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public JComponent createComponent() { return myMainPanel; diff --git a/platform/lang-impl/src/com/intellij/facet/impl/ui/FacetErrorPanel.java b/platform/lang-impl/src/com/intellij/facet/impl/ui/FacetErrorPanel.java index 1c9f2b1dff66..6c73f8c1b936 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/ui/FacetErrorPanel.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/ui/FacetErrorPanel.java @@ -16,6 +16,8 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.ui.UserActivityListener; import com.intellij.ui.UserActivityWatcher; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.SmartList; import com.intellij.util.concurrency.NonUrgentExecutor; import com.intellij.util.containers.ContainerUtil; @@ -23,24 +25,28 @@ import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; public final class FacetErrorPanel { private final JPanel myMainPanel; - private JPanel myButtonPanel; - private JButton myQuickFixButton; + private final JPanel myButtonPanel; + private final JButton myQuickFixButton; private FacetConfigurationQuickFix myCurrentQuickFix; private final JLabel myWarningLabel; private final FacetValidatorsManagerImpl myValidatorsManager; @@ -54,6 +60,18 @@ public final class FacetErrorPanel { public FacetErrorPanel(@Nullable Disposable parentDisposable) { myParentDisposable = parentDisposable; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myButtonPanel = new JPanel(); + myButtonPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myQuickFixButton = new JButton(); + this.$$$loadButtonText$$$(myQuickFixButton, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "button.facet.quickfix.text")); + myButtonPanel.add(myQuickFixButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myValidatorsManager = new FacetValidatorsManagerImpl(); myWarningLabel = new JLabel(); myWarningLabel.setIcon(AllIcons.General.WarningDialog); @@ -73,6 +91,53 @@ public final class FacetErrorPanel { setNoErrors(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myButtonPanel; } + public void addListener(Runnable listener) { myListeners.add(listener); } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/ui/DetectedFrameworksComponent.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/ui/DetectedFrameworksComponent.java index 8cf3d744f432..93ab4ff5d37c 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/ui/DetectedFrameworksComponent.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/ui/DetectedFrameworksComponent.java @@ -10,6 +10,9 @@ import com.intellij.ui.CheckedTreeNode; import com.intellij.ui.EnumComboBoxModel; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import javax.swing.JComboBox; @@ -20,21 +23,59 @@ import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; import java.util.function.Supplier; public final class DetectedFrameworksComponent { - private JPanel myMainPanel; + private final JPanel myMainPanel; private final DetectedFrameworksTree myTree; - private JPanel myTreePanel; - private JComboBox myGroupByComboBox; - private JLabel myDescriptionLabel; - private JPanel myOptionsPanel; + private final JPanel myTreePanel; + private final JComboBox myGroupByComboBox; + private final JLabel myDescriptionLabel; + private final JPanel myOptionsPanel; public DetectedFrameworksComponent(final FrameworkDetectionContext context) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new BorderLayout(0, 5)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, BorderLayout.NORTH); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myGroupByComboBox = new JComboBox(); + panel1.add(myGroupByComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.frameworks.group.by")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTreePanel = new JPanel(); + myTreePanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myTreePanel, BorderLayout.CENTER); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myOptionsPanel, BorderLayout.SOUTH); + myDescriptionLabel = new JLabel(); + myDescriptionLabel.setText("Label"); //NON-NLS + myOptionsPanel.add(myDescriptionLabel, "description"); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myOptionsPanel.add(panel2, "empty"); + label1.setLabelFor(myGroupByComboBox); + } myTree = new DetectedFrameworksTree(context, GroupByOption.TYPE) { @Override protected void onNodeStateChanged(CheckedTreeNode node) { @@ -60,6 +101,53 @@ public final class DetectedFrameworksComponent { updateOptionsPanel(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public DetectedFrameworksTree getTree() { return myTree; } @@ -99,7 +187,8 @@ public final class DetectedFrameworksComponent { myPresentableName = presentableName; } - @NlsContexts.ListItem String getPresentableName() { + @NlsContexts.ListItem + String getPresentableName() { return myPresentableName.get(); } } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/CreateFileFromTemplateDialog.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateFileFromTemplateDialog.java index 61c66dbe032d..de5ebd70677e 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/CreateFileFromTemplateDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CreateFileFromTemplateDialog.java @@ -15,6 +15,9 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Consumer; import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.Nls; @@ -28,25 +31,66 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.ResourceBundle; import java.util.function.BiFunction; import static com.intellij.openapi.util.NlsContexts.DialogTitle; public class CreateFileFromTemplateDialog extends DialogWrapper { - private JTextField myNameField; - private TemplateKindCombo myKindCombo; - private JPanel myPanel; - private JLabel myUpDownHint; - private JLabel myKindLabel; - private JLabel myNameLabel; + private final JTextField myNameField; + private final TemplateKindCombo myKindCombo; + private final JPanel myPanel; + private final JLabel myUpDownHint; + private final JLabel myKindLabel; + private final JLabel myNameLabel; protected CreateFileFromTemplateDialog(@NotNull Project project) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.project.as.template.name")); + myPanel.add(myNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKindLabel = new JLabel(); + this.$$$loadLabelText$$$(myKindLabel, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.file.kind")); + myPanel.add(myKindLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameField = new JTextField(); + myNameField.setColumns(30); + myPanel.add(myNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(250, -1), null, 0, false)); + myUpDownHint = new JLabel(); + myUpDownHint.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/LangBundle", "tooltip.pressing.up.or.down.arrows.while.in.editor.changes.the.kind")); + myPanel.add(myUpDownHint, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myKindCombo = new TemplateKindCombo(); + myPanel.add(myKindCombo, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myNameLabel.setLabelFor(myNameField); + } myKindLabel.setLabelFor(myKindCombo); myKindCombo.registerUpDownHint(myNameField); @@ -55,6 +99,53 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + protected JTextField getNameField() { return myNameField; } @@ -102,7 +193,7 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { private @Nullable Component dialogOwner; private @Nullable BiFunction myKindSelector; - private NonBlockingPopupBuilderImpl(@NotNull Project project) {myProject = project;} + private NonBlockingPopupBuilderImpl(@NotNull Project project) { myProject = project; } @Override public Builder setTitle(@NlsContexts.PopupTitle String title) { @@ -139,7 +230,9 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { } @Override - public @Nullable T show(@NotNull String errorTitle, @Nullable String selectedItem, @NotNull FileCreator creator) { + public @Nullable T show(@NotNull String errorTitle, + @Nullable String selectedItem, + @NotNull FileCreator creator) { throw new UnsupportedOperationException("Modal dialog is not supported by this builder"); } @@ -205,10 +298,12 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { }); Disposer.register(popup, contentPanel); - if (dialogOwner == null) + if (dialogOwner == null) { popup.showCenteredInCurrentWindow(myProject); - else + } + else { popup.showInCenterOf(dialogOwner); + } } @Override @@ -229,8 +324,11 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { public interface Builder { Builder setTitle(@DialogTitle String title); + Builder setValidator(InputValidator validator); + Builder setDefaultText(String text); + Builder setDialogOwner(@Nullable Component owner); default Builder addKind(@NlsContexts.ListItem @NotNull String kind, @Nullable Icon icon, @NonNls @NotNull String templateName) { @@ -253,7 +351,7 @@ public class CreateFileFromTemplateDialog extends DialogWrapper { Consumer elementConsumer); @Nullable - Map getCustomProperties(); + Map getCustomProperties(); default void setKindSelector(BiFunction templateMatcher) { } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java index 2b429005cd7a..56d32bbdffd0 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java @@ -66,6 +66,9 @@ import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.tree.AsyncTreeModel; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import com.intellij.util.concurrency.AppExecutorUtil; @@ -103,13 +106,17 @@ import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -117,15 +124,15 @@ import java.util.concurrent.TimeoutException; public final class ScopeEditorPanel implements Disposable { private static final @NotNull Logger LOG = Logger.getInstance(ScopeEditorPanel.class); - private JPanel myButtonsPanel; - private RawCommandLineEditor myPatternField; - private JPanel myTreeToolbar; + private final JPanel myButtonsPanel; + private final RawCommandLineEditor myPatternField; + private final JPanel myTreeToolbar; private final Tree myPackageTree; private @Nullable Invoker myPackageTreeInvoker; - private JPanel myPanel; - private JPanel myTreePanel; - private JLabel myMatchingCountLabel; - private JPanel myLegendPanel; + private final JPanel myPanel; + private final JPanel myTreePanel; + private final JLabel myMatchingCountLabel; + private final JPanel myLegendPanel; private final Project myProject; private final TreeExpansionMonitor myTreeExpansionMonitor; @@ -136,13 +143,13 @@ public final class ScopeEditorPanel implements Disposable { private @Nls String myErrorMessage; private Future myUpdateAlarm = CompletableFuture.completedFuture(null); - private JLabel myCaretPositionLabel; + private final JLabel myCaretPositionLabel; private int myCaretPosition = 0; - private JPanel myMatchingCountPanel; - private JPanel myPositionPanel; - private JLabel myRecursivelyIncluded; - private JLabel myPartiallyIncluded; - private JBLabel myPatternLegend; + private final JPanel myMatchingCountPanel; + private final JPanel myPositionPanel; + private final JLabel myRecursivelyIncluded; + private final JLabel myPartiallyIncluded; + private final JBLabel myPatternLegend; private PanelProgressIndicator myCurrentProgress; private NamedScopesHolder myHolder; private Boolean myRebuildRequired = null; //updated in EDT only @@ -158,12 +165,102 @@ public final class ScopeEditorPanel implements Disposable { @Topic.ProjectLevel Topic TOPIC = new Topic<>(SettingsChangedListener.class, Topic.BroadcastDirection.TO_CHILDREN); + void settingsChanged(); } public ScopeEditorPanel(final @NotNull Project project, @NotNull NamedScopesHolder holder) { myProject = project; myHolder = holder; + { + myPatternField = new RawCommandLineEditor(text -> Arrays.asList(text.split("\\|\\|")), + strings -> StringUtil.join(strings, "||")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myTreePanel = new JPanel(); + myPanel.add(myTreePanel, new GridConstraints(1, 0, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(-1, 150), null, null, 0, false)); + myButtonsPanel = new JPanel(); + myButtonsPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myButtonsPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myTreeToolbar = new JPanel(); + panel2.add(myTreeToolbar, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMatchingCountPanel = new JPanel(); + myMatchingCountPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(myMatchingCountPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myMatchingCountLabel = new JLabel(); + myMatchingCountLabel.setHorizontalAlignment(4); + myMatchingCountLabel.setHorizontalTextPosition(4); + myMatchingCountLabel.setText(""); + myMatchingCountPanel.add(myMatchingCountLabel, BorderLayout.CENTER); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.scope.pattern")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPositionPanel = new JPanel(); + myPositionPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPositionPanel.setVisible(false); + panel1.add(myPositionPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCaretPositionLabel = new JLabel(); + myCaretPositionLabel.setText(""); + myCaretPositionLabel.setVisible(false); + myPositionPanel.add(myCaretPositionLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + panel1.add(myPatternField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPatternLegend = new JBLabel(); + panel1.add(myPatternLegend, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLegendPanel = new JPanel(); + myLegendPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myLegendPanel, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myRecursivelyIncluded = new JLabel(); + this.$$$loadLabelText$$$(myRecursivelyIncluded, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "scope.editor.legend.recursively.included.label")); + myLegendPanel.add(myRecursivelyIncluded, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myPartiallyIncluded = new JLabel(); + this.$$$loadLabelText$$$(myPartiallyIncluded, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "scope.editor.legend.partly.included.label")); + myLegendPanel.add(myPartiallyIncluded, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + } myPackageTree = new Tree(new RootNode(project)); @@ -180,8 +277,9 @@ public final class ScopeEditorPanel implements Disposable { myTreeMarker = new Marker() { @Override public boolean isMarked(@NotNull VirtualFile file) { - return myCurrentScope != null && (myCurrentScope instanceof PackageSetBase ? ((PackageSetBase)myCurrentScope).contains(file, project, myHolder) - : myCurrentScope.contains(PackageSetBase.getPsiFile(file, myProject), myHolder)); + return myCurrentScope != null && + (myCurrentScope instanceof PackageSetBase ? ((PackageSetBase)myCurrentScope).contains(file, project, myHolder) + : myCurrentScope.contains(PackageSetBase.getPsiFile(file, myProject), myHolder)); } }; @@ -250,7 +348,54 @@ public final class ScopeEditorPanel implements Disposable { } }); } - + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public void dispose() { myIsDisposed = true; @@ -272,7 +417,7 @@ public final class ScopeEditorPanel implements Disposable { return myPanel; } - public JPanel getTreePanel(){ + public JPanel getTreePanel() { JPanel panel = new JPanel(new BorderLayout()); panel.add(myTreePanel, BorderLayout.CENTER); panel.add(myLegendPanel, BorderLayout.SOUTH); @@ -305,15 +450,10 @@ public final class ScopeEditorPanel implements Disposable { updateStatusMessage(); } - private void createUIComponents() { - myPatternField = new RawCommandLineEditor(text -> Arrays.asList(text.split("\\|\\|")), - strings -> StringUtil.join(strings, "||")); - } - private static boolean invalidScopeInside(PackageSet currentScope) { if (currentScope instanceof InvalidPackageSet) return true; if (currentScope instanceof CompoundPackageSet) { - return ContainerUtil.or(((CompoundPackageSet)currentScope).getSets(), s->invalidScopeInside(s)); + return ContainerUtil.or(((CompoundPackageSet)currentScope).getSets(), s -> invalidScopeInside(s)); } if (currentScope instanceof ComplementPackageSet) { return invalidScopeInside(((ComplementPackageSet)currentScope).getComplementarySet()); @@ -488,13 +628,15 @@ public final class ScopeEditorPanel implements Disposable { if (current instanceof UnionPackageSet) { PackageSet[] sets = ((UnionPackageSet)current).getSets(); - PackageSet[] processed = ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]); + PackageSet[] processed = + ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]); return processed.length == 0 ? null : UnionPackageSet.create(processed); } if (current instanceof IntersectionPackageSet) { PackageSet[] sets = ((IntersectionPackageSet)current).getSets(); - PackageSet[] processed = ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]); + PackageSet[] processed = + ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]); return processed.length == 0 ? null : IntersectionPackageSet.create(processed); } @@ -558,7 +700,7 @@ public final class ScopeEditorPanel implements Disposable { } } } - + private void rebuild(final boolean updateText, final @Nullable Runnable runnable, final boolean requestFocus, final int delayMillis) { ThreadingAssertions.assertEventDispatchThread(); myRebuildRequired = false; @@ -680,7 +822,7 @@ public final class ScopeEditorPanel implements Disposable { return new MyPanelProgressIndicator(requestFocus); } - public void cancelCurrentProgress(){ + public void cancelCurrentProgress() { ThreadingAssertions.assertEventDispatchThread(); myUpdateAlarm.cancel(false); if (myCurrentProgress != null) { @@ -697,8 +839,8 @@ public final class ScopeEditorPanel implements Disposable { } public String getPatternText() { - return myPatternField.getText(); - } + return myPatternField.getText(); + } public void reset(PackageSet packageSet, @Nullable Runnable runnable) { myCurrentScope = packageSet; @@ -755,7 +897,7 @@ public final class ScopeEditorPanel implements Disposable { } } - private static final class ChooseScopeTypeAction extends ComboBoxAction{ + private static final class ChooseScopeTypeAction extends ComboBoxAction { private final Runnable myUpdate; ChooseScopeTypeAction(final Runnable update) { @@ -872,7 +1014,8 @@ public final class ScopeEditorPanel implements Disposable { private final @NotNull Consumer> consumer; private List selection; - private MyAction(@NotNull @PropertyKey(resourceBundle = IdeBundle.BUNDLE) String key, @NotNull Consumer> consumer) { + private MyAction(@NotNull @PropertyKey(resourceBundle = IdeBundle.BUNDLE) String key, + @NotNull Consumer> consumer) { super(IdeBundle.message(key)); setEnabled(false); this.consumer = consumer; diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java index d1fcbe4e1e6d..97146aae75ef 100644 --- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java +++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java @@ -13,6 +13,9 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.platform.WebProjectGenerator; import com.intellij.platform.templates.github.GithubTagInfo; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.ReloadableComboBoxPanel; import com.intellij.util.ui.ReloadablePanel; import org.jetbrains.annotations.NotNull; @@ -20,98 +23,120 @@ import org.jetbrains.annotations.Nullable; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; public final class GithubProjectGeneratorPeer implements WebProjectGenerator.GeneratorPeer { - public static String getGithubZipballUrl(String ghUserName,String ghRepoName, String branch) { + public static String getGithubZipballUrl(String ghUserName, String ghRepoName, String branch) { return String.format("https://github.com/%s/%s/zipball/%s", ghUserName, ghRepoName, branch); } - private void createUIComponents() { - myReloadableComboBoxPanel = new ReloadableComboBoxPanel<>() { - - @Override - protected void doUpdateValues(@NotNull Set tags) { - if (!shouldUpdate(tags)) { - return; - } - - List sortedTags = createSortedTagList(tags); - GithubTagInfo selectedItem = getSelectedValue(); - if (selectedItem == null && !sortedTags.isEmpty()) { - selectedItem = sortedTags.get(0); - } - myComboBox.removeAllItems(); - if (myDefaultBranchTag != null) { - myComboBox.addItem(myDefaultBranchTag); - } - for (GithubTagInfo tag : sortedTags) { - myComboBox.addItem(tag); - } - if (selectedItem != null) { - // restore previously selected item - for (int i = 0; i < myComboBox.getItemCount(); i++) { - GithubTagInfo item = GithubTagInfo.tryCast(myComboBox.getItemAt(i)); - if (item != null && item.getName().equals(selectedItem.getName())) { - myComboBox.setSelectedIndex(i); - break; - } - } - } - myComboBox.updateUI(); - fireStateChanged(); - } - - private boolean shouldUpdate(Set newTags) { - if (myComboBox.getItemCount() == 0) { - return true; - } - int count = myComboBox.getItemCount(); - Set oldTags = new HashSet<>(); - for (int i = 1; i < count; i++) { - GithubTagInfo item = myComboBox.getItemAt(i); - if (item != null) { - oldTags.add(item); - } - } - return !oldTags.equals(newTags); - } - - @Override - protected @NotNull JComboBox createValuesComboBox() { - JComboBox box = super.createValuesComboBox(); - box.setRenderer(SimpleListCellRenderer.create((label, tag, index) -> { - final String text; - if (tag == null) { - text = isBackgroundJobRunning() ? CommonBundle.getLoadingTreeNodeText() : LangBundle.message("label.unavailable"); - } - else { - text = tag.getName(); - } - label.setText(text); - })); - - return box; - } - }; - - myVersionPanel = myReloadableComboBoxPanel.getMainPanel(); - } - private final List myListeners = new ArrayList<>(); private final GithubTagInfo myDefaultBranchTag; private final GithubTagListProvider myTagListProvider; - private JComponent myComponent; - private JPanel myVersionPanel; + private final JComponent myComponent; + private final JPanel myVersionPanel; private ReloadablePanel myReloadableComboBoxPanel; public GithubProjectGeneratorPeer(@NotNull AbstractGithubTagDownloadedProjectGenerator generator) { + { + myReloadableComboBoxPanel = new ReloadableComboBoxPanel<>() { + + @Override + protected void doUpdateValues(@NotNull Set tags) { + if (!shouldUpdate(tags)) { + return; + } + + List sortedTags = createSortedTagList(tags); + GithubTagInfo selectedItem = getSelectedValue(); + if (selectedItem == null && !sortedTags.isEmpty()) { + selectedItem = sortedTags.get(0); + } + myComboBox.removeAllItems(); + if (myDefaultBranchTag != null) { + myComboBox.addItem(myDefaultBranchTag); + } + for (GithubTagInfo tag : sortedTags) { + myComboBox.addItem(tag); + } + if (selectedItem != null) { + // restore previously selected item + for (int i = 0; i < myComboBox.getItemCount(); i++) { + GithubTagInfo item = GithubTagInfo.tryCast(myComboBox.getItemAt(i)); + if (item != null && item.getName().equals(selectedItem.getName())) { + myComboBox.setSelectedIndex(i); + break; + } + } + } + myComboBox.updateUI(); + fireStateChanged(); + } + + private boolean shouldUpdate(Set newTags) { + if (myComboBox.getItemCount() == 0) { + return true; + } + int count = myComboBox.getItemCount(); + Set oldTags = new HashSet<>(); + for (int i = 1; i < count; i++) { + GithubTagInfo item = myComboBox.getItemAt(i); + if (item != null) { + oldTags.add(item); + } + } + return !oldTags.equals(newTags); + } + + @Override + protected @NotNull JComboBox createValuesComboBox() { + JComboBox box = super.createValuesComboBox(); + box.setRenderer(SimpleListCellRenderer.create((label, tag, index) -> { + final String text; + if (tag == null) { + text = isBackgroundJobRunning() ? CommonBundle.getLoadingTreeNodeText() : LangBundle.message("label.unavailable"); + } + else { + text = tag.getName(); + } + label.setText(text); + })); + + return box; + } + }; + + myVersionPanel = myReloadableComboBoxPanel.getMainPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myComponent = new JPanel(); + myComponent.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myComponent.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myComponent.add(myVersionPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.github.project.version")); + myComponent.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } String ghUserName = generator.getGithubUserName(); String ghRepoName = generator.getGithubRepositoryName(); String defaultBranchName = generator.getDefaultBranchName(); @@ -137,6 +162,53 @@ public final class GithubProjectGeneratorPeer implements WebProjectGenerator.Gen myReloadableComboBoxPanel.reloadValuesInBackground(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myComponent; } + void onTagsUpdated(@NotNull Set tags) { myReloadableComboBoxPanel.onUpdateValues(tags); } @@ -169,7 +241,8 @@ public final class GithubProjectGeneratorPeer implements WebProjectGenerator.Gen @Override public void buildUI(@NotNull SettingsStep settingsStep) { - settingsStep.addSettingsField(BundleBase.replaceMnemonicAmpersand(IdeBundle.message("github.project.generator.version")), myVersionPanel); + settingsStep.addSettingsField(BundleBase.replaceMnemonicAmpersand(IdeBundle.message("github.project.generator.version")), + myVersionPanel); settingsStep.addSettingsComponent(myReloadableComboBoxPanel.getErrorComponent()); } diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePanel.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePanel.java index a3f9bf8db1b2..f127ab7392ca 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePanel.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePanel.java @@ -5,22 +5,118 @@ import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.fileTypes.FileTypesBundle; import com.intellij.ui.ContextHelpLabel; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import javax.swing.AbstractButton; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; final class FileTypePanel { - JPanel myWholePanel; - JButton myAssociateButton; - JPanel myAssociatePanel; - JBLabel myAssociateMessageLabel; - @SuppressWarnings("unused") private JLabel myAssociateContextHelpLabel; - JPanel myUpperPanel; + final JPanel myWholePanel; + final JButton myAssociateButton; + final JPanel myAssociatePanel; + final JBLabel myAssociateMessageLabel; + @SuppressWarnings("unused") private final JLabel myAssociateContextHelpLabel; + final JPanel myUpperPanel; - private void createUIComponents() { - myAssociateContextHelpLabel = ContextHelpLabel.create( - FileTypesBundle.message("filetype.associate.context.help.text", ApplicationInfo.getInstance().getFullApplicationName()) - ); + public FileTypePanel() { + { + myAssociateContextHelpLabel = ContextHelpLabel.create( + FileTypesBundle.message("filetype.associate.context.help.text", ApplicationInfo.getInstance().getFullApplicationName()) + ); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myAssociatePanel = new JPanel(); + myAssociatePanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(myAssociatePanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myAssociateButton = new JButton(); + this.$$$loadButtonText$$$(myAssociateButton, + this.$$$getMessageFromBundle$$$("messages/FileTypesBundle", "filetype.associate.button")); + myAssociatePanel.add(myAssociateButton, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myAssociatePanel.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myAssociateMessageLabel = new JBLabel(); + myAssociatePanel.add(myAssociateMessageLabel, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAssociatePanel.add(myAssociateContextHelpLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myUpperPanel = new JPanel(); + myUpperPanel.setLayout(new BorderLayout(0, 0)); + myWholePanel.add(myUpperPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + } } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePatternDialog.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePatternDialog.java index 08c06259c6f7..a962d7a4ea94 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePatternDialog.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypePatternDialog.java @@ -7,30 +7,66 @@ import com.intellij.openapi.fileTypes.TemplateLanguageFileType; import com.intellij.openapi.ui.ComboBox; import com.intellij.psi.templateLanguages.TemplateDataLanguageMappings; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.DefaultComboBoxModel; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Comparator; import java.util.List; +import java.util.ResourceBundle; final class FileTypePatternDialog { - private JTextField myPatternField; - private ComboBox myLanguageCombo; - private JLabel myTemplateDataLanguageButton; - private JPanel myMainPanel; + private final JTextField myPatternField; + private final ComboBox myLanguageCombo; + private final JLabel myTemplateDataLanguageButton; + private final JPanel myMainPanel; FileTypePatternDialog(@Nullable String initialPatterns, @NotNull FileType fileType, Language templateDataLanguage) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPatternField = new JTextField(); + myMainPanel.add(myPatternField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/FileTypesBundle", "filetype.edit.add.pattern.prompt")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myTemplateDataLanguageButton = new JLabel(); + this.$$$loadLabelText$$$(myTemplateDataLanguageButton, + this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.template.data.language")); + myMainPanel.add(myTemplateDataLanguageButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myLanguageCombo = new ComboBox(); + myMainPanel.add(myLanguageCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + label1.setLabelFor(myPatternField); + myTemplateDataLanguageButton.setLabelFor(myLanguageCombo); + } myPatternField.setText(initialPatterns); if (fileType instanceof TemplateLanguageFileType) { DefaultComboBoxModel model = (DefaultComboBoxModel)myLanguageCombo.getModel(); model.addElement(null); - List languages = ContainerUtil.sorted(TemplateDataLanguageMappings.getTemplateableLanguages(), Comparator.comparing(Language::getDisplayName)); + List languages = + ContainerUtil.sorted(TemplateDataLanguageMappings.getTemplateableLanguages(), Comparator.comparing(Language::getDisplayName)); for (Language language : languages) { model.addElement(language); } @@ -52,6 +88,53 @@ final class FileTypePatternDialog { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @NotNull JTextField getPatternField() { return myPatternField; diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/associate/ui/FileTypeAssociationForm.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/associate/ui/FileTypeAssociationForm.java index c690fed51cf1..7d58b4263c4d 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/associate/ui/FileTypeAssociationForm.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/associate/ui/FileTypeAssociationForm.java @@ -23,6 +23,8 @@ import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBDimension; import com.intellij.util.ui.JBUI; @@ -42,6 +44,7 @@ import javax.swing.SwingConstants; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.Point; import java.util.ArrayList; import java.util.Collections; @@ -52,15 +55,93 @@ public final class FileTypeAssociationForm { private static final int DEFAULT_EXTENSION_SPLIT_THRESHOLD = 5; - private JPanel myTopPanel; - private JBScrollPane myScrollPane; - private JBLabel myDescLabel; + private final JPanel myTopPanel; + private final JBScrollPane myScrollPane; + private final JBLabel myDescLabel; @SuppressWarnings({"unused", "rawtypes"}) // UI form - private JBList myFileTypesList; - private JBLabel myBottomInfoLabel; + private final JBList myFileTypesList; + private final JBLabel myBottomInfoLabel; private List myItems; public FileTypeAssociationForm() { + { + myItems = createItems(); + presetItems(); + DefaultListModel model = new DefaultListModel<>(); + CheckBoxList checkBoxList = new CheckBoxList<>(model) { + @Override + protected JComponent adjustRendering(JComponent rootComponent, + JCheckBox checkBox, + int index, + boolean selected, + boolean hasFocus) { + MyFileTypeItem item = myItems.get(index); + Color textColor = getForeground(selected); + Color backgroundColor = getBackground(selected); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 2)) { + private final AccessibleContext myContext = checkBox.getAccessibleContext(); + + @Override + public AccessibleContext getAccessibleContext() { + return myContext; + } + }; + if (item.isSubType()) { + panel.add(Box.createRigidArea(new Dimension(JBUIScale.scale(20), 1))); + } + panel.add(checkBox); + if (!item.isSubType() && !item.isGroupItem()) { + JLabel infoLabel = new JLabel(item.getExtensionList(), SwingConstants.LEFT); + infoLabel.setBorder(JBUI.Borders.emptyLeft(JBUIScale.scale(8))); + panel.add(infoLabel); + panel.setBackground(backgroundColor); + infoLabel.setForeground(selected ? textColor : JBColor.GRAY); + infoLabel.setBackground(backgroundColor); + panel.getAccessibleContext().setAccessibleDescription(infoLabel.getText()); + } + panel.setBackground(backgroundColor); + return panel; + } + + @Override + protected @Nullable Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) { + return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index); + } + }; + model.addAll(myItems); + checkBoxList.setCheckBoxListListener(new CheckBoxListListener() { + @Override + public void checkBoxSelectionChanged(int index, boolean value) { + onItemStateChange(myItems.get(index), value); + } + }); + myFileTypesList = checkBoxList; + if (!myFileTypesList.isEmpty()) myFileTypesList.setSelectedIndex(0); + // noinspection rawtypes,unchecked + ListSpeedSearch.installOn(myFileTypesList, o -> ((MyFileTypeItem)o).getText()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myDescLabel = new JBLabel(); + myDescLabel.setText(""); + myTopPanel.add(myDescLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myScrollPane = new JBScrollPane(); + myTopPanel.add(myScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myScrollPane.setViewportView(myFileTypesList); + myBottomInfoLabel = new JBLabel(); + myTopPanel.add(myBottomInfoLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } myTopPanel.setPreferredSize(JBDimension.create(new Dimension(800, 600))); myTopPanel.setBorder(JBUI.Borders.empty()); myScrollPane.setBorder(JBUI.Borders.customLine(JBColor.border())); @@ -71,62 +152,8 @@ public final class FileTypeAssociationForm { myBottomInfoLabel.setForeground(JBColor.GRAY); } - private void createUIComponents() { - myItems = createItems(); - presetItems(); - DefaultListModel model = new DefaultListModel<>(); - CheckBoxList checkBoxList = new CheckBoxList<>(model) { - @Override - protected JComponent adjustRendering(JComponent rootComponent, - JCheckBox checkBox, - int index, - boolean selected, - boolean hasFocus) { - MyFileTypeItem item = myItems.get(index); - Color textColor = getForeground(selected); - Color backgroundColor = getBackground(selected); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 2)) { - private final AccessibleContext myContext = checkBox.getAccessibleContext(); - - @Override - public AccessibleContext getAccessibleContext() { - return myContext; - } - }; - if (item.isSubType()) { - panel.add(Box.createRigidArea(new Dimension(JBUIScale.scale(20),1))); - } - panel.add(checkBox); - if (!item.isSubType() && !item.isGroupItem()) { - JLabel infoLabel = new JLabel(item.getExtensionList(), SwingConstants.LEFT); - infoLabel.setBorder(JBUI.Borders.emptyLeft(JBUIScale.scale(8))); - panel.add(infoLabel); - panel.setBackground(backgroundColor); - infoLabel.setForeground(selected ? textColor : JBColor.GRAY); - infoLabel.setBackground(backgroundColor); - panel.getAccessibleContext().setAccessibleDescription(infoLabel.getText()); - } - panel.setBackground(backgroundColor); - return panel; - } - - @Override - protected @Nullable Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) { - return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index); - } - }; - model.addAll(myItems); - checkBoxList.setCheckBoxListListener(new CheckBoxListListener() { - @Override - public void checkBoxSelectionChanged(int index, boolean value) { - onItemStateChange(myItems.get(index), value); - } - }); - myFileTypesList = checkBoxList; - if (!myFileTypesList.isEmpty()) myFileTypesList.setSelectedIndex(0); - // noinspection rawtypes,unchecked - ListSpeedSearch.installOn(myFileTypesList, o -> ((MyFileTypeItem)o).getText()); - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } public JPanel getTopPanel() { return myTopPanel; @@ -194,8 +221,8 @@ public final class FileTypeAssociationForm { private void onItemStateChange(@NotNull MyFileTypeItem currItem, boolean isSelected) { if (currItem.isGroupItem()) { myItems.stream() - .filter(subItem -> subItem.mySuperType == currItem.myFileType) - .forEach(subItem -> subItem.setSelected(isSelected)); + .filter(subItem -> subItem.mySuperType == currItem.myFileType) + .forEach(subItem -> subItem.setSelected(isSelected)); } else if (currItem.mySuperType != null) { for (MyFileTypeItem item : myItems) { diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/RemoveInvalidElementsDialog.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/RemoveInvalidElementsDialog.java index 9c671f1385d2..a7683dd684c8 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/RemoveInvalidElementsDialog.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/RemoveInvalidElementsDialog.java @@ -11,6 +11,9 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nls; @@ -20,8 +23,10 @@ import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.Insets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -29,9 +34,9 @@ import java.util.Map; @ApiStatus.Internal public final class RemoveInvalidElementsDialog extends DialogWrapper { - private JPanel myContentPanel; - private JPanel myMainPanel; - private JLabel myDescriptionLabel; + private final JPanel myContentPanel; + private final JPanel myMainPanel; + private final JLabel myDescriptionLabel; private final Map myCheckboxes = new HashMap<>(); private RemoveInvalidElementsDialog(@NlsContexts.DialogTitle String title, @@ -40,6 +45,26 @@ public final class RemoveInvalidElementsDialog extends DialogWrapper { Project project, List errors) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myDescriptionLabel = new JLabel(); + myDescriptionLabel.setText(""); + myMainPanel.add(myDescriptionLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMainPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myContentPanel = new JPanel(); + myContentPanel.setLayout(new BorderLayout(0, 0)); + jBScrollPane1.setViewportView(myContentPanel); + } setTitle(title); myDescriptionLabel.setText(ProjectBundle.message( type.canIgnore() ? "label.text.0.cannot.be.loaded.ignore" : "label.text.0.cannot.be.loaded.remove", @@ -66,6 +91,9 @@ public final class RemoveInvalidElementsDialog extends DialogWrapper { setCancelButtonText(ProjectBundle.message("button.text.keep.all")); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + /** * @return {@code true} if the problems are resolved */ diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java index c9ea66cfd734..aeb4fcde1c14 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java @@ -5,6 +5,9 @@ package com.intellij.packageDependencies.ui; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.util.NlsContexts; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Consumer; import com.intellij.util.concurrency.EdtExecutorService; @@ -13,6 +16,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.SwingConstants; +import java.awt.Dimension; +import java.awt.Insets; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -90,11 +95,69 @@ public class PanelProgressIndicator extends ProgressIndicatorBase { } private static final class MyProgressPanel { - public JLabel myFractionLabel; - public JLabel myTextLabel; - public JPanel myPanel; - private JProgressBar myFractionProgress; - private JPanel myLeftPanel; - private JPanel myRightPanel; + public final JLabel myFractionLabel; + public final JLabel myTextLabel; + public final JPanel myPanel; + private final JProgressBar myFractionProgress; + private final JPanel myLeftPanel; + private final JPanel myRightPanel; + + public MyProgressPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, false)); + myFractionLabel = new JLabel(); + myFractionLabel.setHorizontalAlignment(4); + myFractionLabel.setText("0%"); + panel2.add(myFractionLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(30, -1), null, null, 0, false)); + myFractionProgress = new JProgressBar(); + panel2.add(myFractionProgress, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTextLabel = new JLabel(); + myTextLabel.setText(""); + panel1.add(myTextLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLeftPanel = new JPanel(); + myPanel.add(myLeftPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(50, -1), null, 0, false)); + myRightPanel = new JPanel(); + myPanel.add(myRightPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(50, -1), null, 0, false)); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } } } diff --git a/platform/lang-impl/src/com/intellij/platform/templates/SaveProjectAsTemplateDialog.java b/platform/lang-impl/src/com/intellij/platform/templates/SaveProjectAsTemplateDialog.java index 04b6ef853a45..1a0119e8b78d 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/SaveProjectAsTemplateDialog.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/SaveProjectAsTemplateDialog.java @@ -18,22 +18,31 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.EditorTextField; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.io.PathKt; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; import java.io.IOException; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -42,16 +51,62 @@ import java.util.List; public final class SaveProjectAsTemplateDialog extends DialogWrapper { private final @NotNull Project myProject; - private JPanel myPanel; - private JTextField myName; - private EditorTextField myDescription; - private JComboBox myModuleCombo; - private JLabel myModuleLabel; - private JBCheckBox myReplaceParameters; + private final JPanel myPanel; + private final JTextField myName; + private final EditorTextField myDescription; + private final JComboBox myModuleCombo; + private final JLabel myModuleLabel; + private final JBCheckBox myReplaceParameters; SaveProjectAsTemplateDialog(@NotNull Project project, @Nullable VirtualFile descriptionFile) { super(project); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.project.as.template.name")); + myPanel.add(jBLabel1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myName = new JTextField(); + myPanel.add(myName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.project.as.template.description")); + myPanel.add(jBLabel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myDescription = new EditorTextField(); + myPanel.add(myDescription, new GridConstraints(2, 1, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(-1, 60), null, 0, false)); + myModuleCombo = new JComboBox(); + myPanel.add(myModuleCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myModuleLabel = new JLabel(); + this.$$$loadLabelText$$$(myModuleLabel, this.$$$getMessageFromBundle$$$("messages/LangBundle", "label.project.as.template.save")); + myPanel.add(myModuleLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myReplaceParameters = new JBCheckBox(); + myReplaceParameters.setSelected(true); + this.$$$loadButtonText$$$(myReplaceParameters, + this.$$$getMessageFromBundle$$$("messages/LangBundle", "checkbox.replace.parameters.with.placeholders")); + myPanel.add(myReplaceParameters, + new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jBLabel1.setLabelFor(myName); + } setTitle(LangBundle.message("dialog.title.save.project.as.template")); myName.setText(project.getName()); @@ -85,6 +140,78 @@ public final class SaveProjectAsTemplateDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myPanel; diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/DefaultValueChooser.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/DefaultValueChooser.java index d458b67d6e73..aec9ee5933b0 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/DefaultValueChooser.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/DefaultValueChooser.java @@ -9,24 +9,119 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.RadioUpDownListener; import com.intellij.ui.EditorTextField; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; -public final class DefaultValueChooser extends DialogWrapper{ - private JRadioButton myLeaveBlankRadioButton; - private JRadioButton myFeelLuckyRadioButton; - private JLabel myFeelLuckyDescription; - private JRadioButton myUseValueRadioButton; - private EditorTextField myValueEditor; - private JPanel myWholePanel; - private JLabel myBlankDescription; +public final class DefaultValueChooser extends DialogWrapper { + private final JRadioButton myLeaveBlankRadioButton; + private final JRadioButton myFeelLuckyRadioButton; + private final JLabel myFeelLuckyDescription; + private final JRadioButton myUseValueRadioButton; + private final EditorTextField myValueEditor; + private final JPanel myWholePanel; + private final JLabel myBlankDescription; public DefaultValueChooser(Project project, String name, String defaultValue) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridBagLayout()); + myLeaveBlankRadioButton = new JRadioButton(); + Font myLeaveBlankRadioButtonFont = this.$$$getFont$$$(null, Font.BOLD, -1, myLeaveBlankRadioButton.getFont()); + if (myLeaveBlankRadioButtonFont != null) myLeaveBlankRadioButton.setFont(myLeaveBlankRadioButtonFont); + this.$$$loadButtonText$$$(myLeaveBlankRadioButton, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", + "change.signature.leave.blank.default.value")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + myWholePanel.add(myLeaveBlankRadioButton, gbc); + final JPanel spacer1 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + myWholePanel.add(spacer1, gbc); + final JPanel spacer2 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 6; + gbc.fill = GridBagConstraints.VERTICAL; + myWholePanel.add(spacer2, gbc); + myBlankDescription = new JLabel(); + this.$$$loadLabelText$$$(myBlankDescription, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", + "label.change.signature.in.all.calls.to.this.method.leave.the.parameter.blank")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 20, 0, 0); + myWholePanel.add(myBlankDescription, gbc); + myFeelLuckyRadioButton = new JRadioButton(); + Font myFeelLuckyRadioButtonFont = this.$$$getFont$$$(null, Font.BOLD, -1, myFeelLuckyRadioButton.getFont()); + if (myFeelLuckyRadioButtonFont != null) myFeelLuckyRadioButton.setFont(myFeelLuckyRadioButtonFont); + this.$$$loadButtonText$$$(myFeelLuckyRadioButton, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "change.signature.feel.lucky")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 0, 0, 0); + myWholePanel.add(myFeelLuckyRadioButton, gbc); + myFeelLuckyDescription = new JLabel(); + myFeelLuckyDescription.setText(""); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 20, 0, 0); + myWholePanel.add(myFeelLuckyDescription, gbc); + myUseValueRadioButton = new JRadioButton(); + Font myUseValueRadioButtonFont = this.$$$getFont$$$(null, Font.BOLD, -1, myUseValueRadioButton.getFont()); + if (myUseValueRadioButtonFont != null) myUseValueRadioButton.setFont(myUseValueRadioButtonFont); + this.$$$loadButtonText$$$(myUseValueRadioButton, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "change.signature.use.selected.value")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 4; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 0, 0, 0); + myWholePanel.add(myUseValueRadioButton, gbc); + myValueEditor = new EditorTextField(); + myValueEditor.setMinimumSize(new Dimension(10, 24)); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 5; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(0, 20, 0, 0); + myWholePanel.add(myValueEditor, gbc); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myLeaveBlankRadioButton); + buttonGroup.add(myFeelLuckyRadioButton); + buttonGroup.add(myUseValueRadioButton); + } RadioUpDownListener.installOn(myLeaveBlankRadioButton, myFeelLuckyRadioButton, myUseValueRadioButton); final ActionListener actionListener = new ActionListener() { @Override @@ -34,7 +129,8 @@ public final class DefaultValueChooser extends DialogWrapper{ myValueEditor.setEnabled(myUseValueRadioButton.isSelected()); if (myUseValueRadioButton.isSelected()) { myValueEditor.selectAll(); - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myValueEditor, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myValueEditor, true)); } } }; @@ -51,6 +147,102 @@ public final class DefaultValueChooser extends DialogWrapper{ init(); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public boolean feelLucky() { return myFeelLuckyRadioButton.isSelected(); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java index acccfd39b00c..8023b7bc16bb 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java @@ -16,30 +16,42 @@ import com.intellij.refactoring.util.AbstractParameterTablePanel.NameColumnInfo; import com.intellij.refactoring.util.AbstractParameterTablePanel.PassParameterColumnInfo; import com.intellij.refactoring.util.AbstractVariableData; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.TitledSeparator; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.ColumnInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.ResourceBundle; import java.util.stream.Stream; public class AbstractExtractMethodDialog extends DialogWrapper implements ExtractMethodSettings { - private JPanel myContentPane; - private AbstractParameterTablePanel myParametersPanel; - private JTextField myMethodNameTextField; - protected MethodSignatureComponent mySignaturePreviewTextArea; - private JTextArea myOutputVariablesTextArea; + private final JPanel myContentPane; + private final AbstractParameterTablePanel myParametersPanel; + private final JTextField myMethodNameTextField; + protected final MethodSignatureComponent mySignaturePreviewTextArea; + private final JTextArea myOutputVariablesTextArea; private final ComboBoxVisibilityPanel myVisibilityComboBox; protected final Project myProject; private final String myDefaultName; @@ -74,7 +86,97 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Ext getRememberedVisibility(visibilityVariants).ifPresent(myVisibilityComboBox::setVisibility); myVisibilityComboBox.addListener(event -> rememberCurrentVisibility()); - $$$setupUI$$$(); + { + myParametersPanel = + new AbstractParameterTablePanel<>(getParameterColumns()) { + + @Override + protected void doCancelAction() { + AbstractExtractMethodDialog.this.doCancelAction(); + } + + @Override + protected void doEnterAction() { + doOKAction(); + } + + @Override + protected void updateSignature() { + updateOutputVariables(); + AbstractExtractMethodDialog.this.updateSignature(); + } + }; + mySignaturePreviewTextArea = new MethodSignatureComponent("", myProject, myFileType); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, 1, null, null, null, 0, + false)); + myMethodNameTextField = new JTextField(); + myMethodNameTextField.setColumns(10); + myMethodNameTextField.setHorizontalAlignment(2); + panel1.add(myMethodNameTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", + "refactoring.extract.method.dialog.method.name")); + panel1.add(label1, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myVisibilityComboBox, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myContentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/RefactoringBundle", + "refactoring.extract.method.dialog.parameters"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + panel2.add(myParametersPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myContentPane.add(jBScrollPane1, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, 1, null, null, null, 0, + false)); + jBScrollPane1.setViewportView(mySignaturePreviewTextArea); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + myContentPane.add(jBScrollPane2, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, 1, null, null, null, 0, + false)); + myOutputVariablesTextArea = new JTextArea(); + myOutputVariablesTextArea.setEditable(false); + jBScrollPane2.setViewportView(myOutputVariablesTextArea); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText( + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "refactoring.extract.method.dialog.signature.preview")); + titledSeparator1.putClientProperty("BorderFactoryClass", ""); + myContentPane.add(titledSeparator1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator2 = new TitledSeparator(); + titledSeparator2.setText( + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "refactoring.extract.method.dialog.output.variables")); + titledSeparator2.putClientProperty("BorderFactoryClass", ""); + myContentPane.add(titledSeparator2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myArguments = new ArrayList<>(fragment.getInputVariables()); Collections.sort(myArguments); @@ -85,9 +187,53 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Ext init(); } - private void $$$setupUI$$$() { + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + @Override protected void init() { super.init(); @@ -153,12 +299,13 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Ext @Override protected void doOKAction() { final String error = myValidator.check(getMethodName()); - if (error != null){ - if (ApplicationManager.getApplication().isUnitTestMode()){ + if (error != null) { + if (ApplicationManager.getApplication().isUnitTestMode()) { Messages.showInfoMessage(error, RefactoringBundle.message("error.title")); return; } - if (Messages.showOkCancelDialog(error + ". " + RefactoringBundle.message("do.you.wish.to.continue"), RefactoringBundle.message("warning.title"), Messages.getWarningIcon()) != Messages.OK){ + if (Messages.showOkCancelDialog(error + ". " + RefactoringBundle.message("do.you.wish.to.continue"), + RefactoringBundle.message("warning.title"), Messages.getWarningIcon()) != Messages.OK) { return; } } @@ -175,29 +322,6 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Ext return myContentPane; } - private void createUIComponents() { - myParametersPanel = - new AbstractParameterTablePanel<>(getParameterColumns()) { - - @Override - protected void doCancelAction() { - AbstractExtractMethodDialog.this.doCancelAction(); - } - - @Override - protected void doEnterAction() { - doOKAction(); - } - - @Override - protected void updateSignature() { - updateOutputVariables(); - AbstractExtractMethodDialog.this.updateSignature(); - } - }; - mySignaturePreviewTextArea = new MethodSignatureComponent("", myProject, myFileType); - } - protected @NotNull ColumnInfo @NotNull [] getParameterColumns() { return new ColumnInfo[]{new PassParameterColumnInfo(), new NameColumnInfo(myValidator::isValidName)}; } @@ -219,12 +343,13 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Ext final StringBuilder builder = new StringBuilder(); boolean first = true; for (String variable : myOutputVariables) { - if (myVariablesMap!=null){ + if (myVariablesMap != null) { final AbstractVariableData data = myVariablesMap.get(variable); final String outputName = data != null ? data.getName() : variable; - if (first){ + if (first) { first = false; - } else { + } + else { builder.append(", "); } builder.append(outputName); diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduceParameterObject/AbstractIntroduceParameterObjectDialog.java b/platform/lang-impl/src/com/intellij/refactoring/introduceParameterObject/AbstractIntroduceParameterObjectDialog.java index 3662e9445371..1d8209d80095 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduceParameterObject/AbstractIntroduceParameterObjectDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduceParameterObject/AbstractIntroduceParameterObjectDialog.java @@ -9,31 +9,42 @@ import com.intellij.refactoring.changeSignature.ParameterInfo; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.refactoring.util.AbstractParameterTablePanel; import com.intellij.refactoring.util.AbstractVariableData; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public abstract class AbstractIntroduceParameterObjectDialog, - V extends AbstractVariableData> extends RefactoringDialog { + P extends ParameterInfo, + C extends IntroduceParameterObjectClassDescriptor, + V extends AbstractVariableData> extends RefactoringDialog { protected @NotNull M mySourceMethod; - private JPanel myWholePanel; - private JTextField mySourceMethodTextField; - protected JCheckBox myDelegateCheckBox; - private JPanel myParamsPanel; - private JPanel myParameterClassPanel; + private final JPanel myWholePanel; + private final JTextField mySourceMethodTextField; + protected final JCheckBox myDelegateCheckBox; + private final JPanel myParamsPanel; + private final JPanel myParameterClassPanel; protected AbstractParameterTablePanel myParameterTablePanel; protected abstract String getSourceMethodPresentation(); + protected abstract JPanel createParameterClassPanel(); + protected abstract AbstractParameterTablePanel createParametersPanel(); protected abstract C createClassDescriptor(); @@ -45,9 +56,106 @@ public abstract class AbstractIntroduceParameterObjectDialog>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.putClientProperty("BorderFactoryClass", ""); + myParameterClassPanel = new JPanel(); + myParameterClassPanel.setLayout(new BorderLayout(0, 0)); + myParameterClassPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myWholePanel.add(myParameterClassPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myParameterClassPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/RefactoringBundle", "border.title.introduce.parameter.class"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, + null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/RefactoringBundle", "refactoring.introduce.parameter.object.method.to.extract.parameters.from.label"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySourceMethodTextField = new JTextField(); + panel1.add(mySourceMethodTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(400, -1), null, 0, false)); + myDelegateCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myDelegateCheckBox, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", + "checkbox.introduce.parameter.object.keep.method.as.delegate")); + panel1.add(myDelegateCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myParamsPanel = new JPanel(); + myParamsPanel.setLayout(new BorderLayout(0, 0)); + myParamsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myWholePanel.add(myParamsPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myParamsPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/RefactoringBundle", "border.title.introduce.parameters.to.extract"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + } setTitle(RefactoringBundle.message("refactoring.introduce.parameter.object.title")); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override protected void doAction() { final IntroduceParameterObjectDelegate delegate = IntroduceParameterObjectDelegate.findDelegate(mySourceMethod); diff --git a/platform/lang-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java b/platform/lang-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java index 65411255c627..9c98e7b1c959 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java @@ -8,6 +8,8 @@ import com.intellij.psi.PsiNamedElement; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.refactoring.util.CommonRefactoringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.usageView.UsageViewUtil; import org.jetbrains.annotations.ApiStatus; @@ -15,19 +17,43 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; @ApiStatus.Internal public final class InvertBooleanDialog extends RefactoringDialog { - private JTextField myNameField; - private JPanel myPanel; - private JLabel myLabel; - private JLabel myCaptionLabel; + private final JTextField myNameField; + private final JPanel myPanel; + private final JLabel myLabel; + private final JLabel myCaptionLabel; private final PsiElement myElement; public InvertBooleanDialog(final PsiElement element) { super(element.getProject(), false); myElement = element; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myLabel = new JLabel(); + myLabel.setInheritsPopupMenu(false); + myLabel.setText(""); + myPanel.add(myLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameField = new JTextField(); + myPanel.add(myNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myCaptionLabel = new JLabel(); + myCaptionLabel.setText(""); + myPanel.add(myCaptionLabel, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } final String name = myElement instanceof PsiNamedElement ? ((PsiNamedElement)myElement).getName() : myElement.getText(); myNameField.setText(name); myLabel.setLabelFor(myNameField); @@ -41,6 +67,9 @@ public final class InvertBooleanDialog extends RefactoringDialog { init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myNameField; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java index 7a081bc677c9..94764e3b0d68 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java @@ -32,7 +32,10 @@ import com.intellij.ui.PopupHandler; import com.intellij.ui.TableUtil; import com.intellij.ui.components.JBBox; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.usageView.UsageInfo; import com.intellij.usages.UsageViewPresentation; import com.intellij.usages.impl.UsagePreviewPanel; @@ -40,6 +43,8 @@ import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComponent; @@ -50,6 +55,7 @@ import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumnModel; @@ -57,11 +63,16 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; public class AutomaticRenamingDialog extends DialogWrapper { private static final int CHECK_COLUMN = 0; @@ -75,15 +86,15 @@ public class AutomaticRenamingDialog extends DialogWrapper { private final PsiNamedElement[] myRenames; private final MyTableModel myTableModel; - private JPanel myPanel; - private JSplitPane mySplitPane; - private JBTable myTable; - private JPanel myOptionsPanel; - private JBCheckBox mySearchInComments; - private JBCheckBox mySearchTextOccurrences; - private JButton mySelectAllButton; - private JButton myUnselectAllButton; - private JPanel myPanelForPreview; + private final JPanel myPanel; + private final JSplitPane mySplitPane; + private final JBTable myTable; + private final JPanel myOptionsPanel; + private final JBCheckBox mySearchInComments; + private final JBCheckBox mySearchTextOccurrences; + private final JButton mySelectAllButton; + private final JButton myUnselectAllButton; + private final JPanel myPanelForPreview; private UsagePreviewPanel myUsagePreviewPanel; private JLabel myUsageFileLabel; private ListSelectionListener myListSelectionListener; @@ -92,6 +103,92 @@ public class AutomaticRenamingDialog extends DialogWrapper { super(project, true); myProject = project; myRenamer = renamer; + { + myTable = new JBTable(); + myTable.setRowHeight(myTable.getFontMetrics(UIManager.getFont("Table.font").deriveFont(Font.BOLD)).getHeight() + 4); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + mySplitPane = new JSplitPane(); + mySplitPane.setDividerLocation(300); + mySplitPane.setOrientation(0); + myPanel.add(mySplitPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + mySplitPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + mySplitPane.setLeftComponent(panel1); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + panel1.add(jBScrollPane1, gbc); + jBScrollPane1.setViewportView(myTable); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.VERTICAL; + panel1.add(myOptionsPanel, gbc); + mySearchInComments = new JBCheckBox(); + this.$$$loadButtonText$$$(mySearchInComments, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.in.comments.and.strings")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + myOptionsPanel.add(mySearchInComments, gbc); + mySearchTextOccurrences = new JBCheckBox(); + this.$$$loadButtonText$$$(mySearchTextOccurrences, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "search.for.text.occurrences")); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 10, 0, 0); + myOptionsPanel.add(mySearchTextOccurrences, gbc); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.EAST; + gbc.fill = GridBagConstraints.VERTICAL; + panel1.add(panel2, gbc); + mySelectAllButton = new JButton(); + this.$$$loadButtonText$$$(mySelectAllButton, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "select.all.button")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.EAST; + panel2.add(mySelectAllButton, gbc); + myUnselectAllButton = new JButton(); + this.$$$loadButtonText$$$(myUnselectAllButton, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "unselect.all.button")); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(0, 5, 0, 0); + panel2.add(myUnselectAllButton, gbc); + myPanelForPreview = new JPanel(); + myPanelForPreview.setLayout(new BorderLayout(0, 0)); + myPanelForPreview.setPreferredSize(new Dimension(300, 100)); + mySplitPane.setRightComponent(myPanelForPreview); + } Map renames = renamer.getRenames(); @@ -119,11 +216,53 @@ public class AutomaticRenamingDialog extends DialogWrapper { init(); } - private void createUIComponents() { - myTable = new JBTable(); - myTable.setRowHeight(myTable.getFontMetrics(UIManager.getFont("Table.font").deriveFont(Font.BOLD)).getHeight() + 4); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected String getDimensionServiceKey() { return "#com.intellij.refactoring.rename.AutomaticRenamingDialog"; @@ -358,7 +497,7 @@ public class AutomaticRenamingDialog extends DialogWrapper { @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return columnIndex != OLD_NAME_COLUMN && (myAllowRename || columnIndex != NEW_NAME_COLUMN) - && !(myRenames[rowIndex] instanceof SyntheticElement); + && !(myRenames[rowIndex] instanceof SyntheticElement); } @Override @@ -419,21 +558,22 @@ public class AutomaticRenamingDialog extends DialogWrapper { int[] selectedRows = myTable.getSelectedRows(); String initial = (String)myModel.getValueAt(selectedRows[0], NEW_NAME_COLUMN); String newName = Messages.showInputDialog(myTable, RefactoringBundle.message("automatic.renaming.dialog.new.name.label"), - RefactoringBundle.message("automatic.renaming.dialog.rename.selected.title"), null, initial, new InputValidatorEx() { - @Override - public boolean canClose(String inputString) { - return checkInput(inputString); - } + RefactoringBundle.message("automatic.renaming.dialog.rename.selected.title"), null, initial, + new InputValidatorEx() { + @Override + public boolean canClose(String inputString) { + return checkInput(inputString); + } - @Override - public @Nullable String getErrorText(@NlsSafe String inputString) { - final int selectedRow = myTable.getSelectedRow(); - if (!isValidName(inputString, selectedRow)) { - return RefactoringBundle.message("text.identifier.invalid", inputString); - } - return null; - } - }); + @Override + public @Nullable String getErrorText(@NlsSafe String inputString) { + final int selectedRow = myTable.getSelectedRow(); + if (!isValidName(inputString, selectedRow)) { + return RefactoringBundle.message("text.identifier.invalid", inputString); + } + return null; + } + }); if (newName == null) return; for (int i : selectedRows) { diff --git a/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettingsConfigurable.java b/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettingsConfigurable.java index 00a6a026297d..83d14ae369fb 100644 --- a/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettingsConfigurable.java +++ b/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettingsConfigurable.java @@ -10,31 +10,71 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.RawCommandLineEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import static com.intellij.ide.SpecialConfigFiles.CHROME_USER_DATA; public class ChromeSettingsConfigurable implements Configurable { private final ChromeSettings mySettings; - private JPanel myMainPanel; - private JCheckBox myUseCustomProfileCheckBox; - private TextFieldWithBrowseButton myUserDataDirField; - private JLabel myCommandLineOptionsLabel; - private RawCommandLineEditor myCommandLineOptionsEditor; + private final JPanel myMainPanel; + private final JCheckBox myUseCustomProfileCheckBox; + private final TextFieldWithBrowseButton myUserDataDirField; + private final JLabel myCommandLineOptionsLabel; + private final RawCommandLineEditor myCommandLineOptionsEditor; private final String myDefaultUserDirPath; public ChromeSettingsConfigurable(@NotNull ChromeSettings settings) { mySettings = settings; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myUseCustomProfileCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseCustomProfileCheckBox, this.$$$getMessageFromBundle$$$("messages/IdeBundle", + "checkbox.use.custom.user.data.directory.for.chrome")); + myMainPanel.add(myUseCustomProfileCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myUserDataDirField = new TextFieldWithBrowseButton(); + myMainPanel.add(myUserDataDirField, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(350, -1), null, 2, false)); + myCommandLineOptionsEditor = new RawCommandLineEditor(); + myMainPanel.add(myCommandLineOptionsEditor, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myCommandLineOptionsLabel = new JLabel(); + this.$$$loadLabelText$$$(myCommandLineOptionsLabel, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.chrome.command.line.options")); + myMainPanel.add(myCommandLineOptionsLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } myUserDataDirField.addBrowseFolderListener(null, FileChooserDescriptorFactory.createSingleFolderDescriptor() .withTitle(IdeBundle.message("chooser.title.select.user.data.directory")) .withDescription(IdeBundle.message("chooser.description.specifies.user.data.directory"))); @@ -49,6 +89,78 @@ public class ChromeSettingsConfigurable implements Configurable { myCommandLineOptionsLabel.setLabelFor(myCommandLineOptionsEditor.getTextField()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public JComponent createComponent() { return myMainPanel; diff --git a/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java b/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java index d991c0149ecf..1e9883fec0a7 100644 --- a/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java +++ b/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java @@ -12,6 +12,9 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.PathUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -19,16 +22,21 @@ import org.jetbrains.annotations.Nullable; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public class FirefoxSettingsConfigurable implements Configurable { - private JPanel myMainPanel; - private JComboBox myProfileCombobox; - private TextFieldWithBrowseButton myProfilesIniPathField; + private final JPanel myMainPanel; + private final JComboBox myProfileCombobox; + private final TextFieldWithBrowseButton myProfilesIniPathField; private final FirefoxSettings mySettings; private String myLastProfilesIniPath; private @NlsSafe String myDefaultProfilesIniPath; @@ -36,7 +44,61 @@ public class FirefoxSettingsConfigurable implements Configurable { public FirefoxSettingsConfigurable(FirefoxSettings settings) { mySettings = settings; - myProfilesIniPathField.addBrowseFolderListener(null, createProfilesIniChooserDescriptor().withTitle(IdeBundle.message("chooser.title.select.profiles.ini.file"))); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.text.path.to.profiles.ini")); + panel2.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myProfilesIniPathField = new TextFieldWithBrowseButton(); + panel1.add(myProfilesIniPathField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(350, -1), null, 2, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.text.profile")); + panel3.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myProfileCombobox = new JComboBox(); + panel3.add(myProfileCombobox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + label2.setLabelFor(myProfileCombobox); + } + myProfilesIniPathField.addBrowseFolderListener(null, createProfilesIniChooserDescriptor().withTitle( + IdeBundle.message("chooser.title.select.profiles.ini.file"))); myProfilesIniPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { @@ -45,6 +107,53 @@ public class FirefoxSettingsConfigurable implements Configurable { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public static FileChooserDescriptor createProfilesIniChooserDescriptor() { return new FileChooserDescriptor(true, false, false, false, false, false) { @Override diff --git a/platform/platform-api/src/com/intellij/openapi/ui/NamedConfigurable.java b/platform/platform-api/src/com/intellij/openapi/ui/NamedConfigurable.java index 896868e5b53b..de36ceba7b7c 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/NamedConfigurable.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/NamedConfigurable.java @@ -10,6 +10,8 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.ErrorLabel; import com.intellij.ui.JBColor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -17,18 +19,23 @@ import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public abstract class NamedConfigurable implements Configurable { - private JTextField myNameField; - private JPanel myNamePanel; - private JPanel myWholePanel; - private JPanel myOptionsPanel; - private JPanel myTopRightPanel; - private ErrorLabel myErrorLabel; + private final JTextField myNameField; + private final JPanel myNamePanel; + private final JPanel myWholePanel; + private final JPanel myOptionsPanel; + private final JPanel myTopRightPanel; + private final ErrorLabel myErrorLabel; private JComponent myOptionsComponent; private final boolean myNameEditable; private final @Nullable Runnable myUpdateTree; @@ -50,9 +57,89 @@ public abstract class NamedConfigurable implements Configurable { @SuppressWarnings("unused") private NamedConfigurable(boolean fake) { this(); - $$$setupUI$$$(); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new BorderLayout(0, 0)); + myWholePanel.add(myOptionsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myNamePanel = new JPanel(); + myNamePanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(myNamePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myErrorLabel = new ErrorLabel(); + this.$$$loadLabelText$$$(myErrorLabel, this.$$$getMessageFromBundle$$$("messages/CommonBundle", "name.label.text")); + myNamePanel.add(myErrorLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myNameField = new JTextField(); + myNamePanel.add(myNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTopRightPanel = new JPanel(); + myTopRightPanel.setLayout(new BorderLayout(0, 0)); + myNamePanel.add(myTopRightPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myErrorLabel.setLabelFor(myNameField); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public boolean isNameEditable() { return myNameEditable; } @@ -67,7 +154,9 @@ public abstract class NamedConfigurable implements Configurable { } public abstract void setDisplayName(@NlsSafe String name); + public abstract T getEditableObject(); + public abstract @NlsContexts.DetailedDescription String getBannerSlogan(); @Override @@ -122,9 +211,6 @@ public abstract class NamedConfigurable implements Configurable { } } - private void $$$setupUI$$$() { - } - protected void checkName(@NonNls @NotNull String name) throws ConfigurationException { if (name.isEmpty()) { throw new ConfigurationException(IdeBundle.message("error.name.cannot.be.empty")); diff --git a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java index 618bbddfde7e..92e79ccab844 100644 --- a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java +++ b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java @@ -2,13 +2,18 @@ package com.intellij.ui; import com.intellij.openapi.util.Pair; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.ComponentWithEmptyText; import com.intellij.util.ui.StatusText; import org.jetbrains.annotations.NotNull; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; import java.util.ArrayList; import java.util.List; @@ -17,13 +22,32 @@ import java.util.List; * This component represents a list of checkboxes. */ public abstract class OptionalChooserComponent implements CheckBoxListListener, ComponentWithEmptyText { - private JPanel myContentPane; - private CheckBoxList myList; + private final JPanel myContentPane; + private final CheckBoxList myList; private DefaultListModel myListModel; private List> myInitialList; private ArrayList> myWorkingList; public OptionalChooserComponent(final @NotNull List> list) { + { + myList = new CheckBoxList(this); + myList.setBorder(null); + myListModel = (DefaultListModel)myList.getModel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myContentPane.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myList.setSelectionMode(0); + jBScrollPane1.setViewportView(myList); + } setInitialList(list); myWorkingList = new ArrayList<>(myInitialList); @@ -31,6 +55,9 @@ public abstract class OptionalChooserComponent implements CheckBoxListListene reset(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + @Override public @NotNull StatusText getEmptyText() { return myList.getEmptyText(); @@ -46,12 +73,6 @@ public abstract class OptionalChooserComponent implements CheckBoxListListene myWorkingList.add(index, Pair.create(pair.first, value)); } - private void createUIComponents() { - myList = new CheckBoxList(this); - myList.setBorder(null); - myListModel = (DefaultListModel)myList.getModel(); - } - public void reset() { myWorkingList = new ArrayList<>(myInitialList); refresh(); diff --git a/platform/platform-api/src/com/intellij/util/net/AuthenticationPanel.java b/platform/platform-api/src/com/intellij/util/net/AuthenticationPanel.java index d917c20c6e96..a1171d5b0007 100644 --- a/platform/platform-api/src/com/intellij/util/net/AuthenticationPanel.java +++ b/platform/platform-api/src/com/intellij/util/net/AuthenticationPanel.java @@ -1,19 +1,27 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.net; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * Panel for authentication - contains text fields for login and password, and a checkbox to remember @@ -23,32 +31,144 @@ import javax.swing.JTextField; * @author Kirill Likhodedov */ public class AuthenticationPanel extends JPanel { - private JPanel myMainPanel; - private JLabel myDescriptionLabel; - private JTextField myLoginTextField; - private JPasswordField myPasswordTextField; - private JCheckBox rememberPasswordCheckBox; + private final JPanel myMainPanel; + private final JLabel myDescriptionLabel; + private final JTextField myLoginTextField; + private final JPasswordField myPasswordTextField; + private final JCheckBox rememberPasswordCheckBox; /** - * @param description Description text above the text fields. - * @param login Initial login value. - * @param password Initial password value. - * @param rememberPassword Default value for the 'remember password' checkbox. - * If true, the checkbox will be selected; if false, the checkbox won't be selected; if null, there will be no checkbox for remembering - * password. + * @param description Description text above the text fields. + * @param login Initial login value. + * @param password Initial password value. + * @param rememberPassword Default value for the 'remember password' checkbox. + * If true, the checkbox will be selected; if false, the checkbox won't be selected; if null, there will be no checkbox for remembering + * password. */ - public AuthenticationPanel(@Nullable @NlsContexts.Label String description, @Nullable String login, @Nullable String password, @Nullable Boolean rememberPassword) { + public AuthenticationPanel(@Nullable @NlsContexts.Label String description, + @Nullable String login, + @Nullable String password, + @Nullable Boolean rememberPassword) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(10, 10, 10, 10), -1, -1)); + myDescriptionLabel = new JLabel(); + myDescriptionLabel.setText("##"); + myMainPanel.add(myDescriptionLabel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIBundle", "auth.password.label")); + myMainPanel.add(label1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myPasswordTextField = new JPasswordField(); + myMainPanel.add(myPasswordTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myLoginTextField = new JTextField(); + myMainPanel.add(myLoginTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/UIBundle", "auth.login.label")); + myMainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + rememberPasswordCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(rememberPasswordCheckBox, this.$$$getMessageFromBundle$$$("messages/UIBundle", "auth.remember.cb")); + myMainPanel.add(rememberPasswordCheckBox, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } add(myMainPanel); myDescriptionLabel.setText(description); myLoginTextField.setText(login); myPasswordTextField.setText(password); if (rememberPassword == null) { rememberPasswordCheckBox.setVisible(false); - } else { + } + else { rememberPasswordCheckBox.setSelected(rememberPassword); } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public @NotNull String getLogin() { return StringUtil.notNullize(myLoginTextField.getText()); } @@ -57,16 +177,15 @@ public class AuthenticationPanel extends JPanel { return ObjectUtils.notNull(myPasswordTextField.getPassword(), ArrayUtilRt.EMPTY_CHAR_ARRAY); } - public boolean isRememberPassword () { + public boolean isRememberPassword() { return rememberPasswordCheckBox.isSelected(); } /** * @return the component which should be focused when the dialog appears on the screen. May be used in dialogs. - * @see com.intellij.openapi.ui.DialogWrapper#getPreferredFocusedComponent() + * @see DialogWrapper#getPreferredFocusedComponent() */ public JComponent getPreferredFocusedComponent() { return getLogin().isEmpty() ? myLoginTextField : myPasswordTextField; } - } diff --git a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateWarningDialog.java b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateWarningDialog.java index 3218cb962d83..7f922beee2ec 100644 --- a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateWarningDialog.java +++ b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateWarningDialog.java @@ -14,18 +14,32 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.HtmlBuilder; import com.intellij.openapi.util.text.HtmlChunk; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.HTMLEditorKitBuilder; import com.intellij.util.ui.JBDimension; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.security.cert.X509Certificate; +import java.util.Locale; +import java.util.ResourceBundle; /** * @author Mikhail Golubev @@ -45,20 +59,20 @@ public class CertificateWarningDialog extends DialogWrapper { } public static CertificateWarningDialog createUntrustedCertificateWarning(@NotNull X509Certificate certificate) { - return createUntrustedCertificateWarning(certificate, null,null); + return createUntrustedCertificateWarning(certificate, null, null); } public static CertificateWarningDialog createExpiredCertificateWarning(@NotNull X509Certificate certificate) { throw new UnsupportedOperationException("Not supported"); } - private JPanel myRootPanel; - private JLabel myWarningSign; - private JPanel myCertificateInfoPanel; - private JTextPane myNoticePane; - private JTextPane myMessagePane; - private JPanel myRemoteHostPanel; - private JBLabel myRemoteHostLabel; + private final JPanel myRootPanel; + private final JLabel myWarningSign; + private final JPanel myCertificateInfoPanel; + private final JTextPane myNoticePane; + private final JTextPane myMessagePane; + private final JPanel myRemoteHostPanel; + private final JBLabel myRemoteHostLabel; private final X509Certificate myCertificate; public CertificateWarningDialog(@NotNull X509Certificate certificate, @@ -66,6 +80,75 @@ public class CertificateWarningDialog extends DialogWrapper { @NotNull @NlsContexts.DialogTitle String title, @NotNull @NlsContexts.DetailedDescription String message) { super((Project)null, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 10, 0, 10), -1, -1)); + myRootPanel.setMinimumSize(new Dimension(-1, -1)); + myRootPanel.setOpaque(false); + myCertificateInfoPanel = new JPanel(); + myCertificateInfoPanel.setLayout(new BorderLayout(0, 0)); + myRootPanel.add(myCertificateInfoPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myCertificateInfoPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, new Color(-16777216))); + final JBLabel jBLabel1 = new JBLabel(); + Font jBLabel1Font = this.$$$getFont$$$(null, Font.BOLD, -1, jBLabel1.getFont()); + if (jBLabel1Font != null) jBLabel1.setFont(jBLabel1Font); + jBLabel1.setRequestFocusEnabled(true); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.ssl.certificate.details")); + myCertificateInfoPanel.add(jBLabel1, BorderLayout.NORTH); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myNoticePane = new JTextPane(); + myNoticePane.setContentType("text/html"); + myNoticePane.setOpaque(false); + myNoticePane.setText("\n \n \n \n \n \n\n"); //NON-NLS + panel1.add(myNoticePane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(50, 50), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myWarningSign = new JLabel(); + myWarningSign.setText(""); + myRootPanel.add(myWarningSign, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myMessagePane = new JTextPane(); + myMessagePane.setContentType("text/html"); + myMessagePane.setEditable(false); + myMessagePane.setOpaque(true); + myRootPanel.add(myMessagePane, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(150, 50), null, 0, false)); + myRemoteHostPanel = new JPanel(); + myRemoteHostPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(myRemoteHostPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + Font jBLabel2Font = this.$$$getFont$$$(null, Font.BOLD, -1, jBLabel2.getFont()); + if (jBLabel2Font != null) jBLabel2.setFont(jBLabel2Font); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.ssl.certificate.remoteHost")); + myRemoteHostPanel.add(jBLabel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRemoteHostLabel = new JBLabel(); + myRemoteHostPanel.add(myRemoteHostLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } myRootPanel.setPreferredSize(new JBDimension(550, 650)); myNoticePane.setEditorKit(HTMLEditorKitBuilder.simple()); @@ -112,6 +195,77 @@ public class CertificateWarningDialog extends DialogWrapper { LOG.debug("Preferred size: " + getPreferredSize()); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myRootPanel; diff --git a/platform/platform-impl/initial-config-import/src/com/intellij/ide/ImportOldConfigsPanel.java b/platform/platform-impl/initial-config-import/src/com/intellij/ide/ImportOldConfigsPanel.java index 81f3e82edfe6..e1787d760ecc 100644 --- a/platform/platform-impl/initial-config-import/src/com/intellij/ide/ImportOldConfigsPanel.java +++ b/platform/platform-impl/initial-config-import/src/com/intellij/ide/ImportOldConfigsPanel.java @@ -17,12 +17,17 @@ import com.intellij.openapi.vfs.local.CoreLocalFileSystem; import com.intellij.openapi.vfs.local.CoreLocalVirtualFile; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.ComponentUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.system.OS; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JOptionPane; @@ -31,21 +36,25 @@ import javax.swing.JRadioButton; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.BorderLayout; import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Insets; import java.io.IOException; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import java.util.ResourceBundle; import java.util.function.Function; import java.util.zip.ZipFile; public final class ImportOldConfigsPanel extends JDialog { - private JPanel myRootPanel; - private JRadioButton myRbImportAuto; - private JRadioButton myRbImport; - private TextFieldWithBrowseButton myPrevInstallation; - private JRadioButton myRbDoNotImport; - private JButton myOkButton; - private ComboBox myComboBoxOldPaths; + private final JPanel myRootPanel; + private final JRadioButton myRbImportAuto; + private final JRadioButton myRbImport; + private final TextFieldWithBrowseButton myPrevInstallation; + private final JRadioButton myRbDoNotImport; + private final JButton myOkButton; + private final ComboBox myComboBoxOldPaths; private final List myGuessedOldConfigDirs; private final Function> myValidator; @@ -55,6 +64,62 @@ public final class ImportOldConfigsPanel extends JDialog { public ImportOldConfigsPanel(@NotNull List guessedOldConfigDirs, @NotNull Function> validator) { super((Dialog)null, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRbImportAuto = new JRadioButton(); + this.$$$loadButtonText$$$(myRbImportAuto, this.$$$getMessageFromBundle$$$("messages/BootstrapBundle", "import.chooser.rb.previous")); + panel1.add(myRbImportAuto, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRbImport = new JRadioButton(); + this.$$$loadButtonText$$$(myRbImport, this.$$$getMessageFromBundle$$$("messages/BootstrapBundle", "import.chooser.rb.choose")); + panel1.add(myRbImport, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPrevInstallation = new TextFieldWithBrowseButton(); + panel1.add(myPrevInstallation, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myRbDoNotImport = new JRadioButton(); + this.$$$loadButtonText$$$(myRbDoNotImport, this.$$$getMessageFromBundle$$$("messages/BootstrapBundle", "import.chooser.rb.skip")); + panel1.add(myRbDoNotImport, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myComboBoxOldPaths = new ComboBox(); + panel1.add(myComboBoxOldPaths, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myOkButton = new JButton(); + this.$$$loadButtonText$$$(myOkButton, this.$$$getMessageFromBundle$$$("messages/BootstrapBundle", "import.chooser.ok")); + panel2.add(myOkButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(80, -1), null, null, 5, false)); + final Spacer spacer3 = new Spacer(); + myRootPanel.add(spacer3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } ComponentUtil.decorateWindowHeader(rootPane); @@ -65,6 +130,53 @@ public final class ImportOldConfigsPanel extends JDialog { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + private void init() { MnemonicHelper.init(getContentPane()); diff --git a/platform/platform-impl/internal/src/com/intellij/internal/validation/ValidTest.java b/platform/platform-impl/internal/src/com/intellij/internal/validation/ValidTest.java index c497d7295c04..452112da1e92 100644 --- a/platform/platform-impl/internal/src/com/intellij/internal/validation/ValidTest.java +++ b/platform/platform-impl/internal/src/com/intellij/internal/validation/ValidTest.java @@ -1,25 +1,141 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.internal.validation; +import com.intellij.openapi.ui.ComboBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + +import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; /** * @author Konstantin Bulenkov */ public final class ValidTest { - public JTextField field1; - public JTextField field2; - public JPanel panel; - public JComboBox field3; - public JRadioButton field4A; - public JRadioButton field4B; - public JPanel p4; - public JCheckBox field5; - public JComboBox comboBox; - public JSpinner spinner; + public final JTextField field1; + public final JTextField field2; + public final JPanel panel; + public final JComboBox field3; + public final JRadioButton field4A; + public final JRadioButton field4B; + public final JPanel p4; + public final JCheckBox field5; + public final JComboBox comboBox; + public final JSpinner spinner; + + public ValidTest() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + label1.setText("Field1:"); + panel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel.add(spacer2, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Field2:"); + panel.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Field3:"); + panel.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("Field4:"); + panel.add(label4, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + p4 = new JPanel(); + p4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel.add(p4, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + field4A = new JRadioButton(); + field4A.setText("a"); + p4.add(field4A, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + field4B = new JRadioButton(); + field4B.setText("b"); + p4.add(field4B, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("Field5:"); + panel.add(label5, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + field5 = new JCheckBox(); + field5.setText("I agree with all license agreement"); + panel.add(field5, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + field3 = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement(""); + defaultComboBoxModel1.addElement("aaa"); + defaultComboBoxModel1.addElement("bbb"); + defaultComboBoxModel1.addElement("ccc"); + field3.setModel(defaultComboBoxModel1); + panel.add(field3, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + field2 = new JTextField(); + panel.add(field2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + field1 = new JTextField(); + panel.add(field1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel.add(panel1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 2), new Dimension(-1, 2), + new Dimension(-1, 2), 0, false)); + comboBox = new ComboBox(); + comboBox.setEditable(true); + final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); + defaultComboBoxModel2.addElement("One"); + defaultComboBoxModel2.addElement("Two"); + defaultComboBoxModel2.addElement("Three"); + defaultComboBoxModel2.addElement("Four"); + comboBox.setModel(defaultComboBoxModel2); + panel.add(comboBox, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + spinner = new JSpinner(); + panel.add(spinner, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + label1.setLabelFor(field1); + label2.setLabelFor(field2); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } } diff --git a/platform/platform-impl/remote/src/com/intellij/remote/ui/CreateRemoteSdkForm.java b/platform/platform-impl/remote/src/com/intellij/remote/ui/CreateRemoteSdkForm.java index 4b6bbb4e69b1..c103c07201a4 100644 --- a/platform/platform-impl/remote/src/com/intellij/remote/ui/CreateRemoteSdkForm.java +++ b/platform/platform-impl/remote/src/com/intellij/remote/ui/CreateRemoteSdkForm.java @@ -30,6 +30,9 @@ import com.intellij.ui.StatusPanel; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.UIUtil; @@ -39,8 +42,10 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.AncestorEvent; @@ -50,12 +55,14 @@ import java.awt.CardLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Insets; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -65,25 +72,26 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; public abstract class CreateRemoteSdkForm extends JPanel implements RemoteSdkEditorForm, Disposable { - private JPanel myMainPanel; - private JBLabel myInterpreterPathLabel; - protected TextFieldWithBrowseButton myInterpreterPathField; - protected TextFieldWithBrowseButton myHelpersPathField; - private JTextField myNameField; - private JBLabel myNameLabel; - private JBLabel myHelpersPathLabel; - private JPanel myStatusPanelHolder; + private final JPanel myMainPanel; + private final JBLabel myInterpreterPathLabel; + protected final TextFieldWithBrowseButton myInterpreterPathField; + protected final TextFieldWithBrowseButton myHelpersPathField; + private final JTextField myNameField; + private final JBLabel myNameLabel; + private final JBLabel myHelpersPathLabel; + private final JPanel myStatusPanelHolder; private final StatusPanel myStatusPanel; - private JPanel myRadioPanel; - private JPanel myTypesPanel; - private JPanel myRunAsRootViaSudoPanel; - private JBCheckBox myRunAsRootViaSudoJBCheckBox; - private JPanel myRunAsRootViaSudoHelpPanel; - private ButtonGroup myTypeButtonGroup; + private final JPanel myRadioPanel; + private final JPanel myTypesPanel; + private final JPanel myRunAsRootViaSudoPanel; + private final JBCheckBox myRunAsRootViaSudoJBCheckBox; + private final JPanel myRunAsRootViaSudoHelpPanel; + private final ButtonGroup myTypeButtonGroup; private boolean myNameVisible; private final Project myProject; @@ -114,6 +122,104 @@ public abstract class CreateRemoteSdkForm ext super(new BorderLayout()); myProject = project; myParentContainer = parentContainer; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(10, 4, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(-1, 10), null, null, 0, false)); + myInterpreterPathLabel = new JBLabel(); + this.$$$loadLabelText$$$(myInterpreterPathLabel, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.remote.sdk.python.interpreter.path")); + myMainPanel.add(myInterpreterPathLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myInterpreterPathField = new TextFieldWithBrowseButton(); + myMainPanel.add(myInterpreterPathField, + new GridConstraints(4, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myHelpersPathLabel = new JBLabel(); + this.$$$loadLabelText$$$(myHelpersPathLabel, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.remote.sdk.helpers.path")); + myMainPanel.add(myHelpersPathLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myHelpersPathField = new TextFieldWithBrowseButton(); + myMainPanel.add(myHelpersPathField, new GridConstraints(6, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myNameLabel = new JBLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.remote.sdk.name")); + myMainPanel.add(myNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myNameField = new JTextField(); + myMainPanel.add(myNameField, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myStatusPanelHolder = new JPanel(); + myStatusPanelHolder.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myStatusPanelHolder, new GridConstraints(8, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myStatusPanelHolder.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myTypesPanel = new JPanel(); + myTypesPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myTypesPanel, new GridConstraints(3, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel2, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRadioPanel = new JPanel(); + myRadioPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 5, 0)); + panel2.add(myRadioPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRunAsRootViaSudoPanel = new JPanel(); + myRunAsRootViaSudoPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myRunAsRootViaSudoPanel, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myRunAsRootViaSudoJBCheckBox = new JBCheckBox(); + myRunAsRootViaSudoJBCheckBox.setHorizontalAlignment(2); + myRunAsRootViaSudoJBCheckBox.setHorizontalTextPosition(11); + this.$$$loadButtonText$$$(myRunAsRootViaSudoJBCheckBox, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "checkbox.remote.sdk.run.as.root.via.sudo")); + myRunAsRootViaSudoJBCheckBox.setToolTipText(""); + myRunAsRootViaSudoPanel.add(myRunAsRootViaSudoJBCheckBox, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myRunAsRootViaSudoHelpPanel = new JPanel(); + myRunAsRootViaSudoHelpPanel.setLayout(new BorderLayout(0, 0)); + myRunAsRootViaSudoPanel.add(myRunAsRootViaSudoHelpPanel, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myNameLabel.setLabelFor(myNameField); + myTypeButtonGroup = new ButtonGroup(); + } Disposer.register(parentContainer.getDisposable(), this); mySdkScopeController = sdkScopeController; myBundleAccessor = bundleAccessor; @@ -149,7 +255,7 @@ public abstract class CreateRemoteSdkForm ext myRunAsRootViaSudoJBCheckBox.setText( bundleAccessor.message("remote.interpreter.configure.ssh.run_as_root_via_sudo.checkbox")); myRunAsRootViaSudoHelpPanel.add(ContextHelpLabel.create( - bundleAccessor.message("remote.interpreter.configure.ssh.run_as_root_via_sudo.help")), + bundleAccessor.message("remote.interpreter.configure.ssh.run_as_root_via_sudo.help")), BorderLayout.WEST); } else { @@ -164,6 +270,78 @@ public abstract class CreateRemoteSdkForm ext radioSelected(true); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public void showBrowsePathsDialog(@NotNull TextFieldWithBrowseButton textFieldWithBrowseButton, @NlsContexts.DialogTitle @NotNull String dialogTitle) { if (myConnectionType instanceof PathsBrowserDialogProvider) { @@ -482,19 +660,26 @@ public abstract class CreateRemoteSdkForm ext } private interface TypeHandler { - @NotNull JPanel getContentComponent(); + @NotNull + JPanel getContentComponent(); - @NotNull JBRadioButton getRadioButton(); + @NotNull + JBRadioButton getRadioButton(); void onSelected(); - @NlsSafe @Nullable String getInterpreterPath(); + @NlsSafe + @Nullable + String getInterpreterPath(); void setInterpreterPath(@Nullable String interpreterPath); - @Nullable ValidationInfo validate(); + @Nullable + ValidationInfo validate(); - @NlsContexts.DialogMessage @Nullable String validateFinal(); + @NlsContexts.DialogMessage + @Nullable + String validateFinal(); boolean isBrowsingAvailable(); } diff --git a/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java b/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java index 03652d623db1..ecc0fa128804 100644 --- a/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java +++ b/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java @@ -10,6 +10,7 @@ import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.options.colors.AbstractKeyDescriptor; import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider; +import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.Pair; @@ -18,7 +19,11 @@ import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.ColorPanel; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.BitUtil; import com.intellij.util.EventDispatcher; import com.intellij.util.FontUtil; @@ -28,37 +33,44 @@ import com.intellij.util.ui.StartupUiUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; +import java.util.ResourceBundle; public final class ColorAndFontDescriptionPanel extends JPanel implements OptionsPanelImpl.ColorDescriptionPanel { private final EventDispatcher myDispatcher = EventDispatcher.create(Listener.class); - private JPanel myPanel; + private final JPanel myPanel; - private ColorPanel myBackgroundChooser; - private ColorPanel myForegroundChooser; - private ColorPanel myEffectsColorChooser; - private ColorPanel myErrorStripeColorChooser; + private final ColorPanel myBackgroundChooser; + private final ColorPanel myForegroundChooser; + private final ColorPanel myEffectsColorChooser; + private final ColorPanel myErrorStripeColorChooser; - private JBCheckBox myCbBackground; - private JBCheckBox myCbForeground; - private JBCheckBox myCbEffects; - private JBCheckBox myCbErrorStripe; + private final JBCheckBox myCbBackground; + private final JBCheckBox myCbForeground; + private final JBCheckBox myCbEffects; + private final JBCheckBox myCbErrorStripe; private final Map myEffectsMap; + { Map map = new LinkedHashMap<>(); map.put(ApplicationBundle.message("combobox.effect.underscored"), EffectType.LINE_UNDERSCORE); @@ -70,23 +82,119 @@ public final class ColorAndFontDescriptionPanel extends JPanel implements Option map.put(ApplicationBundle.message("combobox.effect.faded"), EffectType.FADED); myEffectsMap = Collections.unmodifiableMap(map); } - private JComboBox myEffectsCombo; - private JBCheckBox myCbBold; - private JBCheckBox myCbItalic; - private JLabel myLabelFont; - private JTextPane myInheritanceLabel; + private final JComboBox myEffectsCombo; - private JBCheckBox myInheritAttributesBox; + private final JBCheckBox myCbBold; + private final JBCheckBox myCbItalic; + private final JLabel myLabelFont; + private final JTextPane myInheritanceLabel; + + private final JBCheckBox myInheritAttributesBox; private boolean myUiEventsEnabled = true; public ColorAndFontDescriptionPanel() { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(10, 3, new Insets(0, 10, 10, 10), -1, -1)); + myCbForeground = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbForeground, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.color.foreground")); + myPanel.add(myCbForeground, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbBackground = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbBackground, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.color.background")); + myPanel.add(myCbBackground, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbErrorStripe = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbErrorStripe, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.color.error.stripe.mark")); + myPanel.add(myCbErrorStripe, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbEffects = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbEffects, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.color.effects")); + myPanel.add(myCbEffects, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myForegroundChooser = new ColorPanel(); + myPanel.add(myForegroundChooser, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myBackgroundChooser = new ColorPanel(); + myPanel.add(myBackgroundChooser, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myErrorStripeColorChooser = new ColorPanel(); + myPanel.add(myErrorStripeColorChooser, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myEffectsColorChooser = new ColorPanel(); + myPanel.add(myEffectsColorChooser, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(30, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(6, 0, 3, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + true)); + myInheritAttributesBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myInheritAttributesBox, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "label.inherit.attributes")); + panel1.add(myInheritAttributesBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + jBScrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myInheritanceLabel = new JTextPane(); + myInheritanceLabel.setText("labl"); //NON-NLS + jBScrollPane1.setViewportView(myInheritanceLabel); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myCbBold = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbBold, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.font.bold")); + panel2.add(myCbBold, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbItalic = new JBCheckBox(); + this.$$$loadButtonText$$$(myCbItalic, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.font.italic")); + panel2.add(myCbItalic, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLabelFont = new JLabel(); + this.$$$loadLabelText$$$(myLabelFont, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "label.font.type")); + panel2.add(myLabelFont, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEffectsCombo = new ComboBox(); + myPanel.add(myEffectsCombo, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(8, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } add(myPanel, BorderLayout.CENTER); setBorder(JBUI.Borders.empty(4, 0, 4, 4)); myEffectsCombo.setModel(new CollectionComboBoxModel<>(new ArrayList<>(myEffectsMap.keySet()))); - myEffectsCombo.setRenderer(BuilderKt.textListCellRenderer(IdeBundle.message("label.invalid.color"), s -> s) ); + myEffectsCombo.setRenderer(BuilderKt.textListCellRenderer(IdeBundle.message("label.invalid.color"), s -> s)); ActionListener actionListener = e -> { if (myUiEventsEnabled) { @@ -100,7 +208,8 @@ public final class ColorAndFontDescriptionPanel extends JPanel implements Option } }; - for (JBCheckBox c : new JBCheckBox[]{myCbBackground, myCbForeground, myCbEffects, myCbErrorStripe, myCbItalic, myCbBold, myInheritAttributesBox}) { + for (JBCheckBox c : new JBCheckBox[]{myCbBackground, myCbForeground, myCbEffects, myCbErrorStripe, myCbItalic, myCbBold, + myInheritAttributesBox}) { c.addActionListener(actionListener); } for (ColorPanel c : new ColorPanel[]{myBackgroundChooser, myForegroundChooser, myEffectsColorChooser, myErrorStripeColorChooser}) { @@ -115,6 +224,78 @@ public final class ColorAndFontDescriptionPanel extends JPanel implements Option myLabelFont.setVisible(false); // hide for now as it doesn't look that good } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull JComponent getPanel() { return this; @@ -318,5 +499,4 @@ public final class ColorAndFontDescriptionPanel extends JPanel implements Option public void addListener(@NotNull Listener listener) { myDispatcher.addListener(listener); } - } diff --git a/platform/platform-impl/src/com/intellij/application/options/colors/RainbowDescriptionPanel.java b/platform/platform-impl/src/com/intellij/application/options/colors/RainbowDescriptionPanel.java index 492a4e8caf3b..fa810e689ce8 100644 --- a/platform/platform-impl/src/com/intellij/application/options/colors/RainbowDescriptionPanel.java +++ b/platform/platform-impl/src/com/intellij/application/options/colors/RainbowDescriptionPanel.java @@ -14,6 +14,10 @@ import com.intellij.openapi.util.text.HtmlChunk; import com.intellij.ui.ColorPanel; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import com.intellij.util.FontUtil; import com.intellij.util.ui.JBDimension; @@ -23,43 +27,145 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public final class RainbowDescriptionPanel extends JPanel implements OptionsPanelImpl.ColorDescriptionPanel { private final EventDispatcher myDispatcher = EventDispatcher.create(Listener.class); - JPanel myPanel; + final JPanel myPanel; - private JBLabel myLStop1; - private JBLabel myLStop2; - private JBLabel myLStop3; - private JBLabel myLStop4; - private JBLabel myLStop5; + private final JBLabel myLStop1; + private final JBLabel myLStop2; + private final JBLabel myLStop3; + private final JBLabel myLStop4; + private final JBLabel myLStop5; private final JBLabel[] myLStops = new JBLabel[]{myLStop1, myLStop2, myLStop3, myLStop4, myLStop5}; - ColorPanel myStop1; - ColorPanel myStop2; - ColorPanel myStop3; - ColorPanel myStop4; - ColorPanel myStop5; + final ColorPanel myStop1; + final ColorPanel myStop2; + final ColorPanel myStop3; + final ColorPanel myStop4; + final ColorPanel myStop5; private final ColorPanel[] myStops = new ColorPanel[]{myStop1, myStop2, myStop3, myStop4, myStop5}; - private JBCheckBox myRainbow; - private JTextPane myInheritanceLabel; - private JBCheckBox myInheritAttributesBox; - private JPanel myOverwrittenPanel; + private final JBCheckBox myRainbow; + private final JTextPane myInheritanceLabel; + private final JBCheckBox myInheritAttributesBox; + private final JPanel myOverwrittenPanel; public RainbowDescriptionPanel() { super(new BorderLayout()); + { + createOverwritePanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(10, 4, new Insets(0, 10, 10, 10), -1, -1)); + myRainbow = new JBCheckBox(); + this.$$$loadButtonText$$$(myRainbow, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.rainbow")); + myRainbow.setVerticalTextPosition(0); + myPanel.add(myRainbow, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(9, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myStop1 = new ColorPanel(); + myPanel.add(myStop1, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myStop2 = new ColorPanel(); + myPanel.add(myStop2, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myStop3 = new ColorPanel(); + myPanel.add(myStop3, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myStop4 = new ColorPanel(); + myPanel.add(myStop4, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myStop5 = new ColorPanel(); + myPanel.add(myStop5, new GridConstraints(7, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(8, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(30, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + true)); + myInheritAttributesBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myInheritAttributesBox, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "label.inherit.attributes")); + panel1.add(myInheritAttributesBox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + jBScrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myInheritanceLabel = new JTextPane(); + myInheritanceLabel.setText("labl"); //NON-NLS + jBScrollPane1.setViewportView(myInheritanceLabel); + myLStop1 = new JBLabel(); + this.$$$loadLabelText$$$(myLStop1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.stop.1")); + myPanel.add(myLStop1, + new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLStop2 = new JBLabel(); + this.$$$loadLabelText$$$(myLStop2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.stop.2")); + myPanel.add(myLStop2, + new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLStop3 = new JBLabel(); + this.$$$loadLabelText$$$(myLStop3, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.stop.3")); + myPanel.add(myLStop3, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLStop4 = new JBLabel(); + this.$$$loadLabelText$$$(myLStop4, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.stop.4")); + myPanel.add(myLStop4, + new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLStop5 = new JBLabel(); + this.$$$loadLabelText$$$(myLStop5, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.stop.5")); + myPanel.add(myLStop5, + new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "rainbow.option.description")); + myPanel.add(jBLabel1, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myPanel.add(myOverwrittenPanel, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } add(myPanel, BorderLayout.CENTER); setBorder(JBUI.Borders.empty(4, 0, 4, 4)); @@ -90,6 +196,78 @@ public final class RainbowDescriptionPanel extends JPanel implements OptionsPane myInheritanceLabel.setBorder(JBUI.Borders.empty(4, 0, 4, 4)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void createOverwritePanel() { myOverwrittenPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JLabel iconLabel = new JLabel(); @@ -101,10 +279,6 @@ public final class RainbowDescriptionPanel extends JPanel implements OptionsPane myOverwrittenPanel.setVisible(false); } - private void createUIComponents() { - createOverwritePanel(); - } - @Contract(pure = true) private static @NotNull String checkRightArrow(@NotNull String str) { return str.replaceAll("->", FontUtil.rightArrow(StartupUiUtil.getLabelFont())); @@ -167,7 +341,8 @@ public final class RainbowDescriptionPanel extends JPanel implements OptionsPane : Boolean.valueOf(myRainbow.isSelected())); for (int i = 0; i < myStops.length; ++i) { - scheme.setAttributes(RainbowHighlighter.RAINBOW_COLOR_KEYS[i], RainbowHighlighter.createRainbowAttribute(myStops[i].getSelectedColor())); + scheme.setAttributes(RainbowHighlighter.RAINBOW_COLOR_KEYS[i], + RainbowHighlighter.createRainbowAttribute(myStops[i].getSelectedColor())); } descriptor.apply(scheme); } diff --git a/platform/platform-impl/src/com/intellij/application/options/pathMacros/PathMacroEditor.java b/platform/platform-impl/src/com/intellij/application/options/pathMacros/PathMacroEditor.java index e1f1514a0ac9..62e90c40e8e3 100644 --- a/platform/platform-impl/src/com/intellij/application/options/pathMacros/PathMacroEditor.java +++ b/platform/platform-impl/src/com/intellij/application/options/pathMacros/PathMacroEditor.java @@ -8,29 +8,74 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsSafe; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class PathMacroEditor extends DialogWrapper { - private JTextField myNameField; - private JPanel myPanel; - private TextFieldWithBrowseButton myValueField; + private final JTextField myNameField; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myValueField; private final Validator myValidator; public interface Validator { boolean checkName(String name); + boolean isOK(String name, String value); } public PathMacroEditor(@NlsContexts.DialogTitle String title, @NlsSafe String macroName, @NlsSafe String value, Validator validator) { super(true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myNameField = new JTextField(); + panel1.add(myNameField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(100, -1), null, 0, false)); + myValueField = new TextFieldWithBrowseButton(); + panel1.add(myValueField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(200, -1), null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "editbox.path.macro.name")); + panel2.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "editbox.path.macro.value")); + panel2.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } setTitle(title); myValidator = validator; myNameField.setText(macroName); @@ -64,6 +109,53 @@ public final class PathMacroEditor extends DialogWrapper { updateControls(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void setMacroNameEditable(boolean isEditable) { myNameField.setEditable(isEditable); } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.java index 8935674d0d01..4d8b25927dc3 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.java @@ -13,6 +13,9 @@ import com.intellij.openapi.util.text.HtmlBuilder; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBEmptyBorder; import com.intellij.util.ui.JBUI; @@ -25,7 +28,9 @@ import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -41,9 +46,9 @@ public final class PluginConflictDialog extends DialogWrapper { private final boolean myIsConflictWithPlatform; private final @Nullable List myRadioButtons; - private JPanel myContentPane; - private JBLabel myTopMessageLabel; - private JPanel myConflictingPluginsListPanel; + private final JPanel myContentPane; + private final JBLabel myTopMessageLabel; + private final JPanel myConflictingPluginsListPanel; public PluginConflictDialog(@NotNull List conflictingPlugins, boolean isConflictWithPlatform) { super(false); @@ -58,7 +63,41 @@ public final class PluginConflictDialog extends DialogWrapper { myRadioButtons = new ArrayList<>(); } - $$$setupUI$$$(); + { + final ButtonGroup buttonGroup = new ButtonGroup(); + + myConflictingPluginsListPanel = new JPanel(new GridLayout(0, 1)); + final List pluginDescriptions = + ContainerUtil.map(myConflictingPlugins, plugin -> getChooserPanelForPlugin(buttonGroup, plugin)); + pluginDescriptions.forEach(myConflictingPluginsListPanel::add); + + if (!myIsConflictWithPlatform) { + JPanel chooserPanelForPlugin = getChooserPanelForPlugin(buttonGroup, null); + myConflictingPluginsListPanel.add(chooserPanelForPlugin); + } + + setUpDefaultSelection(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.setPreferredSize(new Dimension(400, -1)); + myTopMessageLabel = new JBLabel(); + myContentPane.add(myTopMessageLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myContentPane.add(myConflictingPluginsListPanel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } setTitle(DiagnosticBundle.message("error.dialog.conflict.plugin.title")); init(); setCrossClosesWindow(false); @@ -69,6 +108,9 @@ public final class PluginConflictDialog extends DialogWrapper { myContentPane.setPreferredSize(JBUI.size(WIDTH, (int)myContentPane.getMinimumSize().getHeight())); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + private static @NlsContexts.Label String getTopMessageText(@NotNull List conflictingPlugins, boolean isConflictWithPlatform) { final int pluginsNumber = conflictingPlugins.size(); if (isConflictWithPlatform) { @@ -85,30 +127,11 @@ public final class PluginConflictDialog extends DialogWrapper { } } - private void $$$setupUI$$$() { - } - @Override protected @Nullable JComponent createCenterPanel() { return myContentPane; } - private void createUIComponents() { - final ButtonGroup buttonGroup = new ButtonGroup(); - - myConflictingPluginsListPanel = new JPanel(new GridLayout(0, 1)); - final List pluginDescriptions = - ContainerUtil.map(myConflictingPlugins, plugin -> getChooserPanelForPlugin(buttonGroup, plugin)); - pluginDescriptions.forEach(myConflictingPluginsListPanel::add); - - if (!myIsConflictWithPlatform) { - JPanel chooserPanelForPlugin = getChooserPanelForPlugin(buttonGroup, null); - myConflictingPluginsListPanel.add(chooserPanelForPlugin); - } - - setUpDefaultSelection(); - } - private @NotNull JPanel getChooserPanelForPlugin(@NotNull ButtonGroup buttonGroup, @Nullable PluginId plugin) { final JPanel panel = new JPanel(new BorderLayout()); if (!myIsConflictWithPlatform) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java index 67464e374bd3..e3b78f196b3a 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java @@ -26,6 +26,9 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.AppUIUtil; import com.intellij.ui.AppUIUtilKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ExceptionUtil; import com.intellij.util.Restarter; import com.intellij.util.system.OS; @@ -34,14 +37,18 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.io.IOException; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; +import java.util.ResourceBundle; @ApiStatus.Internal public final class CreateDesktopEntryAction extends DumbAwareAction implements ActionRemoteBehaviorSpecification.Disabled { @@ -176,17 +183,111 @@ public final class CreateDesktopEntryAction extends DumbAwareAction implements A public static final class CreateDesktopEntryDialog extends DialogWrapper { private static final @NlsSafe String APP_NAME_PLACEHOLDER = "$APP_NAME$"; - private JPanel myContentPane; - private JLabel myLabel; - private JCheckBox myGlobalEntryCheckBox; + private final JPanel myContentPane; + private final JLabel myLabel; + private final JCheckBox myGlobalEntryCheckBox; public CreateDesktopEntryDialog(Project project) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); + myGlobalEntryCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myGlobalEntryCheckBox, this.$$$getMessageFromBundle$$$("messages/IdeBundle", + "checkbox.create.the.entry.for.all.users.requires.superuser.privileges")); + myContentPane.add(myGlobalEntryCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 1, false)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLabel = new JLabel(); + this.$$$loadLabelText$$$(myLabel, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.you.can.create.a.desktop.entry")); + myContentPane.add(myLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + } init(); setTitle(ApplicationBundle.message("desktop.entry.title")); myLabel.setText(myLabel.getText().replace(APP_NAME_PLACEHOLDER, ApplicationNamesInfo.getInstance().getProductName())); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + @Override protected JComponent createCenterPanel() { return myContentPane; diff --git a/platform/platform-impl/src/com/intellij/ide/browsers/StartBrowserPanel.java b/platform/platform-impl/src/com/intellij/ide/browsers/StartBrowserPanel.java index b94401fd9e29..c1fd2ec310d0 100644 --- a/platform/platform-impl/src/com/intellij/ide/browsers/StartBrowserPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/browsers/StartBrowserPanel.java @@ -20,27 +20,100 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.ui.AncestorListenerAdapter; import com.intellij.ui.ComboboxWithBrowseButton; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Url; import com.intellij.util.io.URLUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.AncestorEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class StartBrowserPanel { - private JCheckBox myStartBrowserCheckBox; - private ComboboxWithBrowseButton myBrowserComboBox; + private final JCheckBox myStartBrowserCheckBox; + private final ComboboxWithBrowseButton myBrowserComboBox; - private JCheckBox myStartJavaScriptDebuggerCheckBox; + private final JCheckBox myStartJavaScriptDebuggerCheckBox; - private TextFieldWithBrowseButton myUrlField; + private final TextFieldWithBrowseButton myUrlField; private BrowserSelector myBrowserSelector; - private JPanel myRoot; + private final JPanel myRoot; public StartBrowserPanel() { + { + myBrowserSelector = new BrowserSelector(); + myBrowserComboBox = (ComboboxWithBrowseButton)myBrowserSelector.getMainComponent(); + myBrowserComboBox.getComboBox().addActionListener(e -> { + myStartJavaScriptDebuggerCheckBox.setEnabled(isDebugAllowed(myBrowserSelector.getSelected())); + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(3, 4, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/IdeBundle", + "start.browser.border.label.open.browser"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myRoot.add(spacer2, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myStartBrowserCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myStartBrowserCheckBox, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "start.browser.checkbox.start.browser")); + myStartBrowserCheckBox.setVerticalTextPosition(0); + myRoot.add(myStartBrowserCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRoot.add(myBrowserComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myStartJavaScriptDebuggerCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myStartJavaScriptDebuggerCheckBox, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "start.browser.with.js.debugger")); + myRoot.add(myStartJavaScriptDebuggerCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel1, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myUrlField = new TextFieldWithBrowseButton(); + panel1.add(myUrlField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "start.browser.panel.url.label")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jBLabel1.setLabelFor(myUrlField); + } myStartJavaScriptDebuggerCheckBox.setVisible(JavaScriptDebuggerStarter.Util.hasStarters()); myRoot.addAncestorListener(new AncestorListenerAdapter() { @Override @@ -50,15 +123,15 @@ public final class StartBrowserPanel { Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myRoot)); if (project == null) { DataManager.getInstance() - .getDataContextFromFocusAsync() - .onSuccess(context -> { - Project project1 = CommonDataKeys.PROJECT.getData(context); - if (project1 == null) { - // IDEA-118202 - project1 = ProjectManager.getInstance().getDefaultProject(); - } - setupUrlField(myUrlField, project1); - }); + .getDataContextFromFocusAsync() + .onSuccess(context -> { + Project project1 = CommonDataKeys.PROJECT.getData(context); + if (project1 == null) { + // IDEA-118202 + project1 = ProjectManager.getInstance().getDefaultProject(); + } + setupUrlField(myUrlField, project1); + }); } else { setupUrlField(myUrlField, project); @@ -67,6 +140,78 @@ public final class StartBrowserPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + public @NotNull JPanel getComponent() { return myRoot; } @@ -102,14 +247,6 @@ public final class StartBrowserPanel { return myBrowserSelector; } - private void createUIComponents() { - myBrowserSelector = new BrowserSelector(); - myBrowserComboBox = (ComboboxWithBrowseButton)myBrowserSelector.getMainComponent(); - myBrowserComboBox.getComboBox().addActionListener(e -> { - myStartJavaScriptDebuggerCheckBox.setEnabled(isDebugAllowed(myBrowserSelector.getSelected())); - }); - } - private static @Nullable Url virtualFileToUrl(@NotNull VirtualFile file, @NotNull Project project) { PsiFile psiFile = ReadAction.compute(() -> PsiManager.getInstance(project).findFile(file)); return WebBrowserServiceImpl.getDebuggableUrl(psiFile); diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java index 3c21a33ba3d2..363f004e0fdc 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java @@ -6,9 +6,13 @@ import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -16,26 +20,107 @@ import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author gregsh */ public final class PasswordPromptComponent { - private JPanel myRootPanel; - private JPanel myMessagePanel; - private JPanel myUserPanel; - private JPasswordField myPasswordField; - private JCheckBox myRememberCheckBox; - private JLabel myPasswordLabel; - private JTextField myUserTextField; - private JLabel myIconLabel; + private final JPanel myRootPanel; + private final JPanel myMessagePanel; + private final JPanel myUserPanel; + private final JPasswordField myPasswordField; + private final JCheckBox myRememberCheckBox; + private final JLabel myPasswordLabel; + private final JTextField myUserTextField; + private final JLabel myIconLabel; public PasswordPromptComponent(boolean memoryOnly, @NlsContexts.DialogMessage String message) { this(memoryOnly, message, true, null); } - public PasswordPromptComponent(boolean memoryOnly, @NlsContexts.DialogMessage String message, boolean showUserName, @NlsContexts.Label @Nullable String passwordFieldLabel) { + public PasswordPromptComponent(boolean memoryOnly, + @NlsContexts.DialogMessage String message, + boolean showUserName, + @NlsContexts.Label @Nullable String passwordFieldLabel) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(15, 10, 0, 20), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 1, 1, null, null, null, 0, + false)); + panel2.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myRememberCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myRememberCheckBox, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "checkbox.password.safe.remember")); + panel2.add(myRememberCheckBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUserPanel = new JPanel(); + myUserPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(myUserPanel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, true)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.password.safe.user")); + myUserPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myUserTextField = new JTextField(); + myUserPanel.add(myUserTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(200, -1), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, true)); + myPasswordLabel = new JLabel(); + this.$$$loadLabelText$$$(myPasswordLabel, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.password.safe.password")); + panel3.add(myPasswordLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPasswordField = new JPasswordField(); + myPasswordField.setText(""); + panel3.add(myPasswordField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(200, -1), null, 0, false)); + myMessagePanel = new JPanel(); + myMessagePanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myMessagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myIconLabel = new JLabel(); + myIconLabel.setText("icon"); //NON-NLS + myRootPanel.add(myIconLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myPasswordLabel.setLabelFor(myPasswordField); + } myIconLabel.setText(""); myIconLabel.setIcon(Messages.getWarningIcon()); JTextPane messageField = Messages.configureMessagePaneUi(new JTextPane(), message, UIUtil.FontSize.SMALL); @@ -57,6 +142,78 @@ public final class PasswordPromptComponent { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + public JComponent getComponent() { return myRootPanel; } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java index b623c186eea6..e7d4a8ee2fa7 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java @@ -6,13 +6,19 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.StartupUiUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.ApiStatus; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Font; +import java.awt.Insets; /** * @author Konstantin Bulenkov @@ -21,17 +27,88 @@ import java.awt.Font; public final class PluginHeaderPanel { private IdeaPluginDescriptor myPlugin; - private JBLabel myCategory; - private JBLabel myName; - private JBLabel myDownloads; - private RatesPanel myRating; - private JBLabel myUpdated; - private JBLabel myVersion; - private JPanel myRoot; - private JPanel myDownloadsPanel; - private JPanel myVersionInfoPanel; + private final JBLabel myCategory; + private final JBLabel myName; + private final JBLabel myDownloads; + private final RatesPanel myRating; + private final JBLabel myUpdated; + private final JBLabel myVersion; + private final JPanel myRoot; + private final JPanel myDownloadsPanel; + private final JPanel myVersionInfoPanel; public PluginHeaderPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.setOpaque(true); + myCategory = new JBLabel(); + myCategory.setText("CATEGORY"); //NON-NLS + myRoot.add(myCategory, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myRoot.add(spacer2, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myName = new JBLabel(); + myName.setText("Name name name"); //NON-NLS + myRoot.add(myName, + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDownloadsPanel = new JPanel(); + myDownloadsPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myDownloadsPanel.setOpaque(false); + myRoot.add(myDownloadsPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myDownloadsPanel.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myRating = new RatesPanel(); + myDownloadsPanel.add(myRating, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myDownloads = new JBLabel(); + myDownloads.setText("777 downloads"); //NON-NLS + myDownloadsPanel.add(myDownloads, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myVersionInfoPanel = new JPanel(); + myVersionInfoPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myVersionInfoPanel.setOpaque(false); + myRoot.add(myVersionInfoPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUpdated = new JBLabel(); + myUpdated.setText("Updated: 11/12/13"); //NON-NLS + myVersionInfoPanel.add(myUpdated, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myVersion = new JBLabel(); + myVersion.setText("v 1.2.3"); //NON-NLS + myVersionInfoPanel.add(myVersion, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer4 = new Spacer(); + myVersionInfoPanel.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new BorderLayout(0, 0)); + panel1.setOpaque(false); + myRoot.add(panel1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + } final Font font = myName.getFont(); myName.setFont(new Font(font.getFontName(), font.getStyle(), font.getSize() + 2)); final JBColor greyed = new JBColor(Gray._130, Gray._200); @@ -48,6 +125,9 @@ public final class PluginHeaderPanel { myRoot.setVisible(false); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + public void setPlugin(IdeaPluginDescriptor plugin) { myPlugin = plugin; myRoot.setVisible(true); @@ -58,7 +138,9 @@ public final class PluginHeaderPanel { myName.setFont(StartupUiUtil.getLabelFont().deriveFont(4f + StartupUiUtil.getLabelFont().getSize())); myName.setText("" + plugin.getName() + ""); - myCategory.setText(plugin.getDisplayCategory() == null ? IdeBundle.message("label.category.unknown") : StringUtil.toUpperCase(plugin.getDisplayCategory())); + myCategory.setText(plugin.getDisplayCategory() == null + ? IdeBundle.message("label.category.unknown") + : StringUtil.toUpperCase(plugin.getDisplayCategory())); String versionText; boolean showVersion = !plugin.isBundled() || plugin.allowBundledUpdate(); if (plugin instanceof PluginNode node) { diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java index af7c7d5270d7..902366434867 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java @@ -16,8 +16,12 @@ import com.intellij.ui.Gray; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.ui.speedSearch.SpeedSearchUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.text.Matcher; import com.intellij.util.text.matching.MatchingMode; @@ -26,34 +30,41 @@ import com.intellij.util.ui.StartupUiUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.ApiStatus; +import javax.swing.BorderFactory; import javax.swing.Icon; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTable; +import javax.swing.border.TitledBorder; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.Objects; +import java.util.ResourceBundle; /** -* @author Konstantin Bulenkov -*/ + * @author Konstantin Bulenkov + */ @ApiStatus.Internal public class PluginsTableRenderer extends DefaultTableCellRenderer { - protected SimpleColoredComponent myName; - private JLabel myStatus; - private RatesPanel myRating; - private JLabel myDownloads; - private JLabel myLastUpdated; - private JPanel myPanel; + protected final SimpleColoredComponent myName; + private final JLabel myStatus; + private final RatesPanel myRating; + private final JLabel myDownloads; + private final JLabel myLastUpdated; + private final JPanel myPanel; - private SimpleColoredComponent myCategory; - private JPanel myRightPanel; - private JPanel myBottomPanel; - private JPanel myInfoPanel; + private final SimpleColoredComponent myCategory; + private final JPanel myRightPanel; + private final JPanel myBottomPanel; + private final JPanel myInfoPanel; protected final IdeaPluginDescriptor myPluginDescriptor; private final boolean myPluginsView; @@ -61,6 +72,90 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { // showFullInfo: true for Plugin Repository view, false for Installed Plugins view public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor, boolean showFullInfo) { myPluginDescriptor = pluginDescriptor; + { + myRating = new RatesPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setOpaque(false); + myPanel.add(panel1, BorderLayout.WEST); + panel1.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 3, 0, 6), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myStatus = new JBLabel(); + this.$$$loadLabelText$$$(myStatus, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.plugin.status")); + panel1.add(myStatus, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInfoPanel = new JPanel(); + myInfoPanel.setLayout(new BorderLayout(0, 0)); + myInfoPanel.setOpaque(false); + myPanel.add(myInfoPanel, BorderLayout.CENTER); + myBottomPanel = new JPanel(); + myBottomPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myBottomPanel.setOpaque(false); + myInfoPanel.add(myBottomPanel, BorderLayout.SOUTH); + myCategory = new SimpleColoredComponent(); + myBottomPanel.add(myCategory, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myBottomPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.setOpaque(false); + myInfoPanel.add(panel2, BorderLayout.NORTH); + panel2.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myName = new SimpleColoredComponent(); + panel2.add(myName, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myRightPanel = new JPanel(); + myRightPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRightPanel.setOpaque(false); + myPanel.add(myRightPanel, BorderLayout.EAST); + myRightPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myLastUpdated = new JBLabel(); + this.$$$loadLabelText$$$(myLastUpdated, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.plugin.last.updated")); + myRightPanel.add(myLastUpdated, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + myRightPanel.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel3.setOpaque(false); + myRightPanel.add(panel3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRating.setOpaque(false); + panel3.add(myRating, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myDownloads = new JBLabel(); + this.$$$loadLabelText$$$(myDownloads, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.plugin.downloads")); + panel3.add(myDownloads, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myPluginsView = !showFullInfo; Font smallFont = UIUtil.getLabelFont(UIUtil.FontSize.MINI); @@ -82,10 +177,53 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { myPanel.setBorder(StartupUiUtil.isJreHiDPI(myPanel) ? JBUI.Borders.empty(4, 3) : JBUI.Borders.empty(2, 3)); } - private void createUIComponents() { - myRating = new RatesPanel(); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (myPluginDescriptor != null) { @@ -114,10 +252,12 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { SimpleTextAttributes.STYLE_PLAIN); Matcher matcher = NameUtil.buildMatcher("*" + query, MatchingMode.IGNORE_CASE); - String category = myPluginDescriptor.getDisplayCategory() == null ? null : StringUtil.toUpperCase(myPluginDescriptor.getDisplayCategory()); + String category = + myPluginDescriptor.getDisplayCategory() == null ? null : StringUtil.toUpperCase(myPluginDescriptor.getDisplayCategory()); if (category != null) { if (query != null) { - SpeedSearchUtil.appendColoredFragmentForMatcher(category, myCategory, attr, matcher, UIUtil.getTableBackground(isSelected, hasFocus), true); + SpeedSearchUtil.appendColoredFragmentForMatcher(category, myCategory, attr, matcher, + UIUtil.getTableBackground(isSelected, hasFocus), true); } else { myCategory.append(category); @@ -204,7 +344,8 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { if (!Objects.equals(initialNameForeground, myName.getForeground())) { attr = attr.derive(attr.getStyle(), myName.getForeground(), attr.getBgColor(), attr.getWaveColor()); } - SpeedSearchUtil.appendColoredFragmentForMatcher(pluginName, myName, attr, matcher, UIUtil.getTableBackground(isSelected, hasFocus), true); + SpeedSearchUtil.appendColoredFragmentForMatcher(pluginName, myName, attr, matcher, UIUtil.getTableBackground(isSelected, hasFocus), + true); } else { myName.append(pluginName); diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java index cd15335886f4..aa15d91018ad 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java @@ -13,7 +13,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.EditSourceOnDoubleClickHandler; import com.intellij.util.EditSourceOnEnterKeyHandler; import org.jetbrains.annotations.ApiStatus; @@ -27,20 +32,53 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; @ApiStatus.Internal public final class CannotUndoReportDialog extends DialogWrapper implements UiDataProvider { private static final int FILE_TEXT_PREVIEW_CHARS_LIMIT = 40; private final Project myProject; - private JList myProblemFilesList; - private JPanel myPanel; - private JLabel myProblemMessageLabel; + private final JList myProblemFilesList; + private final JPanel myPanel; + private final JLabel myProblemMessageLabel; public CannotUndoReportDialog(Project project, @Nls String problemText, Collection files) { super(project, false); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myProblemMessageLabel = new JLabel(); + myProblemMessageLabel.setText("%%Cannot undo reason%"); //NON-NLS + myPanel.add(myProblemMessageLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndentWithoutInsets"); + myPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndentWithoutInsets.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IdeBundle", "border.title.problem.files"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myProblemFilesList = new JBList(); + jBScrollPane1.setViewportView(myProblemFilesList); + } DefaultListModel model = new DefaultListModel<>(); for (DocumentReference file : files) { @@ -79,6 +117,28 @@ public final class CannotUndoReportDialog extends DialogWrapper implements UiDat init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected Action @NotNull [] createActions() { return new Action[]{getOKAction()}; diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessDialog.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessDialog.java index 0a0ce3daef60..227a9724a15c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessDialog.java @@ -11,10 +11,16 @@ import com.intellij.openapi.vcs.readOnlyHandler.FileListRenderer; import com.intellij.openapi.vcs.readOnlyHandler.ReadOnlyStatusDialog; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.CollectionListModel; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; @@ -22,20 +28,74 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JRootPane; import javax.swing.KeyStroke; +import java.awt.Insets; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; final class NonProjectFileWritingAccessDialog extends DialogWrapper { - private JPanel myPanel; - private JLabel myListTitle; - private JList myFileList; - private JRadioButton myUnlockOneButton; - private JRadioButton myUnlockDirButton; - private JRadioButton myUnlockAllButton; + private final JPanel myPanel; + private final JLabel myListTitle; + private final JList myFileList; + private final JRadioButton myUnlockOneButton; + private final JRadioButton myUnlockDirButton; + private final JRadioButton myUnlockAllButton; NonProjectFileWritingAccessDialog(@NotNull Project project, @NotNull List nonProjectFiles) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + myUnlockOneButton = new JRadioButton(); + myUnlockOneButton.setSelected(false); + this.$$$loadButtonText$$$(myUnlockOneButton, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "radio.button.unlock.one")); + panel1.add(myUnlockOneButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myUnlockAllButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUnlockAllButton, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "radio.button.unlock.all")); + panel1.add(myUnlockAllButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myUnlockDirButton = new JRadioButton(); + myUnlockDirButton.setSelected(false); + this.$$$loadButtonText$$$(myUnlockDirButton, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "radio.button.unlock.dir")); + panel1.add(myUnlockDirButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.i.want.to.edit.choice")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myListTitle = new JLabel(); + myListTitle.setText("title"); //NON-NLS + myPanel.add(myListTitle, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFileList = new JBList(); + jBScrollPane1.setViewportView(myFileList); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myUnlockAllButton); + buttonGroup.add(myUnlockOneButton); + buttonGroup.add(myUnlockDirButton); + } setTitle(IdeBundle.message("dialog.title.non.project.files.protection")); myFileList.setPreferredSize(ReadOnlyStatusDialog.getDialogPreferredSize()); @@ -61,7 +121,8 @@ final class NonProjectFileWritingAccessDialog extends DialogWrapper { String dirsText = IdeBundle.message("button.i.want.to.edit.all.files.in.choice.this.directory", dirsSize); setTextAndMnemonicAndListeners(myUnlockDirButton, dirsText, "dir"); - setTextAndMnemonicAndListeners(myUnlockAllButton, IdeBundle.message("button.i.want.to.edit.any.non.project.file.in.current.session"), "any"); + setTextAndMnemonicAndListeners(myUnlockAllButton, IdeBundle.message("button.i.want.to.edit.any.non.project.file.in.current.session"), + "any"); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { getRootPane().registerKeyboardAction(e -> doOKAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); @@ -72,6 +133,78 @@ final class NonProjectFileWritingAccessDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setTextAndMnemonicAndListeners(JRadioButton button, @NlsContexts.RadioButton String text, String mnemonic) { button.setText(text); button.setMnemonic(mnemonic.charAt(0)); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/RemoteFilePanel.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/RemoteFilePanel.java index ba97f1137a2e..75f5413cdc58 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/RemoteFilePanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/RemoteFilePanel.java @@ -18,6 +18,9 @@ import com.intellij.openapi.vfs.impl.http.FileDownloadingListener; import com.intellij.openapi.vfs.impl.http.HttpVirtualFile; import com.intellij.openapi.vfs.impl.http.RemoteFileInfo; import com.intellij.openapi.vfs.impl.http.RemoteFileState; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.net.HttpConfigurable; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; @@ -27,16 +30,22 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JTextField; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public final class RemoteFilePanel { @@ -44,17 +53,17 @@ public final class RemoteFilePanel { private static final @NonNls String ERROR_CARD = "error"; private static final @NonNls String DOWNLOADING_CARD = "downloading"; private static final @NonNls String EDITOR_CARD = "editor"; - private JPanel myMainPanel; - private JLabel myProgressLabel; - private JProgressBar myProgressBar; - private JButton myCancelButton; - private JPanel myContentPanel; - private JLabel myErrorLabel; - private JButton myTryAgainButton; - private JButton myChangeProxySettingsButton; - private JPanel myEditorPanel; - private JTextField myUrlTextField; - private JPanel myToolbarPanel; + private final JPanel myMainPanel; + private final JLabel myProgressLabel; + private final JProgressBar myProgressBar; + private final JButton myCancelButton; + private final JPanel myContentPanel; + private final JLabel myErrorLabel; + private final JButton myTryAgainButton; + private final JButton myChangeProxySettingsButton; + private final JPanel myEditorPanel; + private final JTextField myUrlTextField; + private final JPanel myToolbarPanel; private final Project myProject; private final HttpVirtualFile myVirtualFile; private final MergingUpdateQueue myProgressUpdatesQueue; @@ -66,6 +75,96 @@ public final class RemoteFilePanel { myProject = project; myVirtualFile = virtualFile; myPropertyChangeListener = propertyChangeListener; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myContentPanel = new JPanel(); + myContentPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myContentPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(5, 5, 5, 5), -1, -1)); + myContentPanel.add(panel1, "downloading"); + myProgressLabel = new JLabel(); + this.$$$loadLabelText$$$(myProgressLabel, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.downloading.file.started")); + panel1.add(myProgressLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(241, 28), null, 1, false)); + myProgressBar = new JProgressBar(); + panel2.add(myProgressBar, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCancelButton = new JButton(); + this.$$$loadButtonText$$$(myCancelButton, this.$$$getMessageFromBundle$$$("messages/CommonBundle", "button.cancel")); + panel2.add(myCancelButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(3, 1, new Insets(5, 5, 5, 5), -1, -1)); + myContentPanel.add(panel3, "error"); + myErrorLabel = new JLabel(); + myErrorLabel.setText("Label"); //NON-NLS + panel3.add(myErrorLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myChangeProxySettingsButton = new JButton(); + this.$$$loadButtonText$$$(myChangeProxySettingsButton, + this.$$$getMessageFromBundle$$$("messages/UIBundle", "downloading.file.change.http.proxy.settings")); + panel4.add(myChangeProxySettingsButton, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel4.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myTryAgainButton = new JButton(); + this.$$$loadButtonText$$$(myTryAgainButton, + this.$$$getMessageFromBundle$$$("messages/UIBundle", "downloading.file.try.again.button")); + panel4.add(myTryAgainButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + myContentPanel.add(myEditorPanel, "editor"); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 2, new Insets(3, 3, 0, 3), 0, -1)); + myMainPanel.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, + null, null, 0, false)); + myUrlTextField = new JTextField(); + myUrlTextField.setEditable(false); + panel5.add(myUrlTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myToolbarPanel = new JPanel(); + myToolbarPanel.setLayout(new BorderLayout(0, 0)); + panel5.add(myToolbarPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myErrorLabel.setIcon(AllIcons.General.BalloonError); myUrlTextField.setText(virtualFile.getUrl()); myProgressUpdatesQueue = new MergingUpdateQueue("downloading progress updates", 300, false, myMainPanel); @@ -113,6 +212,78 @@ public final class RemoteFilePanel { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void initToolbar(Project project) { DefaultActionGroup group = new DefaultActionGroup(); group.add(new RefreshRemoteFileAction(myVirtualFile)); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java index 1ec18d2f8bcf..a588cf0f2dd9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java @@ -22,6 +22,10 @@ import com.intellij.ui.DoubleClickListener; import com.intellij.ui.ListSpeedSearch; import com.intellij.ui.ScrollingUtil; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.concurrency.annotations.RequiresEdt; import com.intellij.util.ui.NamedColorUtil; import com.intellij.util.ui.UIUtil; @@ -30,6 +34,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.DefaultListModel; import javax.swing.JComponent; import javax.swing.JLabel; @@ -37,28 +43,88 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.ListSelectionModel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.ResourceBundle; public final class FileTypeChooser extends DialogWrapper { - private JList myList; - private JLabel myTitleLabel; - private ComboBox myPattern; - private JPanel myPanel; - private JRadioButton myOpenInIdea; - private JRadioButton myOpenAsNative; - private JRadioButton myDetectFileType; - private JBLabel myContextHelpLabel; + private final JList myList; + private final JLabel myTitleLabel; + private final ComboBox myPattern; + private final JPanel myPanel; + private final JRadioButton myOpenInIdea; + private final JRadioButton myOpenAsNative; + private final JRadioButton myDetectFileType; + private final JBLabel myContextHelpLabel; private final String myFileName; private FileTypeChooser(@NotNull List patterns, @NotNull String fileName) { super(true); myFileName = fileName; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + myTitleLabel = new JLabel(); + myTitleLabel.setText("Cannot associate _template_"); //NON-NLS + myPanel.add(myTitleLabel, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/FileTypesBundle", "filetype.chooser.file.pattern")); + myPanel.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPattern = new ComboBox(); + myPattern.setEditable(true); + myPanel.add(myPattern, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(150, 200), null, 2, false)); + myList = new JBList(); + jBScrollPane1.setViewportView(myList); + myOpenInIdea = new JRadioButton(); + myOpenInIdea.setSelected(true); + myOpenInIdea.setText("Open matching files in PRODUCTNAME as type:"); //NON-NLS + myPanel.add(myOpenInIdea, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOpenAsNative = new JRadioButton(); + this.$$$loadButtonText$$$(myOpenAsNative, this.$$$getMessageFromBundle$$$("messages/IdeBundle", + "radio.button.open.matching.files.in.associated.application")); + myPanel.add(myOpenAsNative, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDetectFileType = new JRadioButton(); + myDetectFileType.setText("Open matching files in PRODUCTNAME and auto-detect file type"); //NON-NLS + myPanel.add(myDetectFileType, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myContextHelpLabel = new JBLabel(); + myPanel.add(myContextHelpLabel, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myPattern); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myOpenInIdea); + buttonGroup.add(myOpenAsNative); + buttonGroup.add(myDetectFileType); + } myOpenInIdea.setText(FileTypesBundle.message("filetype.chooser.association", ApplicationNamesInfo.getInstance().getFullProductName())); myDetectFileType.setText(FileTypesBundle.message("filetype.chooser.autodetect")); ActionListener actionListener = e -> { @@ -75,11 +141,15 @@ public final class FileTypeChooser extends DialogWrapper { } var fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); - Arrays.sort(fileTypes, (ft1, ft2) -> ft1 == null ? 1 : ft2 == null ? -1 : ft1.getDescription().compareToIgnoreCase(ft2.getDescription())); + Arrays.sort(fileTypes, + (ft1, ft2) -> ft1 == null ? 1 : ft2 == null ? -1 : ft1.getDescription().compareToIgnoreCase(ft2.getDescription())); var model = new DefaultListModel(); for (var type : fileTypes) { - if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType) && type != DetectedByContentFileType.INSTANCE) { + if (!type.isReadOnly() && + type != FileTypes.UNKNOWN && + !(type instanceof NativeFileType) && + type != DetectedByContentFileType.INSTANCE) { model.addElement(type); } } @@ -94,6 +164,78 @@ public final class FileTypeChooser extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateContextHelp() { var selectedType = getSelectedType(); var fileTypeString = selectedType == null ? "" : (" | " + selectedType.getDescription()); @@ -145,7 +287,7 @@ public final class FileTypeChooser extends DialogWrapper { } @Override - protected String getDimensionServiceKey(){ + protected String getDimensionServiceKey() { return "#com.intellij.fileTypes.FileTypeChooser"; } @@ -157,7 +299,8 @@ public final class FileTypeChooser extends DialogWrapper { /** @deprecated Method requires both EDT and BGT. Use {@link #associateFileType(String)} directly */ @Deprecated(forRemoval = true) - public static @Nullable FileType getKnownFileTypeOrAssociate(@NotNull VirtualFile file, @SuppressWarnings("unused") @Nullable Project project) { + public static @Nullable FileType getKnownFileTypeOrAssociate(@NotNull VirtualFile file, + @SuppressWarnings("unused") @Nullable Project project) { var type = file.getFileType(); if (type == FileTypes.UNKNOWN) { type = getKnownFileTypeOrAssociate(file.getName()); @@ -167,7 +310,9 @@ public final class FileTypeChooser extends DialogWrapper { /** @deprecated Method requires both EDT and BGT. Use {@link #associateFileType(String)} directly */ @Deprecated(forRemoval = true) - public static @Nullable FileType getKnownFileTypeOrAssociate(@NotNull VirtualFile parent, @NotNull String newName, @Nullable Project project) { + public static @Nullable FileType getKnownFileTypeOrAssociate(@NotNull VirtualFile parent, + @NotNull String newName, + @Nullable Project project) { return getKnownFileTypeOrAssociate(new FakeVirtualFile(parent, newName), project); } @@ -189,7 +334,8 @@ public final class FileTypeChooser extends DialogWrapper { var type = chooser.getSelectedType(); if (type == FileTypes.UNKNOWN || type == null) return null; - ApplicationManager.getApplication().runWriteAction(() -> FileTypeManagerEx.getInstanceEx().associatePattern(type, chooser.getSelectedPattern())); + ApplicationManager.getApplication() + .runWriteAction(() -> FileTypeManagerEx.getInstanceEx().associatePattern(type, chooser.getSelectedPattern())); return type; } diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadOnlyStatusDialog.java b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadOnlyStatusDialog.java index 2ddd9c3dce8b..0a76fabebf05 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadOnlyStatusDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadOnlyStatusDialog.java @@ -11,25 +11,36 @@ import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.list.TargetPopup; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.NamedColorUtil; import com.intellij.util.ui.OptionsDialog; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.AbstractListModel; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JRootPane; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; @ApiStatus.Internal public final class ReadOnlyStatusDialog extends OptionsDialog { @@ -38,16 +49,71 @@ public final class ReadOnlyStatusDialog extends OptionsDialog { private static final SimpleTextAttributes SELECTED_BOLD_ATTRIBUTES = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, JBColor.lazy(() -> NamedColorUtil.getListSelectionForeground(true))); - private JPanel myTopPanel; - private JList myFileList; - private JRadioButton myUsingFileSystemRadioButton; - private JRadioButton myUsingVcsRadioButton; - private JComboBox myChangelist; - private JCheckBox myMakeChangeListActive; + private final JPanel myTopPanel; + private final JList myFileList; + private final JRadioButton myUsingFileSystemRadioButton; + private final JRadioButton myUsingVcsRadioButton; + private final JComboBox myChangelist; + private final JCheckBox myMakeChangeListActive; private List myFiles; ReadOnlyStatusDialog(Project project, @NotNull List files) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myTopPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFileList = new JBList(); + jBScrollPane1.setViewportView(myFileList); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 4, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUsingFileSystemRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUsingFileSystemRadioButton, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "radio.button.using.file.system")); + panel1.add(myUsingFileSystemRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(175, 22), null, 0, false)); + myUsingVcsRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUsingVcsRadioButton, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "radio.button.using.version.control.integration")); + panel1.add(myUsingVcsRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(175, 22), null, 0, + false)); + myChangelist = new JComboBox(); + panel1.add(myChangelist, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setHorizontalAlignment(11); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/IdeBundle", "label.change.list.for.unlocked.files")); + panel1.add(jBLabel1, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(34, 14), null, 0, false)); + myMakeChangeListActive = new JCheckBox(); + this.$$$loadButtonText$$$(myMakeChangeListActive, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "new.changelist.make.active.checkbox")); + panel1.add(myMakeChangeListActive, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jBLabel1.setLabelFor(myChangelist); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myUsingFileSystemRadioButton); + buttonGroup.add(myUsingVcsRadioButton); + } setTitle(IdeBundle.message("dialog.title.clear.read.only.file.status")); myFiles = files; myFileList.setPreferredSize(getDialogPreferredSize()); @@ -62,6 +128,78 @@ public final class ReadOnlyStatusDialog extends OptionsDialog { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private void initFileList() { myFileList.setModel(new AbstractListModel<>() { @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/ChooseEncodingDialog.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/ChooseEncodingDialog.java index 907d875c8e91..1a24f4e95b0d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/ChooseEncodingDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/ChooseEncodingDialog.java @@ -5,6 +5,10 @@ import com.intellij.ide.IdeBundle; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.TreeUIHelper; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -15,23 +19,41 @@ import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; import java.awt.Component; +import java.awt.Insets; import java.nio.charset.Charset; @ApiStatus.Internal public final class ChooseEncodingDialog extends DialogWrapper { private final Charset[] myCharsets; private final Charset myDefaultCharset; - private JList myList; - private JPanel myPanel; + private final JList myList; + private final JPanel myPanel; private ChooseEncodingDialog(final Charset[] charsets, final Charset defaultCharset, final VirtualFile virtualFile) { super(false); myCharsets = charsets; myDefaultCharset = defaultCharset; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myList = new JBList(); + jBScrollPane1.setViewportView(myList); + } setTitle(IdeBundle.message("dialog.title.choose.encoding.for.the.0", virtualFile.getName())); init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected @Nullable JComponent createCenterPanel() { AbstractListModel model = new AbstractListModel() { @@ -47,7 +69,7 @@ public final class ChooseEncodingDialog extends DialogWrapper { }; myList.setModel(model); TreeUIHelper.getInstance().installListSpeedSearch(myList); - myList.setCellRenderer(new DefaultListCellRenderer(){ + myList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -78,5 +100,4 @@ public final class ChooseEncodingDialog extends DialogWrapper { protected @NonNls String getDimensionServiceKey() { return "#com.intellij.openapi.vfs.encoding.ChooseEncodingDialog"; } - } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PresentationModeProgressPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PresentationModeProgressPanel.java index 0a59cc4b8d3e..9772713bb285 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PresentationModeProgressPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PresentationModeProgressPanel.java @@ -9,6 +9,9 @@ import com.intellij.openapi.wm.impl.status.InfoAndProgressPanel.MyProgressCompon import com.intellij.ui.InplaceButton; import com.intellij.ui.TransparentPanel; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.JBIterable; import com.intellij.util.ui.JBDimension; import com.intellij.util.ui.JBUI; @@ -19,9 +22,11 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.Insets; /** * @author Konstantin Bulenkov @@ -30,14 +35,61 @@ import java.awt.Font; public final class PresentationModeProgressPanel { private final MyProgressComponent progress; private final JBIterable myEastButtons; - private JLabel textLabel; - private JProgressBar myProgressBar; - private JLabel additionalTextLabel; - private JPanel myRootPanel; - private JPanel myButtonPanel; + private final JLabel textLabel; + private final JProgressBar myProgressBar; + private final JLabel additionalTextLabel; + private final JPanel myRootPanel; + private final JPanel myButtonPanel; public PresentationModeProgressPanel(@NotNull MyProgressComponent progress) { this.progress = progress; + { + myRootPanel = new TransparentPanel(0.5f) { + @Override + public boolean isVisible() { + if (!progress.showInPresentationMode()) { + return false; + } + UISettings ui = UISettings.getInstance(); + return ui.getPresentationMode() || !ui.getShowStatusBar() && Registry.is("ide.show.progress.without.status.bar"); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.setOpaque(false); + myProgressBar = new JProgressBar(); + myProgressBar.setIndeterminate(true); + myProgressBar.setOpaque(false); + myRootPanel.add(myProgressBar, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myButtonPanel = new JPanel(); + myButtonPanel.setLayout(new BorderLayout(0, 0)); + myButtonPanel.setOpaque(false); + myRootPanel.add(myButtonPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + textLabel = new JLabel(); + textLabel.setAutoscrolls(true); + textLabel.setText(""); + myRootPanel.add(textLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(209, -1), new Dimension(209, -1), new Dimension(209, -1), 0, false)); + additionalTextLabel = new JLabel(); + additionalTextLabel.setText(""); + myRootPanel.add(additionalTextLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(209, -1), new Dimension(209, -1), new Dimension(209, -1), 0, + false)); + } Font font = JBUI.Fonts.label(11); textLabel.setFont(font); additionalTextLabel.setFont(font); @@ -53,6 +105,9 @@ public final class PresentationModeProgressPanel { myProgressBar.setPreferredSize(new Dimension(JBUIScale.scale(250), myProgressBar.getPreferredSize().height)); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + private static @NotNull Color getTextForeground() { return EditorColorsManager.getInstance().getGlobalScheme().getDefaultForeground(); } @@ -84,17 +139,4 @@ public final class PresentationModeProgressPanel { public @NotNull JComponent getProgressPanel() { return myRootPanel; } - - private void createUIComponents() { - myRootPanel = new TransparentPanel(0.5f) { - @Override - public boolean isVisible() { - if (!progress.showInPresentationMode()) { - return false; - } - UISettings ui = UISettings.getInstance(); - return ui.getPresentationMode() || !ui.getShowStatusBar() && Registry.is("ide.show.progress.without.status.bar"); - } - }; - } } diff --git a/platform/platform-impl/src/com/intellij/troubleshooting/ui/CollectTroubleshootingInformationDialog.java b/platform/platform-impl/src/com/intellij/troubleshooting/ui/CollectTroubleshootingInformationDialog.java index 1161af81f0a0..6546b0199af8 100644 --- a/platform/platform-impl/src/com/intellij/troubleshooting/ui/CollectTroubleshootingInformationDialog.java +++ b/platform/platform-impl/src/com/intellij/troubleshooting/ui/CollectTroubleshootingInformationDialog.java @@ -10,24 +10,75 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.troubleshooting.TroubleInfoCollector; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.Action; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; +import java.lang.reflect.Method; +import java.util.ResourceBundle; final class CollectTroubleshootingInformationDialog extends DialogWrapper { - private JTextArea summary; - private JPanel centerPanel; - private ComboBox troubleTypeBox; + private final JTextArea summary; + private final JPanel centerPanel; + private final ComboBox troubleTypeBox; public CollectTroubleshootingInformationDialog(@NotNull Project project) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + centerPanel = new JPanel(); + centerPanel.setLayout(new GridBagLayout()); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 2; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + centerPanel.add(jBScrollPane1, gbc); + summary = new JTextArea(); + jBScrollPane1.setViewportView(summary); + troubleTypeBox = new ComboBox(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + centerPanel.add(troubleTypeBox, gbc); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/DiagnosticBundle", "label.issue.type")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + centerPanel.add(jBLabel1, gbc); + final JBLabel jBLabel2 = new JBLabel(); + jBLabel2.setHorizontalAlignment(2); + jBLabel2.setHorizontalTextPosition(2); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/DiagnosticBundle", + "label.the.information.may.contain.sensitive.data")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.ipady = 10; + centerPanel.add(jBLabel2, gbc); + } setTitle(IdeBundle.message("dialog.title.collect.troubleshooting.information")); CompositeGeneralTroubleInfoCollector generalInfoCollector = new CompositeGeneralTroubleInfoCollector(); troubleTypeBox.addItem(generalInfoCollector); @@ -53,6 +104,53 @@ final class CollectTroubleshootingInformationDialog extends DialogWrapper { pack(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return centerPanel; } + @Override protected @Nullable String getDimensionServiceKey() { return getClass().getName(); diff --git a/platform/platform-impl/src/com/intellij/ui/GotItPanel.java b/platform/platform-impl/src/com/intellij/ui/GotItPanel.java index 84f096dc912e..93875e4d2bc0 100644 --- a/platform/platform-impl/src/com/intellij/ui/GotItPanel.java +++ b/platform/platform-impl/src/com/intellij/ui/GotItPanel.java @@ -3,22 +3,34 @@ package com.intellij.ui; import com.intellij.ide.IdeTooltipManager; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.StartupUiUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.AWTEvent; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; /** * @author Konstantin Bulenkov @@ -31,40 +43,163 @@ public class GotItPanel { private static final JBColor BODY_COLOR_2 = new JBColor(new Color(71, 135, 237), new Color(38, 53, 73)); private static final JBColor BORDER_COLOR = new JBColor(new Color(71, 91, 167), new Color(78, 120, 161)); - JPanel myRoot; - JLabel myTitle; - JEditorPane myMessage; - JPanel myButton; - JLabel myButtonLabel; + final JPanel myRoot; + final JLabel myTitle; + final JEditorPane myMessage; + final JPanel myButton; + final JLabel myButtonLabel; public GotItPanel() { + { + myButton = new JPanel(new BorderLayout()) { + { + enableEvents(AWTEvent.MOUSE_EVENT_MASK); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + GraphicsUtil.setupAAPainting(g); + ((Graphics2D)g).setPaint(new GradientPaint(0, 0, BODY_COLOR_1, 0, getHeight(), BODY_COLOR_2)); + g.fillRoundRect(0, 0, getWidth() - JBUIScale.scale(1), getHeight() - JBUIScale.scale(1), JBUIScale.scale(5), JBUIScale.scale(5)); + ((Graphics2D)g).setStroke(new BasicStroke(StartupUiUtil.isUnderDarcula() ? 2f : 1f)); + g.setColor(BORDER_COLOR); + g.drawRoundRect(0, 0, getWidth() - JBUIScale.scale(1), getHeight() - JBUIScale.scale(1), JBUIScale.scale(5), JBUIScale.scale(5)); + } + }; + + myMessage = IdeTooltipManager.initPane("", new HintHint().setAwtTooltip(true), null); + myMessage.setFont(StartupUiUtil.getLabelFont().deriveFont(StartupUiUtil.getLabelFont().getSize() + 2f)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(4, 1, new Insets(4, 5, 4, 5), -1, -1)); + myRoot.setOpaque(false); + myTitle = new JLabel(); + Font myTitleFont = this.$$$getFont$$$(null, -1, 20, myTitle.getFont()); + if (myTitleFont != null) myTitle.setFont(myTitleFont); + myTitle.setText("Title"); //NON-NLS + myRoot.add(myTitle, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myMessage.setContentType("text/html"); + Font myMessageFont = this.$$$getFont$$$(null, -1, 12, myMessage.getFont()); + if (myMessageFont != null) myMessage.setFont(myMessageFont); + myMessage.setOpaque(false); + myMessage.setText( + "\r\n \r\n \r\n \r\n \r\n

    \r\n Test test test\r\n

    \r\n \r\n\r\n"); //NON-NLS + myRoot.add(myMessage, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setOpaque(false); + myRoot.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myButton.setLayout(new BorderLayout(0, 0)); + myButton.setBackground(new Color(-16750951)); + myButton.setOpaque(false); + panel1.add(myButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myButton.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(4, 10, 4, 8), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myButtonLabel = new JLabel(); + Font myButtonLabelFont = this.$$$getFont$$$(null, Font.BOLD, 12, myButtonLabel.getFont()); + if (myButtonLabelFont != null) myButtonLabel.setFont(myButtonLabelFont); + myButtonLabel.setForeground(new Color(-1)); + this.$$$loadLabelText$$$(myButtonLabel, this.$$$getMessageFromBundle$$$("messages/UIBundle", "got.it")); + myButton.add(myButtonLabel, BorderLayout.CENTER); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } scaleFont(myTitle); scaleFont(myButtonLabel); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + private static void scaleFont(@NotNull JComponent component) { component.setFont(component.getFont().deriveFont(1.0f * JBUIScale.scaleFontSize((float)component.getFont().getSize()))); } - - private void createUIComponents() { - myButton = new JPanel(new BorderLayout()) { - { - enableEvents(AWTEvent.MOUSE_EVENT_MASK); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - GraphicsUtil.setupAAPainting(g); - ((Graphics2D)g).setPaint(new GradientPaint(0, 0, BODY_COLOR_1, 0, getHeight(), BODY_COLOR_2)); - g.fillRoundRect(0, 0, getWidth() - JBUIScale.scale(1), getHeight() - JBUIScale.scale(1), JBUIScale.scale(5), JBUIScale.scale(5)); - ((Graphics2D)g).setStroke(new BasicStroke(StartupUiUtil.isUnderDarcula() ? 2f : 1f)); - g.setColor(BORDER_COLOR); - g.drawRoundRect(0, 0, getWidth() - JBUIScale.scale(1), getHeight() - JBUIScale.scale(1), JBUIScale.scale(5), JBUIScale.scale(5)); - } - }; - - myMessage = IdeTooltipManager.initPane("", new HintHint().setAwtTooltip(true), null); - myMessage.setFont(StartupUiUtil.getLabelFont().deriveFont(StartupUiUtil.getLabelFont().getSize() + 2f)); - } } diff --git a/platform/platform-impl/src/com/intellij/util/net/ssl/CertificateConfigurable.java b/platform/platform-impl/src/com/intellij/util/net/ssl/CertificateConfigurable.java index 0c67db4f0d08..8b2b584f7752 100644 --- a/platform/platform-impl/src/com/intellij/util/net/ssl/CertificateConfigurable.java +++ b/platform/platform-impl/src/com/intellij/util/net/ssl/CertificateConfigurable.java @@ -9,6 +9,7 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.ui.AnActionButton; import com.intellij.ui.AnActionButtonRunnable; @@ -16,8 +17,12 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.UIBundle; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; @@ -26,16 +31,22 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.TreeSelectionModel; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.security.cert.X509Certificate; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import static com.intellij.util.net.ssl.CertificateUtil.getCommonName; @@ -49,13 +60,141 @@ public final class CertificateConfigurable implements SearchableConfigurable, Co public static final String EMPTY_PANEL = "empty.panel"; - private JPanel myRootPanel; + private final JPanel myRootPanel; - private JBCheckBox myAcceptAutomatically; + private final JBCheckBox myAcceptAutomatically; + + private final JPanel myCertificatesListPanel; + private final JPanel myDetailsPanel; + private final JPanel myEmptyPanel; + + public CertificateConfigurable() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCertificatesListPanel = new JPanel(); + myCertificatesListPanel.setLayout(new BorderLayout(0, 0)); + myCertificatesListPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myRootPanel.add(myCertificatesListPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myAcceptAutomatically = new JBCheckBox(); + this.$$$loadButtonText$$$(myAcceptAutomatically, this.$$$getMessageFromBundle$$$("messages/IdeBundle", + "settings.certificate.accept.non.trusted.certificates.automatically")); + panel1.add(myAcceptAutomatically, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDetailsPanel = new JPanel(); + myDetailsPanel.setLayout(new CardLayout(0, 0)); + myRootPanel.add(myDetailsPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(499, 24), null, 0, false)); + myEmptyPanel = new JPanel(); + myEmptyPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myDetailsPanel.add(myEmptyPanel, "Card1"); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/IdeBundle", "settings.certificate.no.certificate.selected")); + myEmptyPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final Splitter splitter1 = new Splitter(); + splitter1.setOrientation(true); + splitter1.setProportion(0.3f); + splitter1.setShowDividerControls(false); + myRootPanel.add(splitter1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + splitter1.setFirstComponent(myCertificatesListPanel); + splitter1.setSecondComponent(myDetailsPanel); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } - private JPanel myCertificatesListPanel; - private JPanel myDetailsPanel; - private JPanel myEmptyPanel; private MutableTrustManager myTrustManager; private CertificateTreeBuilder myTreeBuilder; @@ -199,8 +338,9 @@ public final class CertificateConfigurable implements SearchableConfigurable, Co for (X509Certificate certificate : removed) { if (!myTrustManager.removeCertificate(certificate)) { - throw new ConfigurationException(IdeBundle.message("settings.certificate.cannot.remove.certificate.for", getCommonName(certificate)), - IdeBundle.message("settings.certificate.cannot.remove.certificate")); + throw new ConfigurationException( + IdeBundle.message("settings.certificate.cannot.remove.certificate.for", getCommonName(certificate)), + IdeBundle.message("settings.certificate.cannot.remove.certificate")); } } CertificateManager.Config state = CertificateManager.getInstance().getState(); diff --git a/platform/platform-impl/src/com/intellij/util/ui/ReloadableComboBoxPanel.java b/platform/platform-impl/src/com/intellij/util/ui/ReloadableComboBoxPanel.java index e287ec878cd1..232cdc92d9e2 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ReloadableComboBoxPanel.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ReloadableComboBoxPanel.java @@ -2,15 +2,48 @@ package com.intellij.util.ui; import com.intellij.openapi.ui.ComboBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; public abstract class ReloadableComboBoxPanel extends ReloadablePanel { - protected JComboBox myComboBox; - protected JPanel myActionPanel; - private JPanel myMainPanel; + protected final JComboBox myComboBox; + protected final JPanel myActionPanel; + private final JPanel myMainPanel; + + public ReloadableComboBoxPanel() { + { + myComboBox = createValuesComboBox(); + myActionPanel = getActionPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myComboBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(150, -1), null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myMainPanel.add(myActionPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } @Override @SuppressWarnings("unchecked") @@ -26,9 +59,4 @@ public abstract class ReloadableComboBoxPanel extends ReloadablePanel { public @NotNull JPanel getMainPanel() { return myMainPanel; } - - private void createUIComponents() { - myComboBox = createValuesComboBox(); - myActionPanel = getActionPanel(); - } } diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java index aff9e3bf4e04..ccb77b9e337b 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -16,6 +16,9 @@ import com.intellij.ui.HoverHyperlinkLabel; import com.intellij.ui.IconManager; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.table.TableView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.IconUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -36,6 +39,7 @@ import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; @@ -53,7 +57,8 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT } public interface Fix extends Runnable { - @NlsContexts.LinkLabel String getTitle(); + @NlsContexts.LinkLabel + String getTitle(); } private final class ColumnInfoWrapper extends ColumnInfo { @@ -101,12 +106,12 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT } } - private JPanel myContentPane; + private final JPanel myContentPane; private TableView myTable; private final AnAction myRemoveButton; - private JLabel myMessageLabel; - private HoverHyperlinkLabel myFixLink; - private JPanel myTablePanel; + private final JLabel myMessageLabel; + private final HoverHyperlinkLabel myFixLink; + private final JPanel myTablePanel; private final List myWarnings = new ArrayList<>(); private Fix myFixRunnable; @@ -166,27 +171,57 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT myTable.setShowGrid(v); } - private void createUIComponents() { - myTable = new ChangesTrackingTableView<>() { - @Override - protected void onCellValueChanged(int row, int column, Object value) { - Item original = getItems().get(row); - Item override = cloneOf(original); - ColumnInfo columnInfo = getTableModel().getColumnInfos()[column]; - columnInfo.setValue(override, value); - updateMessage(row, override); - } - - @Override - protected void onEditingStopped() { - updateMessage(-1, null); - } - }; - - myFixLink = new HoverHyperlinkLabel(null); - } - protected ValidatingTableEditor(AnAction @Nullable ... extraButtons) { + { + myTable = new ChangesTrackingTableView<>() { + @Override + protected void onCellValueChanged(int row, int column, Object value) { + Item original = getItems().get(row); + Item override = cloneOf(original); + ColumnInfo columnInfo = getTableModel().getColumnInfos()[column]; + columnInfo.setValue(override, value); + updateMessage(row, override); + } + + @Override + protected void onEditingStopped() { + updateMessage(-1, null); + } + }; + + myFixLink = new HoverHyperlinkLabel(null); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myMessageLabel = new JLabel(); + myMessageLabel.setText("Label"); //NON-NLS + panel1.add(myMessageLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myFixLink.setText("Fix"); //NON-NLS + panel1.add(myFixLink, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTablePanel = new JPanel(); + myTablePanel.setLayout(new BorderLayout(0, 0)); + myContentPane.add(myTablePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + } ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableRemoveAction().disableUpAction().disableDownAction(); decorator.setAddAction(new AnActionButtonRunnable() { @@ -248,6 +283,9 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT this(null); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + public @Nullable List getSelectedItems() { return myTable.getSelectedObjects(); } diff --git a/platform/platform-impl/update-checker/src/com/intellij/openapi/updateSettings/impl/NoUpdatesDialog.java b/platform/platform-impl/update-checker/src/com/intellij/openapi/updateSettings/impl/NoUpdatesDialog.java index 30aca52f788a..cc70da60e9b8 100644 --- a/platform/platform-impl/update-checker/src/com/intellij/openapi/updateSettings/impl/NoUpdatesDialog.java +++ b/platform/platform-impl/update-checker/src/com/intellij/openapi/updateSettings/impl/NoUpdatesDialog.java @@ -12,6 +12,9 @@ import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; final class NoUpdatesDialog extends AbstractUpdateDialog { NoUpdatesDialog(boolean addConfigureUpdatesLink) { @@ -35,14 +38,49 @@ final class NoUpdatesDialog extends AbstractUpdateDialog { } private final class NoUpdatesPanel { - private JPanel myPanel; - private JLabel myNothingToUpdateLabel; - private JEditorPane myMessageArea; + private final JPanel myPanel; + private final JLabel myNothingToUpdateLabel; + private final JEditorPane myMessageArea; NoUpdatesPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridBagLayout()); + myNothingToUpdateLabel = new JLabel(); + myNothingToUpdateLabel.setText("(nothing to update)"); //NON-NLS + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.NORTH; + gbc.fill = GridBagConstraints.HORIZONTAL; + myPanel.add(myNothingToUpdateLabel, gbc); + myMessageArea = new JEditorPane(); + myMessageArea.setContentType("text/html"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(10, 0, 0, 0); + myPanel.add(myMessageArea, gbc); + final JPanel spacer1 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.VERTICAL; + myPanel.add(spacer1, gbc); + } myNothingToUpdateLabel.setText(getNoUpdatesText()); configureMessageArea(myMessageArea); } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } } static @Nls(capitalization = Nls.Capitalization.Sentence) String getNoUpdatesText() { diff --git a/platform/platform-tests/testSrc/com/intellij/ui/laf/DarculaTest.java b/platform/platform-tests/testSrc/com/intellij/ui/laf/DarculaTest.java index f03aaebe7518..f2726f5095fd 100644 --- a/platform/platform-tests/testSrc/com/intellij/ui/laf/DarculaTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ui/laf/DarculaTest.java @@ -4,12 +4,23 @@ package com.intellij.ui.laf; import com.intellij.ide.ui.laf.darcula.DarculaLaf; import com.intellij.ui.ShowUIDefaultsAction; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBRadioButton; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.components.JBTabbedPane; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.TimeoutUtil; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JProgressBar; @@ -21,6 +32,8 @@ import javax.swing.UnsupportedLookAndFeelException; import javax.swing.WindowConstants; import javax.swing.table.DefaultTableModel; import java.awt.AWTEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; @@ -32,42 +45,410 @@ import java.awt.event.KeyEvent; */ @SuppressWarnings("HardCodedStringLiteral") public class DarculaTest { - private JBCheckBox myJBCheckBox1; - private JBCheckBox myJBCheckBox2; - private JBCheckBox myJBCheckBox3; - private JBCheckBox myJBCheckBox4; - private JBCheckBox myJBCheckBox5; - private JComboBox myComboBox1; - private JComboBox myComboBox2; - private JComboBox myComboBox3; - private JComboBox myComboBox4; - private JComboBox myComboBox5; - private JTextField myTextField1; - private JTextField myThisTextIsDisabledTextField; - private JPasswordField myPasswordField1; - private JPanel myRoot; - private JButton myHelpButton; - private JButton myCancelButton; - private JButton myDisabledButton; - private JButton myDefaultButton; - private JTextField myTextField2; - private JTextField myTextField3; - private JTextField myTextField4; - private JSpinner mySpinner1; - private JProgressBar myProgressBar1; - private JButton myProgressButton; - private JProgressBar myProgressBar2; - private JButton myStartButton; - private JBTable myTable; + private final JBCheckBox myJBCheckBox1; + private final JBCheckBox myJBCheckBox2; + private final JBCheckBox myJBCheckBox3; + private final JBCheckBox myJBCheckBox4; + private final JBCheckBox myJBCheckBox5; + private final JComboBox myComboBox1; + private final JComboBox myComboBox2; + private final JComboBox myComboBox3; + private final JComboBox myComboBox4; + private final JComboBox myComboBox5; + private final JTextField myTextField1; + private final JTextField myThisTextIsDisabledTextField; + private final JPasswordField myPasswordField1; + private final JPanel myRoot; + private final JButton myHelpButton; + private final JButton myCancelButton; + private final JButton myDisabledButton; + private final JButton myDefaultButton; + private final JTextField myTextField2; + private final JTextField myTextField3; + private final JTextField myTextField4; + private final JSpinner mySpinner1; + private final JProgressBar myProgressBar1; + private final JButton myProgressButton; + private final JProgressBar myProgressBar2; + private final JButton myStartButton; + private final JBTable myTable; public DarculaTest() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBTabbedPane jBTabbedPane1 = new JBTabbedPane(); + myRoot.add(jBTabbedPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(8, 8, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Controls", panel1); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setText("Checkbox 1"); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + jBLabel2.setText("Checkbox 2"); + panel1.add(jBLabel2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + jBLabel3.setText("Checkbox 3"); + panel1.add(jBLabel3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + jBLabel4.setText("Checkbox 4"); + panel1.add(jBLabel4, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + jBLabel5.setEnabled(false); + jBLabel5.setText("Checkbox 5"); + panel1.add(jBLabel5, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myJBCheckBox1 = new JBCheckBox(); + panel1.add(myJBCheckBox1, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJBCheckBox2 = new JBCheckBox(); + myJBCheckBox2.setSelected(true); + panel1.add(myJBCheckBox2, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJBCheckBox3 = new JBCheckBox(); + myJBCheckBox3.setSelected(true); + panel1.add(myJBCheckBox3, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJBCheckBox4 = new JBCheckBox(); + myJBCheckBox4.setSelected(true); + panel1.add(myJBCheckBox4, + new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJBCheckBox5 = new JBCheckBox(); + myJBCheckBox5.setEnabled(false); + panel1.add(myJBCheckBox5, + new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel6 = new JBLabel(); + jBLabel6.setText("Radio button 1"); + panel1.add(jBLabel6, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel7 = new JBLabel(); + jBLabel7.setText("Radio button 2"); + panel1.add(jBLabel7, + new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel8 = new JBLabel(); + jBLabel8.setText("Radio button 3"); + panel1.add(jBLabel8, + new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel9 = new JBLabel(); + jBLabel9.setText("Radio button 4"); + panel1.add(jBLabel9, + new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel10 = new JBLabel(); + jBLabel10.setEnabled(false); + jBLabel10.setText("Radio button 5"); + panel1.add(jBLabel10, + new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBRadioButton jBRadioButton1 = new JBRadioButton(); + panel1.add(jBRadioButton1, + new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBRadioButton jBRadioButton2 = new JBRadioButton(); + panel1.add(jBRadioButton2, + new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBRadioButton jBRadioButton3 = new JBRadioButton(); + panel1.add(jBRadioButton3, + new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBRadioButton jBRadioButton4 = new JBRadioButton(); + panel1.add(jBRadioButton4, + new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBRadioButton jBRadioButton5 = new JBRadioButton(); + panel1.add(jBRadioButton5, + new GridConstraints(4, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("Combo 1"); + panel1.add(label1, + new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Combo 2"); + panel1.add(label2, + new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Combo 3"); + panel1.add(label3, + new GridConstraints(2, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setEnabled(false); + label4.setText("Combo 4"); + panel1.add(label4, + new GridConstraints(3, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setEnabled(false); + label5.setText("Combo 5"); + panel1.add(label5, + new GridConstraints(4, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myComboBox1 = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("item 1"); + defaultComboBoxModel1.addElement("item 2"); + defaultComboBoxModel1.addElement("long item"); + defaultComboBoxModel1.addElement("very long item"); + defaultComboBoxModel1.addElement("blah blah blah blah"); + defaultComboBoxModel1.addElement("hello"); + defaultComboBoxModel1.addElement("darcula"); + myComboBox1.setModel(defaultComboBoxModel1); + panel1.add(myComboBox1, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myComboBox2 = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); + defaultComboBoxModel2.addElement("item 1"); + defaultComboBoxModel2.addElement("item 2"); + defaultComboBoxModel2.addElement("long item"); + defaultComboBoxModel2.addElement("very long item"); + defaultComboBoxModel2.addElement("blah blah blah blah"); + defaultComboBoxModel2.addElement("hello"); + defaultComboBoxModel2.addElement("darcula"); + myComboBox2.setModel(defaultComboBoxModel2); + panel1.add(myComboBox2, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myComboBox3 = new JComboBox(); + myComboBox3.setEditable(true); + final DefaultComboBoxModel defaultComboBoxModel3 = new DefaultComboBoxModel(); + defaultComboBoxModel3.addElement("item 1"); + defaultComboBoxModel3.addElement("item 2"); + defaultComboBoxModel3.addElement("long item"); + defaultComboBoxModel3.addElement("very long item"); + defaultComboBoxModel3.addElement("blah blah blah blah"); + defaultComboBoxModel3.addElement("hello"); + defaultComboBoxModel3.addElement("darcula"); + myComboBox3.setModel(defaultComboBoxModel3); + panel1.add(myComboBox3, new GridConstraints(2, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myComboBox4 = new JComboBox(); + myComboBox4.setEditable(true); + myComboBox4.setEnabled(false); + final DefaultComboBoxModel defaultComboBoxModel4 = new DefaultComboBoxModel(); + defaultComboBoxModel4.addElement("item 1"); + defaultComboBoxModel4.addElement("item 2"); + defaultComboBoxModel4.addElement("long item"); + defaultComboBoxModel4.addElement("very long item"); + defaultComboBoxModel4.addElement("blah blah blah blah"); + defaultComboBoxModel4.addElement("hello"); + defaultComboBoxModel4.addElement("darcula"); + myComboBox4.setModel(defaultComboBoxModel4); + panel1.add(myComboBox4, new GridConstraints(3, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myComboBox5 = new JComboBox(); + myComboBox5.setEnabled(false); + final DefaultComboBoxModel defaultComboBoxModel5 = new DefaultComboBoxModel(); + defaultComboBoxModel5.addElement("item 1"); + defaultComboBoxModel5.addElement("item 2"); + defaultComboBoxModel5.addElement("long item"); + defaultComboBoxModel5.addElement("very long item"); + defaultComboBoxModel5.addElement("blah blah blah blah"); + defaultComboBoxModel5.addElement("hello"); + defaultComboBoxModel5.addElement("darcula"); + myComboBox5.setModel(defaultComboBoxModel5); + panel1.add(myComboBox5, new GridConstraints(4, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(6, 0, 1, 8, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JBLabel jBLabel11 = new JBLabel(); + jBLabel11.setText("Username:"); + panel2.add(jBLabel11, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel12 = new JBLabel(); + jBLabel12.setText("Password:"); + panel2.add(jBLabel12, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel13 = new JBLabel(); + jBLabel13.setEnabled(false); + jBLabel13.setText("Disabled:"); + panel2.add(jBLabel13, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel2.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myTextField1 = new JTextField(); + panel2.add(myTextField1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myThisTextIsDisabledTextField = new JTextField(); + myThisTextIsDisabledTextField.setEnabled(false); + myThisTextIsDisabledTextField.setText("This text is disabled"); + panel2.add(myThisTextIsDisabledTextField, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), + null, 0, false)); + myPasswordField1 = new JPasswordField(); + panel2.add(myPasswordField1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTextField2 = new JTextField(); + panel1.add(myTextField2, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTextField3 = new JTextField(); + panel1.add(myTextField3, new GridConstraints(1, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTextField4 = new JTextField(); + panel1.add(myTextField4, new GridConstraints(2, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("Label"); + panel1.add(label6, + new GridConstraints(5, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySpinner1 = new JSpinner(); + panel1.add(mySpinner1, new GridConstraints(5, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Table", panel3); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel3.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myTable = new JBTable(); + jBScrollPane1.setViewportView(myTable); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Progress", panel4); + myProgressBar1 = new JProgressBar(); + myProgressBar1.setIndeterminate(false); + panel4.add(myProgressBar1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel4.add(spacer4, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myProgressButton = new JButton(); + myProgressButton.setText("Start"); + panel4.add(myProgressButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myProgressBar2 = new JProgressBar(); + panel4.add(myProgressBar2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myStartButton = new JButton(); + myStartButton.setText("Start"); + panel4.add(myStartButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel5); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel6); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel7); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel8); + final JPanel panel9 = new JPanel(); + panel9.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel9); + final JPanel panel10 = new JPanel(); + panel10.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab("Untitled", panel10); + final JPanel panel11 = new JPanel(); + panel11.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel11, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer5 = new Spacer(); + panel11.add(spacer5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer6 = new Spacer(); + panel11.add(spacer6, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myHelpButton = new JButton(); + myHelpButton.setText("Help"); + panel11.add(myHelpButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCancelButton = new JButton(); + myCancelButton.setText("Cancel"); + panel11.add(myCancelButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDisabledButton = new JButton(); + myDisabledButton.setEnabled(false); + myDisabledButton.setText("Disabled"); + panel11.add(myDisabledButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDefaultButton = new JButton(); + myDefaultButton.setText("Default"); + panel11.add(myDefaultButton, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(jBRadioButton1); + buttonGroup.add(jBRadioButton2); + buttonGroup.add(jBRadioButton3); + buttonGroup.add(jBRadioButton4); + buttonGroup.add(jBRadioButton5); + } myProgressButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myProgressButton.getText().equals("Start")) { myProgressBar1.setIndeterminate(true); myProgressButton.setText("Stop"); - } else { + } + else { myProgressBar1.setIndeterminate(false); myProgressButton.setText("Start"); } @@ -77,7 +458,7 @@ public class DarculaTest { @Override public void actionPerformed(ActionEvent e) { myStartButton.setEnabled(false); - new Thread("darcula test"){ + new Thread("darcula test") { @Override public void run() { while (myProgressBar2.getValue() < 100) { @@ -97,11 +478,15 @@ public class DarculaTest { myTable.setModel(new DefaultTableModel(new Object[][]{{"Test", "Darcula"}, {"Test1", "Darcula1"}}, new Object[]{"Name", "Value"})); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + public static void main(String[] args) { try { UIManager.setLookAndFeel(new DarculaLaf()); } - catch (UnsupportedLookAndFeelException ignored) {} + catch (UnsupportedLookAndFeelException ignored) { + } final JFrame frame = new JFrame("Darcula Demo"); frame.setSize(900, 500); final DarculaTest form = new DarculaTest(); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/SingleRemoteServerConfigurable.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/SingleRemoteServerConfigurable.java index dbef8cb73abd..d437e44b567b 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/SingleRemoteServerConfigurable.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/SingleRemoteServerConfigurable.java @@ -13,6 +13,9 @@ import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.ServerConfiguration; import com.intellij.remoteServer.util.DelayedRunner; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import com.intellij.util.xmlb.XmlSerializerUtil; import org.jetbrains.annotations.Nls; @@ -23,15 +26,17 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; public class SingleRemoteServerConfigurable extends NamedConfigurable> { private final RemoteServerConfigurable myConfigurable; private final RemoteServer myServer; private @NlsSafe String myServerName; private boolean myNew; - private JPanel myMainPanel; - private JPanel mySettingsPanel; - private JBLabel myConnectionStatusLabel; + private final JPanel myMainPanel; + private final JPanel mySettingsPanel; + private final JBLabel myConnectionStatusLabel; private final DelayedRunner myRunner; private ConnectionTester myConnectionTester; @@ -46,6 +51,28 @@ public class SingleRemoteServerConfigurable extends NamedConfigurable>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 10, 0, 10), -1, -1)); + mySettingsPanel = new JPanel(); + mySettingsPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(mySettingsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myConnectionStatusLabel = new JBLabel(); + myConnectionStatusLabel.setText(" "); + myMainPanel.add(myConnectionStatusLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(10, -1), + new Dimension(10, -1), null, 0, false)); + } myServerName = myServer.getName(); C configuration = server.getConfiguration(); C innerConfiguration = XmlSerializerUtil.createCopy(configuration); @@ -94,6 +121,9 @@ public class SingleRemoteServerConfigurable extends NamedConfigurable RemoteServerConfigurable createConfigurable(RemoteServer server, C configuration) { return server.getType().createServerConfigurable(configuration); } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowMessagePanel.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowMessagePanel.java index 9768f7cb2b08..182d87a45275 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowMessagePanel.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowMessagePanel.java @@ -3,6 +3,8 @@ package com.intellij.remoteServer.impl.runtime.ui; import com.intellij.remoteServer.CloudBundle; import com.intellij.ui.ColorUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.NamedColorUtil; import com.intellij.util.ui.StartupUiUtil; @@ -12,13 +14,30 @@ import org.jetbrains.annotations.NotNull; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Insets; class ServersToolWindowMessagePanel implements RemoteServersDeploymentManager.MessagePanel { - private JPanel myPanel; - private JEditorPane myMessageArea; + private final JPanel myPanel; + private final JEditorPane myMessageArea; private String myCurrentText; ServersToolWindowMessagePanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMessageArea = new JEditorPane(); + myMessageArea.setBackground(new Color(-1513240)); + myMessageArea.setContentType("text/html"); + myMessageArea.setText("\r\n \r\n \r\n \r\n \r\n \r\n\r\n"); //NON-NLS + myPanel.add(myMessageArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(150, 50), null, 0, false)); + } myPanel.setBackground(JBUI.CurrentTheme.ToolWindow.background()); myMessageArea.setBackground(myPanel.getBackground()); myMessageArea.setBorder(JBUI.Borders.empty()); @@ -28,14 +47,18 @@ class ServersToolWindowMessagePanel implements RemoteServersDeploymentManager.Me myMessageArea.setEditable(false); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public void setEmptyText(@NotNull String text) { if (text.equals(myCurrentText)) { return; } - myMessageArea.setText(CloudBundle.message("editor.pane.text.empty.text", UIUtil.getCssFontDeclaration(StartupUiUtil.getLabelFont(), null, null, null), - ColorUtil.toHex(myPanel.getBackground()), ColorUtil.toHex( - NamedColorUtil.getInactiveTextColor()), text)); + myMessageArea.setText( + CloudBundle.message("editor.pane.text.empty.text", UIUtil.getCssFontDeclaration(StartupUiUtil.getLabelFont(), null, null, null), + ColorUtil.toHex(myPanel.getBackground()), ColorUtil.toHex( + NamedColorUtil.getInactiveTextColor()), text)); myCurrentText = text; } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java index b2e5f72f5d15..c6cfd5afb810 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java @@ -20,6 +20,9 @@ import com.intellij.remoteServer.ServerType; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.RemoteServersManager; import com.intellij.remoteServer.impl.configuration.SingleRemoteServerConfigurable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.UniqueNameGenerator; @@ -27,14 +30,19 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; public class CloudAccountSelectionEditor { @@ -43,9 +51,9 @@ public class CloudAccountSelectionEditor { = new HashMap<>(); - private JButton myNewButton; - private ComboBox myAccountComboBox; - private JPanel myMainPanel; + private final JButton myNewButton; + private final ComboBox myAccountComboBox; + private final JPanel myMainPanel; private final List> myCloudTypes; @@ -53,6 +61,26 @@ public class CloudAccountSelectionEditor { public CloudAccountSelectionEditor(List> cloudTypes) { myCloudTypes = cloudTypes; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myNewButton = new JButton(); + this.$$$loadButtonText$$$(myNewButton, this.$$$getMessageFromBundle$$$("messages/CloudBundle", "button.cloud.new")); + myMainPanel.add(myNewButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAccountComboBox = new ComboBox(); + myMainPanel.add(myAccountComboBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(200, -1), null, 0, false)); + } for (ServerType cloudType : cloudTypes) { for (RemoteServer account : RemoteServersManager.getInstance().getServers(cloudType)) { @@ -79,6 +107,53 @@ public class CloudAccountSelectionEditor { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public void setAccountSelectionListener(Runnable listener) { myServerSelectionListener = listener; } @@ -99,8 +174,9 @@ public class CloudAccountSelectionEditor { } }); } - JBPopupFactory.getInstance().createActionGroupPopup(CloudBundle.message("popup.title.new.account"), group, DataManager.getInstance().getDataContext(myMainPanel), - JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false) + JBPopupFactory.getInstance() + .createActionGroupPopup(CloudBundle.message("popup.title.new.account"), group, DataManager.getInstance().getDataContext(myMainPanel), + JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false) .showUnderneathOf(myNewButton); } diff --git a/platform/statistics/devkit/src/com/intellij/internal/statistic/devkit/actions/TestParseEventsSchemeDialog.java b/platform/statistics/devkit/src/com/intellij/internal/statistic/devkit/actions/TestParseEventsSchemeDialog.java index 98067c52087f..8bcfb613dd8f 100644 --- a/platform/statistics/devkit/src/com/intellij/internal/statistic/devkit/actions/TestParseEventsSchemeDialog.java +++ b/platform/statistics/devkit/src/com/intellij/internal/statistic/devkit/actions/TestParseEventsSchemeDialog.java @@ -43,17 +43,24 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.testFramework.LightVirtualFile; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.IncorrectOperationException; import com.intellij.util.PathUtil; import com.jetbrains.fus.reporting.model.metadata.EventGroupRemoteDescriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -66,12 +73,12 @@ public class TestParseEventsSchemeDialog extends DialogWrapper { private static final int IN_DIVIDER_LOCATION = 650; private static final int IN_OUT_DIVIDER_LOCATION = 300; - private JPanel myMainPanel; - private JPanel myEventsSchemePanel; - private JPanel myResultPanel; - private JEditorPane myEventLogPanel; - private JSplitPane myInputDataSplitPane; - private JSplitPane myInputOutputSplitPane; + private final JPanel myMainPanel; + private final JPanel myEventsSchemePanel; + private final JPanel myResultPanel; + private final JEditorPane myEventLogPanel; + private final JSplitPane myInputDataSplitPane; + private final JSplitPane myInputOutputSplitPane; private final Project myProject; private final EditorEx myEventsSchemeEditor; @@ -81,6 +88,44 @@ public class TestParseEventsSchemeDialog extends DialogWrapper { protected TestParseEventsSchemeDialog(@NotNull Project project, @Nullable Editor selectedEditor) { super(project); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myInputOutputSplitPane = new JSplitPane(); + myInputOutputSplitPane.setOrientation(0); + myMainPanel.add(myInputOutputSplitPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, + 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myInputOutputSplitPane.setRightComponent(jBScrollPane1); + myEventLogPanel = new JEditorPane(); + myEventLogPanel.setText("Add event log to filter here, one event per line"); + jBScrollPane1.setViewportView(myEventLogPanel); + myInputDataSplitPane = new JSplitPane(); + myInputDataSplitPane.setContinuousLayout(true); + myInputDataSplitPane.setDividerLocation(230); + myInputDataSplitPane.setDividerSize(2); + myInputOutputSplitPane.setLeftComponent(myInputDataSplitPane); + myInputDataSplitPane.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + myInputDataSplitPane.setLeftComponent(jBScrollPane2); + myEventsSchemePanel = new JPanel(); + myEventsSchemePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBScrollPane2.setViewportView(myEventsSchemePanel); + final JBScrollPane jBScrollPane3 = new JBScrollPane(); + myInputDataSplitPane.setRightComponent(jBScrollPane3); + myResultPanel = new JPanel(); + myResultPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBScrollPane3.setViewportView(myResultPanel); + } setOKButtonText("&Filter Event Log"); setCancelButtonText("&Close"); Disposer.register(myProject, getDisposable()); @@ -105,6 +150,9 @@ public class TestParseEventsSchemeDialog extends DialogWrapper { } } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private @NotNull EditorEx initEditor(@Nullable Editor selectedEditor, @NotNull String fileName, @NotNull String templateText) { if (selectedEditor != null) { return (EditorEx)EditorFactory.getInstance().createEditor(selectedEditor.getDocument(), myProject); diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/context/ConfigureBranchContextDialog.java b/platform/tasks-platform-impl/src/com/intellij/tasks/context/ConfigureBranchContextDialog.java index 06409db7d938..5891e43d4f04 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/context/ConfigureBranchContextDialog.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/context/ConfigureBranchContextDialog.java @@ -8,22 +8,54 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.tasks.TaskBundle; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public class ConfigureBranchContextDialog extends DialogWrapper { private final Project myProject; - private JPanel myPanel; - private JBCheckBox myReloadContext; - private JBCheckBox myShowNotification; + private final JPanel myPanel; + private final JBCheckBox myReloadContext; + private final JBCheckBox myShowNotification; protected ConfigureBranchContextDialog(Project project) { super(project); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myReloadContext = new JBCheckBox(); + this.$$$loadButtonText$$$(myReloadContext, + this.$$$getMessageFromBundle$$$("messages/TaskBundle", "checkbox.restore.workspace.on.branch.switching")); + myPanel.add(myReloadContext, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myShowNotification = new JBCheckBox(); + this.$$$loadButtonText$$$(myShowNotification, this.$$$getMessageFromBundle$$$("messages/TaskBundle", + "checkbox.show.notification.with.ability.to.restore.previous.workspace")); + myPanel.add(myShowNotification, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } setTitle(TaskBundle.message("branch.workspace.settings")); myReloadContext.setSelected(VcsConfiguration.getInstance(project).RELOAD_CONTEXT); @@ -37,6 +69,53 @@ public class ConfigureBranchContextDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myPanel; @@ -47,7 +126,8 @@ public class ConfigureBranchContextDialog extends DialogWrapper { VcsConfiguration.getInstance(myProject).RELOAD_CONTEXT = myReloadContext.isSelected(); NotificationDisplayType displayType = myShowNotification.isSelected() ? NotificationDisplayType.BALLOON : NotificationDisplayType.NONE; - NotificationsConfiguration.getNotificationsConfiguration().changeSettings(BranchContextTracker.NOTIFICATION.getDisplayId(), displayType, true, false); + NotificationsConfiguration.getNotificationsConfiguration() + .changeSettings(BranchContextTracker.NOTIFICATION.getDisplayId(), displayType, true, false); super.doOKAction(); } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsForm.java b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsForm.java index e975e5752d4c..a1b11a270918 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsForm.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsForm.java @@ -13,41 +13,148 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.UserActivityListener; import com.intellij.ui.UserActivityWatcher; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.EventDispatcher; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ExportTestResultsForm { - private JRadioButton myXmlRb; - private JRadioButton myBundledTemplateRb; - private TextFieldWithBrowseButton myCustomTemplateField; - private TextFieldWithBrowseButton myFolderField; - private JPanel myContentPane; - private JLabel myOutputFolderLabel; - private JRadioButton myCustomTemplateRb; - private JTextField myFileNameField; - private JLabel myMessageLabel; - private JCheckBox myOpenExportedFileCb; + private final JRadioButton myXmlRb; + private final JRadioButton myBundledTemplateRb; + private final TextFieldWithBrowseButton myCustomTemplateField; + private final TextFieldWithBrowseButton myFolderField; + private final JPanel myContentPane; + private final JLabel myOutputFolderLabel; + private final JRadioButton myCustomTemplateRb; + private final JTextField myFileNameField; + private final JLabel myMessageLabel; + private final JCheckBox myOpenExportedFileCb; private final EventDispatcher myEventDispatcher = EventDispatcher.create(ChangeListener.class); public ExportTestResultsForm(ExportTestResultsConfiguration config, String defaultFileName, @NlsSafe String defaultFolder) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/TestRunnerBundle", + "border.title.export.format"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myBundledTemplateRb = new JRadioButton(); + myBundledTemplateRb.setText("HTML"); + myBundledTemplateRb.setMnemonic('H'); + myBundledTemplateRb.setDisplayedMnemonicIndex(0); + panel1.add(myBundledTemplateRb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myXmlRb = new JRadioButton(); + myXmlRb.setText("XML"); + myXmlRb.setMnemonic('X'); + myXmlRb.setDisplayedMnemonicIndex(0); + panel1.add(myXmlRb, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCustomTemplateRb = new JRadioButton(); + this.$$$loadButtonText$$$(myCustomTemplateRb, + this.$$$getMessageFromBundle$$$("messages/TestRunnerBundle", "radio.button.custom.apply.xsl.template")); + panel1.add(myCustomTemplateRb, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCustomTemplateField = new TextFieldWithBrowseButton(); + panel1.add(myCustomTemplateField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/TestRunnerBundle", + "border.title.output"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOutputFolderLabel = new JLabel(); + this.$$$loadLabelText$$$(myOutputFolderLabel, this.$$$getMessageFromBundle$$$("messages/TestRunnerBundle", "label.folder")); + panel2.add(myOutputFolderLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFolderField = new TextFieldWithBrowseButton(); + panel2.add(myFolderField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/TestRunnerBundle", "label.file.name")); + panel2.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFileNameField = new JTextField(); + panel2.add(myFileNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myMessageLabel = new JLabel(); + myMessageLabel.setText(" "); + myContentPane.add(myMessageLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myOpenExportedFileCb = new JCheckBox(); + this.$$$loadButtonText$$$(myOpenExportedFileCb, + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "export.test.results.open.browser")); + myContentPane.add(myOpenExportedFileCb, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myBundledTemplateRb); + buttonGroup.add(myXmlRb); + buttonGroup.add(myCustomTemplateRb); + } ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -70,7 +177,8 @@ public class ExportTestResultsForm { }.withTitle(ExecutionBundle.message("export.test.results.custom.template.chooser.title")); myCustomTemplateField.addBrowseFolderListener(null, templateDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); - var outputDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(ExecutionBundle.message("export.test.results.output.folder.chooser.title")); + var outputDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor() + .withTitle(ExecutionBundle.message("export.test.results.output.folder.chooser.title")); myFolderField.addBrowseFolderListener(null, outputDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myFileNameField.getDocument().addDocumentListener(new DocumentAdapter() { @@ -109,6 +217,78 @@ public class ExportTestResultsForm { updateOpenInLabel(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + private void updateOpenInLabel() { myOpenExportedFileCb.setText(ExecutionBundle.message( shouldOpenInBrowser(myFileNameField.getText()) ? "export.test.results.open.browser" : "export.test.results.open.editor")); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictDialog.java index 8dce36224511..5f6ebfc92109 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictDialog.java @@ -11,37 +11,104 @@ import com.intellij.openapi.vcs.changes.LocalChangeList; import com.intellij.openapi.vcs.readOnlyHandler.FileListRenderer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.CollectionListModel; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import javax.swing.AbstractAction; +import javax.swing.AbstractButton; import javax.swing.Action; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; +import java.awt.Insets; import java.awt.event.ActionEvent; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev */ public class ChangelistConflictDialog extends DialogWrapper { - private JPanel myPanel; + private final JPanel myPanel; - private JRadioButton myShelveChangesRadioButton; - private JRadioButton myMoveChangesToActiveRadioButton; - private JRadioButton mySwitchToChangelistRadioButton; - private JRadioButton myIgnoreRadioButton; - private JLabel myListTitle; - private JList myFileList; + private final JRadioButton myShelveChangesRadioButton; + private final JRadioButton myMoveChangesToActiveRadioButton; + private final JRadioButton mySwitchToChangelistRadioButton; + private final JRadioButton myIgnoreRadioButton; + private final JLabel myListTitle; + private final JList myFileList; private final Project myProject; public ChangelistConflictDialog(Project project, List changeLists, List conflicts) { super(project); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + myShelveChangesRadioButton = new JRadioButton(); + myShelveChangesRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myShelveChangesRadioButton, this.$$$getMessageFromBundle$$$("messages/VcsBundle", + "changes.change.list.conflict.dialog.radio.button.shelve.changes")); + panel1.add(myShelveChangesRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myMoveChangesToActiveRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myMoveChangesToActiveRadioButton, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "move.to.changelist")); + panel1.add(myMoveChangesToActiveRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIgnoreRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myIgnoreRadioButton, this.$$$getMessageFromBundle$$$("messages/VcsBundle", + "changes.change.list.conflict.dialog.radio.button.ignore")); + panel1.add(myIgnoreRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySwitchToChangelistRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(mySwitchToChangelistRadioButton, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "switch.to.changelist")); + panel1.add(mySwitchToChangelistRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myListTitle = new JLabel(); + myListTitle.setText(""); + myPanel.add(myListTitle, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFileList = new JBList(); + jBScrollPane1.setViewportView(myFileList); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myMoveChangesToActiveRadioButton); + buttonGroup.add(myShelveChangesRadioButton); + buttonGroup.add(mySwitchToChangelistRadioButton); + buttonGroup.add(myIgnoreRadioButton); + } setTitle(VcsBundle.message("dialog.title.resolve.changelist.conflict")); @@ -79,24 +146,74 @@ public class ChangelistConflictDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected JComponent createCenterPanel() { return myPanel; } public ChangelistConflictResolution getResolution() { - if (myShelveChangesRadioButton.isSelected()) + if (myShelveChangesRadioButton.isSelected()) { return ChangelistConflictResolution.SHELVE; - if (myMoveChangesToActiveRadioButton.isSelected()) + } + if (myMoveChangesToActiveRadioButton.isSelected()) { return ChangelistConflictResolution.MOVE; - if (mySwitchToChangelistRadioButton.isSelected()) + } + if (mySwitchToChangelistRadioButton.isSelected()) { return ChangelistConflictResolution.SWITCH; + } return ChangelistConflictResolution.IGNORE; } @Override protected Action @NotNull [] createLeftSideActions() { - return new Action[] { new AbstractAction(VcsBundle.message("changes.configure")) { + return new Action[]{new AbstractAction(VcsBundle.message("changes.configure")) { @Override public void actionPerformed(ActionEvent e) { ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ChangelistConflictConfigurable.class); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/IssueLinkConfigurationDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/IssueLinkConfigurationDialog.java index 81aaf6fa4558..1e08d5787c2f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/IssueLinkConfigurationDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/IssueLinkConfigurationDialog.java @@ -7,6 +7,10 @@ import com.intellij.openapi.vcs.IssueNavigationConfiguration; import com.intellij.openapi.vcs.IssueNavigationLink; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -16,21 +20,108 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Locale; +import java.util.ResourceBundle; @ApiStatus.Internal public class IssueLinkConfigurationDialog extends DialogWrapper { - private JPanel myPanel; - private JTextField myIssueIDTextField; - private JTextField myIssueLinkTextField; - private JLabel myErrorLabel; - private JTextField myExampleIssueIDTextField; - private JTextField myExampleIssueLinkTextField; + private final JPanel myPanel; + private final JTextField myIssueIDTextField; + private final JTextField myIssueLinkTextField; + private final JLabel myErrorLabel; + private final JTextField myExampleIssueIDTextField; + private final JTextField myExampleIssueLinkTextField; protected IssueLinkConfigurationDialog(Project project) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myErrorLabel = new JLabel(); + myErrorLabel.setForeground(Color.red); + myErrorLabel.setText(" "); + myPanel.add(myErrorLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/VcsBundle", + "add.issue.dialog.issue.example.border.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, + this.$$$getFont$$$(null, -1, -1, panel1.getFont()), null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/VcsBundle", "add.issue.dialog.issue.id.label")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/VcsBundle", "add.issue.dialog.issue.link.label")); + panel1.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myExampleIssueIDTextField = new JTextField(); + panel1.add(myExampleIssueIDTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(150, -1), null, 0, false)); + myExampleIssueLinkTextField = new JTextField(); + myExampleIssueLinkTextField.setEditable(false); + panel1.add(myExampleIssueLinkTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(150, -1), null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "add.issue.dialog.issue.id.regular.expression")); + panel2.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "add.issue.dialog.issue.link.replacement.expression")); + panel2.add(label4, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIssueIDTextField = new JTextField(); + panel2.add(myIssueIDTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(300, -1), null, 0, false)); + myIssueLinkTextField = new JTextField(); + panel2.add(myIssueLinkTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(300, -1), null, 0, false)); + label1.setLabelFor(myExampleIssueIDTextField); + label2.setLabelFor(myExampleIssueLinkTextField); + label3.setLabelFor(myIssueIDTextField); + label4.setLabelFor(myIssueLinkTextField); + } init(); DocumentAdapter documentChangeListener = new DocumentAdapter() { @Override @@ -47,6 +138,77 @@ public class IssueLinkConfigurationDialog extends DialogWrapper { myExampleIssueIDTextField.setText("Task_DA_113"); //NON-NLS // placeholder } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateFeedback() { myErrorLabel.setText(" "); try { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/DateFilterComponent.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/DateFilterComponent.java index 67d2545770e7..41f06b944cae 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/DateFilterComponent.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/DateFilterComponent.java @@ -3,27 +3,37 @@ package com.intellij.openapi.vcs.versionBrowser; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.text.DateTimeFormatManager; +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; import com.michaelbaranov.microba.calendar.DatePicker; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.border.Border; +import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.beans.PropertyVetoException; +import java.lang.reflect.Method; import java.text.DateFormat; import java.util.Date; +import java.util.ResourceBundle; public class DateFilterComponent { - private JPanel myDatePanel; - private JCheckBox myUseDateBeforeFilter; - private JCheckBox myUseDateAfterFilter; - private DatePicker myDateBefore; - private DatePicker myDateAfter; - private JPanel myRootPanel; + private final JPanel myDatePanel; + private final JCheckBox myUseDateBeforeFilter; + private final JCheckBox myUseDateAfterFilter; + private final DatePicker myDateBefore; + private final DatePicker myDateAfter; + private final JPanel myRootPanel; /** @deprecated use {@link #withBorder} and {@link #withFormat} as appropriate */ @Deprecated(forRemoval = true) @@ -34,12 +44,91 @@ public class DateFilterComponent { } public DateFilterComponent() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new BorderLayout(0, 0)); + myDatePanel = new JPanel(); + myDatePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(myDatePanel, BorderLayout.CENTER); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new FormLayout( + "fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):grow,left:4dlu:noGrow,fill:d:noGrow,left:6dlu:noGrow,fill:max(d;4px):grow", + "center:d:grow")); + ((FormLayout)panel1.getLayout()).setColumnGroups(new int[][]{new int[]{3, 7}}); + myDatePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUseDateAfterFilter = new JCheckBox(); + this.$$$loadButtonText$$$(myUseDateAfterFilter, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "checkbox.show.changes.after.date")); + CellConstraints cc = new CellConstraints(); + panel1.add(myUseDateAfterFilter, cc.xy(1, 1)); + myUseDateBeforeFilter = new JCheckBox(); + this.$$$loadButtonText$$$(myUseDateBeforeFilter, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "checkbox.show.changes.before.date")); + panel1.add(myUseDateBeforeFilter, cc.xy(5, 1)); + myDateAfter = new DatePicker(); + panel1.add(myDateAfter, cc.xy(3, 1)); + myDateBefore = new DatePicker(); + panel1.add(myDateBefore, cc.xy(7, 1)); + } withFormat(DateTimeFormatManager.getInstance().getDateFormat()); myUseDateAfterFilter.addActionListener(e -> updateAllEnabled(e)); myUseDateBeforeFilter.addActionListener(e -> updateAllEnabled(e)); updateAllEnabled(null); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + public DateFilterComponent withFormat(@NotNull DateFormat format) { myDateBefore.setDateFormat(format); myDateAfter.setDateFormat(format); @@ -66,7 +155,8 @@ public class DateFilterComponent { myDateBefore.setDate(new Date(beforeTs)); myDateBefore.setEnabled(true); } - catch (PropertyVetoException ignored) { } + catch (PropertyVetoException ignored) { + } } public void setAfter(long afterTs) { @@ -75,7 +165,8 @@ public class DateFilterComponent { myDateAfter.setDate(new Date(afterTs)); myDateAfter.setEnabled(true); } - catch (PropertyVetoException ignored) { } + catch (PropertyVetoException ignored) { + } } public long getBefore() { @@ -93,7 +184,8 @@ public class DateFilterComponent { myDateBefore.setDate(settings.getDateBefore()); myDateAfter.setDate(settings.getDateAfter()); } - catch (PropertyVetoException ignored) { } + catch (PropertyVetoException ignored) { + } updateAllEnabled(null); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/StandardVersionFilterComponent.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/StandardVersionFilterComponent.java index 15c7947e9e5f..393fd6678222 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/StandardVersionFilterComponent.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/versionBrowser/StandardVersionFilterComponent.java @@ -4,20 +4,27 @@ package com.intellij.openapi.vcs.versionBrowser; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public abstract class StandardVersionFilterComponent implements ChangesBrowserSettingsEditor { - private JPanel myPanel; + private final JPanel myPanel; protected JPanel getDatePanel() { return myDateFilterComponent.getPanel(); @@ -27,22 +34,110 @@ public abstract class StandardVersionFilterComponent>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myVersionNumberPanel = new JPanel(); + myVersionNumberPanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myVersionNumberPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myUseNumAfterFilter = new JCheckBox(); + this.$$$loadButtonText$$$(myUseNumAfterFilter, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "checkbox.show.changes.after.num")); + myVersionNumberPanel.add(myUseNumAfterFilter, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNumAfter = new JTextField(); + myVersionNumberPanel.add(myNumAfter, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(50, -1), null, 0, false)); + myUseNumBeforeFilter = new JCheckBox(); + this.$$$loadButtonText$$$(myUseNumBeforeFilter, + this.$$$getMessageFromBundle$$$("messages/VcsBundle", "checkbox.show.changes.before.num")); + myVersionNumberPanel.add(myUseNumBeforeFilter, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNumBefore = new JTextField(); + myVersionNumberPanel.add(myNumBefore, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(50, -1), null, 0, false)); + myDateFilterComponent = new DateFilterComponent(); + myPanel.add(myDateFilterComponent.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + } } public StandardVersionFilterComponent(boolean showDateFilter) { myDateFilterComponent.getPanel().setVisible(showDateFilter); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + protected void init(@NotNull T settings) { myVersionNumberPanel.setBorder(IdeBorderFactory.createTitledBorder(getChangeNumberTitle())); installCheckBoxesListeners(); @@ -137,7 +232,7 @@ public abstract class StandardVersionFilterComponent>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPane.add(myMainPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myMainPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/XDebuggerBundle", + "xbreakpoints.properties.actions.group.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myExpressionPanel = new JPanel(); + myExpressionPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, 0)); + myMainPanel.add(myExpressionPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myLogExpressionCheckBoxPanel = new JPanel(); + myLogExpressionCheckBoxPanel.setLayout(new BorderLayout(0, 0)); + myExpressionPanel.add(myLogExpressionCheckBoxPanel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myLogExpressionPanel = new JPanel(); + myLogExpressionPanel.setLayout(new BorderLayout(0, 0)); + myExpressionPanel.add(myLogExpressionPanel, + new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myLanguageChooserPanel = new JPanel(); + myLanguageChooserPanel.setLayout(new BorderLayout(0, 0)); + myExpressionPanel.add(myLanguageChooserPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myExpressionPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myTemporaryCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myTemporaryCheckBox, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.remove.once.hit.label")); + myMainPanel.add(myTemporaryCheckBox, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myLogMessageLabel = new JLabel(); + this.$$$loadLabelText$$$(myLogMessageLabel, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.log.message.label")); + myLogMessageLabel.setVerticalAlignment(0); + panel1.add(myLogMessageLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myLogMessageCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myLogMessageCheckBox, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.log.message.checkbox")); + panel1.add(myLogMessageCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myLogStack = new JCheckBox(); + this.$$$loadButtonText$$$(myLogStack, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.log.stack.checkbox")); + panel1.add(myLogStack, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + private @Nullable XDebuggerExpressionComboBox myLogExpressionComboBox; private boolean myShowAllOptions; @@ -89,7 +264,8 @@ public class XBreakpointActionsPanel extends XBreakpointPropertiesSubPanel { (!(myBreakpoint instanceof XLineBreakpointProxy) || !((XLineBreakpointProxy)myBreakpoint).isTemporary())) { myMainPanel.setVisible(false); return true; - } else { + } + else { myMainPanel.setBorder(null); return false; } @@ -123,7 +299,8 @@ public class XBreakpointActionsPanel extends XBreakpointPropertiesSubPanel { myLogExpressionCheckBoxPanel.add(label); myLogExpressionPanel.setBorder(JBUI.Borders.emptyLeft(3)); myLogMessageLabel.setBorder(JBUI.Borders.empty(0, 4, 4, 0)); // to unify with other labels - } else { + } + else { myLogExpressionCheckBoxPanel.add(myLogExpressionCheckBox); myLogExpressionPanel.setBorder(JBUI.Borders.emptyLeft(UIUtil.getCheckBoxTextHorizontalOffset(myLogExpressionCheckBox))); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java index e34e36a1ad12..b54e139e6f9a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java @@ -16,6 +16,9 @@ import com.intellij.ui.components.ActionLink; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.popup.util.DetailView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -36,14 +39,26 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; @ApiStatus.Internal public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Delegate { @@ -65,21 +80,12 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele } } - private void createUIComponents() { - myRestoreLink = new ActionLink(XDebuggerBundle.message("xbreakpoints.restore.label"), e -> { - myBreakpointManager.restoreRemovedBreakpoint(myBreakpoint); - if (myBalloon != null) { - myBalloon.hide(); - } - }); - } - public interface Delegate { void showActionOptions(); } - private JPanel myConditionPanel; - private JPanel myMainPanel; + private final JPanel myConditionPanel; + private final JPanel myMainPanel; public Delegate getDelegate() { return myDelegate; @@ -97,20 +103,20 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele private Delegate myDelegate; private @Nullable Balloon myBalloon; - private XSuspendPolicyPanel mySuspendPolicyPanel; - private XBreakpointActionsPanel myActionsPanel; - private XMasterBreakpointPanel myMasterBreakpointPanel; - private JPanel myCustomPropertiesPanelWrapper; - private JPanel myCustomConditionsPanelWrapper; - private JCheckBox myEnabledCheckbox; - private JPanel myCustomRightPropertiesPanelWrapper; + private final XSuspendPolicyPanel mySuspendPolicyPanel; + private final XBreakpointActionsPanel myActionsPanel; + private final XMasterBreakpointPanel myMasterBreakpointPanel; + private final JPanel myCustomPropertiesPanelWrapper; + private final JPanel myCustomConditionsPanelWrapper; + private final JCheckBox myEnabledCheckbox; + private final JPanel myCustomRightPropertiesPanelWrapper; private JBCheckBox myConditionEnabledCheckbox; - private JPanel myCustomTopPropertiesPanelWrapper; - private JBLabel myBreakpointNameLabel; - private JPanel myConditionCheckboxPanel; - private JPanel myLanguageChooserPanel; - private JPanel myConditionExpressionPanel; - private ActionLink myRestoreLink; + private final JPanel myCustomTopPropertiesPanelWrapper; + private final JBLabel myBreakpointNameLabel; + private final JPanel myConditionCheckboxPanel; + private final JPanel myLanguageChooserPanel; + private final JPanel myConditionExpressionPanel; + private final ActionLink myRestoreLink; private final List myCustomPanels; private final List mySubPanels = new ArrayList<>(); @@ -139,6 +145,139 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele myBreakpoint = breakpoint; myShowAllOptions = showAllOptions; myIsEditorBalloon = isEditorBalloon; + { + myRestoreLink = new ActionLink(XDebuggerBundle.message("xbreakpoints.restore.label"), e -> { + myBreakpointManager.restoreRemovedBreakpoint(myBreakpoint); + if (myBalloon != null) { + myBalloon.hide(); + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(11, 2, new Insets(0, 0, 0, 0), -1, -1)); + myConditionPanel = new JPanel(); + myConditionPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, 0)); + myMainPanel.add(myConditionPanel, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myConditionCheckboxPanel = new JPanel(); + myConditionCheckboxPanel.setLayout(new BorderLayout(0, 0)); + myConditionPanel.add(myConditionCheckboxPanel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myLanguageChooserPanel = new JPanel(); + myLanguageChooserPanel.setLayout(new BorderLayout(0, 0)); + myConditionPanel.add(myLanguageChooserPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myConditionExpressionPanel = new JPanel(); + myConditionExpressionPanel.setLayout(new BorderLayout(0, 0)); + myConditionPanel.add(myConditionExpressionPanel, + new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myConditionPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mySuspendPolicyPanel = new XSuspendPolicyPanel(); + myMainPanel.add(mySuspendPolicyPanel.$$$getRootComponent$$$(), + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myActionsPanel = new XBreakpointActionsPanel(); + myMainPanel.add(myActionsPanel.$$$getRootComponent$$$(), + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myMasterBreakpointPanel = new XMasterBreakpointPanel(); + myMainPanel.add(myMasterBreakpointPanel.$$$getRootComponent$$$(), + new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myCustomPropertiesPanelWrapper = new JPanel(); + myCustomPropertiesPanelWrapper.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myCustomPropertiesPanelWrapper, + new GridConstraints(9, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(10, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, new Dimension(400, -1), null, 0, false)); + myCustomConditionsPanelWrapper = new JPanel(); + myCustomConditionsPanelWrapper.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myCustomConditionsPanelWrapper, + new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myCustomRightPropertiesPanelWrapper = new JPanel(); + myCustomRightPropertiesPanelWrapper.setLayout(new BorderLayout(0, 0)); + myCustomRightPropertiesPanelWrapper.setEnabled(true); + myCustomRightPropertiesPanelWrapper.setVisible(true); + myMainPanel.add(myCustomRightPropertiesPanelWrapper, + new GridConstraints(6, 1, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 2, + false)); + myCustomRightPropertiesPanelWrapper.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer3 = new Spacer(); + myMainPanel.add(spacer3, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myCustomTopPropertiesPanelWrapper = new JPanel(); + myCustomTopPropertiesPanelWrapper.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myCustomTopPropertiesPanelWrapper, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(5, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myEnabledCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myEnabledCheckbox, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.enabled.label")); + panel1.add(myEnabledCheckbox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myBreakpointNameLabel = new JBLabel(); + Font myBreakpointNameLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, myBreakpointNameLabel.getFont()); + if (myBreakpointNameLabelFont != null) myBreakpointNameLabel.setFont(myBreakpointNameLabelFont); + this.$$$loadLabelText$$$(myBreakpointNameLabel, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.breakpoint.name")); + panel2.add(myBreakpointNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + this.$$$loadButtonText$$$(myRestoreLink, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoints.restore.label")); + panel2.add(myRestoreLink, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + } XBreakpointTypeProxy breakpointType = breakpoint.getType(); if (breakpointType.getVisibleStandardPanels().contains(XBreakpointType.StandardPanels.SUSPEND_POLICY)) { @@ -176,7 +315,8 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele myConditionExpressionPanel.add(myConditionComboBox.getComponent(), BorderLayout.CENTER); myConditionEnabledCheckbox.addActionListener(e -> onCheckboxChanged()); DebuggerUIUtil.focusEditorOnCheck(myConditionEnabledCheckbox, myConditionComboBox.getEditorComponent()); - } else { + } + else { myConditionPanel.setVisible(false); } @@ -264,8 +404,8 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele XSourcePosition sourcePosition = myBreakpoint.getSourcePosition(); XBreakpointProxy lastRemovedBreakpoint = breakpointManager.getLastRemovedBreakpoint(); boolean restore = lastRemovedBreakpoint != null && - breakpointType.equals(lastRemovedBreakpoint.getType()) && - XSourcePosition.isOnTheSameLine(sourcePosition, lastRemovedBreakpoint.getSourcePosition()) && + breakpointType.equals(lastRemovedBreakpoint.getType()) && + XSourcePosition.isOnTheSameLine(sourcePosition, lastRemovedBreakpoint.getSourcePosition()) && !lastRemovedBreakpoint.haveSameState(breakpoint, true); return Pair.create(sourcePosition, restore); }) @@ -280,6 +420,102 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele .submit(AppExecutorUtil.getAppExecutorService()); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void onCheckboxChanged() { if (myConditionComboBox != null) { myConditionComboBox.setEnabled(myConditionEnabledCheckbox.isSelected()); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java index 2005207d4d76..bf33b150b750 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java @@ -8,24 +8,182 @@ import com.intellij.platform.debugger.impl.shared.proxy.XDebugManagerProxy; import com.intellij.platform.debugger.impl.shared.proxy.XDependentBreakpointManagerProxy; import com.intellij.ui.GuiUtils; import com.intellij.ui.popup.util.DetailView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.UIManager; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; @ApiStatus.Internal public class XMasterBreakpointPanel extends XBreakpointPropertiesSubPanel { - private JPanel myMasterBreakpointComboBoxPanel; - private JPanel myAfterBreakpointHitPanel; - private JRadioButton myLeaveEnabledRadioButton; + private final JPanel myMasterBreakpointComboBoxPanel; + private final JPanel myAfterBreakpointHitPanel; + private final JRadioButton myLeaveEnabledRadioButton; @SuppressWarnings("UnusedDeclaration") - private JPanel myContentPane; - private JPanel myMainPanel; + private final JPanel myContentPane; + private final JPanel myMainPanel; + + public XMasterBreakpointPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.putClientProperty("BorderFactoryClass", ""); + myContentPane.add(myMainPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myMainPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myMasterBreakpointComboBoxPanel = new JPanel(); + myMasterBreakpointComboBoxPanel.setLayout(new BorderLayout(0, 0)); + myMasterBreakpointComboBoxPanel.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoint.master.breakpoint.description")); + myMainPanel.add(myMasterBreakpointComboBoxPanel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 1, + false)); + myAfterBreakpointHitPanel = new JPanel(); + myAfterBreakpointHitPanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myAfterBreakpointHitPanel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 1, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoint.label.after.breakpoint.was.hit")); + myAfterBreakpointHitPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JRadioButton radioButton1 = new JRadioButton(); + radioButton1.setSelected(true); + this.$$$loadButtonText$$$(radioButton1, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoint.radio.disable.again")); + myAfterBreakpointHitPanel.add(radioButton1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myLeaveEnabledRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myLeaveEnabledRadioButton, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoint.radio.leave.enabled")); + myAfterBreakpointHitPanel.add(myLeaveEnabledRadioButton, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myAfterBreakpointHitPanel.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setEnabled(true); + Font label2Font = UIManager.getFont("Label.font"); + if (label2Font != null) label2.setFont(label2Font); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xbreakpoint.master.breakpoint.description")); + myMainPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(radioButton1); + buttonGroup.add(myLeaveEnabledRadioButton); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } private BreakpointChooser myMasterBreakpointChooser; private XDependentBreakpointManagerProxy myDependentBreakpointManager; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java index 9e9e02c9d819..c7f6eed57fca 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java @@ -4,34 +4,147 @@ package com.intellij.xdebugger.impl.breakpoints.ui; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.platform.debugger.impl.shared.proxy.XBreakpointProxy; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.breakpoints.SuspendPolicy; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; import java.awt.CardLayout; import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public class XSuspendPolicyPanel extends XBreakpointPropertiesSubPanel { - private JCheckBox mySuspendCheckBox; - private JRadioButton mySuspendAll; - private JRadioButton mySuspendThread; + private final JCheckBox mySuspendCheckBox; + private final JRadioButton mySuspendAll; + private final JRadioButton mySuspendThread; - private JPanel myContentPane; - private JButton myMakeDefaultButton; - private JPanel myMakeDefaultPanel; + private final JPanel myContentPane; + private final JButton myMakeDefaultButton; + private final JPanel myMakeDefaultPanel; - private ButtonGroup mySuspendPolicyGroup; + public XSuspendPolicyPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPane.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/XDebuggerBundle", + "suspend.policy.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mySuspendAll = new JRadioButton(); + mySuspendAll.setSelected(true); + this.$$$loadButtonText$$$(mySuspendAll, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "suspend.policy.panel.all")); + myContentPane.add(mySuspendAll, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySuspendThread = new JRadioButton(); + this.$$$loadButtonText$$$(mySuspendThread, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "suspend.policy.panel.thread")); + myContentPane.add(mySuspendThread, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySuspendCheckBox = new JCheckBox(); + mySuspendCheckBox.setSelected(true); + this.$$$loadButtonText$$$(mySuspendCheckBox, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "suspend.policy.panel.suspend")); + myContentPane.add(mySuspendCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMakeDefaultPanel = new JPanel(); + myMakeDefaultPanel.setLayout(new CardLayout(0, 0)); + myContentPane.add(myMakeDefaultPanel, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myMakeDefaultButton = new JButton(); + this.$$$loadButtonText$$$(myMakeDefaultButton, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "suspend.policy.panel.makeDefault")); + myMakeDefaultPanel.add(myMakeDefaultButton, "Show"); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMakeDefaultPanel.add(panel1, "Hide"); + mySuspendPolicyGroup = new ButtonGroup(); + mySuspendPolicyGroup.add(mySuspendAll); + mySuspendPolicyGroup.add(mySuspendThread); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + + private final ButtonGroup mySuspendPolicyGroup; public interface Delegate { void showActionOptionsIfNeeded(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java index d4c5137c3fa0..2e1ea2d9ef69 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java @@ -1,17 +1,101 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.xdebugger.impl.evaluate; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nls; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ExpressionInputForm { - private JPanel myLanguageChooserPanel; - private JPanel myExpressionPanel; - private JPanel myMainPanel; - private JLabel myNameLabel; + private final JPanel myLanguageChooserPanel; + private final JPanel myExpressionPanel; + private final JPanel myMainPanel; + private final JLabel myNameLabel; + + public ExpressionInputForm() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myExpressionPanel = new JPanel(); + myExpressionPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myExpressionPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, + this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "xdebugger.evaluate.label.expression")); + myMainPanel.add(myNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myLanguageChooserPanel = new JPanel(); + myLanguageChooserPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myLanguageChooserPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } public void addLanguageComponent(JComponent component) { myLanguageChooserPanel.add(component); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index 87a4f5fcbb4b..4ec4a1bb7d36 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -18,11 +18,15 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.ComponentUtil; import com.intellij.ui.components.ActionLink; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.impl.actions.XDebuggerActions; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -30,8 +34,11 @@ import javax.swing.JPanel; import javax.swing.LayoutFocusTraversalPolicy; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @ApiStatus.Internal public class BreakpointEditor { @@ -39,20 +46,6 @@ public class BreakpointEditor { return myMainPanel; } - private void createUIComponents() { - AnAction action = ActionManager.getInstance().getAction(XDebuggerActions.VIEW_BREAKPOINTS); - String shortcutText = action != null ? KeymapUtil.getFirstKeyboardShortcutText(action) : null; - String text = XDebuggerBundle.message("xbreakpoints.popup.more.label"); - if (shortcutText != null) { - text += " (" + shortcutText + ")"; - } - myShowMoreOptionsLink = new ActionLink(text, e -> { - if (myDelegate != null) { - myDelegate.more(); - } - }); - } - public void setShowMoreOptionsLink(boolean b) { myShowMoreOptionsLink.setVisible(b); } @@ -63,13 +56,61 @@ public class BreakpointEditor { void more(); } - private JPanel myMainPanel; - private JButton myDoneButton; - private JPanel myPropertiesPlaceholder; - private ActionLink myShowMoreOptionsLink; + private final JPanel myMainPanel; + private final JButton myDoneButton; + private final JPanel myPropertiesPlaceholder; + private final ActionLink myShowMoreOptionsLink; private Delegate myDelegate; public BreakpointEditor() { + { + AnAction action = ActionManager.getInstance().getAction(XDebuggerActions.VIEW_BREAKPOINTS); + String shortcutText = action != null ? KeymapUtil.getFirstKeyboardShortcutText(action) : null; + String text = XDebuggerBundle.message("xbreakpoints.popup.more.label"); + if (shortcutText != null) { + text += " (" + shortcutText + ")"; + } + myShowMoreOptionsLink = new ActionLink(text, e -> { + if (myDelegate != null) { + myDelegate.more(); + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(5, 5, 5, 5), -1, -1)); + myPropertiesPlaceholder = new JPanel(); + myPropertiesPlaceholder.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myPropertiesPlaceholder, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myDoneButton = new JButton(); + this.$$$loadButtonText$$$(myDoneButton, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "done.action.text")); + panel1.add(myDoneButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + panel1.add(myShowMoreOptionsLink, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myDoneButton.addActionListener(new ActionListener() { @Override @@ -85,8 +126,8 @@ public class BreakpointEditor { Project project = getEventProject(e); Editor editor = e.getData(CommonDataKeys.EDITOR); boolean disabled = project != null && - (LookupManager.getInstance(project).getActiveLookup() != null || - (editor != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null)); + (LookupManager.getInstance(project).getActiveLookup() != null || + (editor != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null)); final Component owner = IdeFocusManager.findInstance().getFocusOwner(); if (owner != null) { final JComboBox comboBox = ComponentUtil.getParentOfType((Class)JComboBox.class, owner); @@ -94,7 +135,7 @@ public class BreakpointEditor { disabled = true; } } - e.getPresentation().setEnabled(!disabled && (editor == null || StringUtil.isEmpty(editor.getSelectionModel().getSelectedText())) ); + e.getPresentation().setEnabled(!disabled && (editor == null || StringUtil.isEmpty(editor.getSelectionModel().getSelectedText()))); } @Override @@ -114,6 +155,53 @@ public class BreakpointEditor { myMainPanel.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void done() { if (myDelegate != null) { myDelegate.done(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialogBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialogBase.java index 3131b715e663..0950eca122d9 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialogBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialogBase.java @@ -8,6 +8,9 @@ import com.intellij.ui.DocumentAdapter; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.text.UniqueNameGenerator; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebuggerBundle; @@ -25,9 +28,13 @@ import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; import java.util.Set; public abstract class ValueMarkerPresentationDialogBase extends DialogWrapper { @@ -35,14 +42,62 @@ public abstract class ValueMarkerPresentationDialogBase extends DialogWrapper { private final @NotNull Set myExistingMarkups; private SimpleColoredComponent myColorSample; private Color myColor; - private JPanel myMainPanel; - private JTextField myLabelField; - private FixedSizeButton myChooseColorButton; - private JPanel mySamplePanel; - private JPanel myErrorPanel; + private final JPanel myMainPanel; + private final JTextField myLabelField; + private final FixedSizeButton myChooseColorButton; + private final JPanel mySamplePanel; + private final JPanel myErrorPanel; - public ValueMarkerPresentationDialogBase(@Nullable Component parent, @Nullable String defaultText, @NotNull Collection markups) { + public ValueMarkerPresentationDialogBase(@Nullable Component parent, + @Nullable String defaultText, + @NotNull Collection markups) { super(parent, true); + { + myColorSample = new SimpleColoredComponent(); + mySamplePanel = new JPanel(new BorderLayout()); + mySamplePanel.setBorder(BorderFactory.createEtchedBorder()); + mySamplePanel.add(BorderLayout.CENTER, myColorSample); + myChooseColorButton = new FixedSizeButton(mySamplePanel); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 0), 0, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "value.marker.dialog.label.text")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLabelField = new JTextField(); + myLabelField.setColumns(30); + myMainPanel.add(myLabelField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XDebuggerBundle", "value.marker.dialog.preview.label")); + myMainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myMainPanel.add(mySamplePanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(406, 0), null, 0, false)); + myMainPanel.add(myChooseColorButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myErrorPanel = new JPanel(); + myErrorPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myErrorPanel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + label1.setLabelFor(myLabelField); + } setTitle(XDebuggerBundle.message("value.marker.dialog.select.object.label")); setModal(true); myExistingMarkups = StreamEx.of(markups).map(ValueMarkup::getText).toSet(); @@ -55,7 +110,8 @@ public abstract class ValueMarkerPresentationDialogBase extends DialogWrapper { myChooseColorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - final Color color = ColorChooserService.getInstance().showDialog(myColorSample, XDebuggerBundle.message("value.marker.dialog.choose.label.color"), myColor); + final Color color = ColorChooserService.getInstance() + .showDialog(myColorSample, XDebuggerBundle.message("value.marker.dialog.choose.label.color"), myColor); if (color != null) { myColor = color; updateLabelSample(); @@ -70,6 +126,53 @@ public abstract class ValueMarkerPresentationDialogBase extends DialogWrapper { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myLabelField; @@ -96,12 +199,4 @@ public abstract class ValueMarkerPresentationDialogBase extends DialogWrapper { final String text = myLabelField.getText().trim(); return text.isEmpty() ? null : new ValueMarkup(text, myColor, null); } - - private void createUIComponents() { - myColorSample = new SimpleColoredComponent(); - mySamplePanel = new JPanel(new BorderLayout()); - mySamplePanel.setBorder(BorderFactory.createEtchedBorder()); - mySamplePanel.add(BorderLayout.CENTER, myColorSample); - myChooseColorButton = new FixedSizeButton(mySamplePanel); - } } diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java index 0cd0face710d..42b3047f0322 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedPanel.java @@ -18,25 +18,149 @@ package org.intellij.plugins.intelliLang.inject.config.ui; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.LanguageTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.intellij.lang.regexp.RegExpLanguage; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class AdvancedPanel extends AbstractInjectionPanel { - private JPanel myRoot; + private final JPanel myRoot; - private EditorTextField myValuePattern; - private JCheckBox mySingleFileCheckBox; + private final EditorTextField myValuePattern; + private final JCheckBox mySingleFileCheckBox; public AdvancedPanel(Project project, BaseInjection injection) { super(injection, project); - $$$setupUI$$$(); // see IDEA-9987 + { + myValuePattern = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getValuePattern(), + new LanguageTextField.SimpleDocumentCreator() { + @Override + public void customizePsiFile(PsiFile psiFile) { + psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE); + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.putClientProperty("html.disable", Boolean.FALSE); + myRoot.add(panel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "advanced.xml.panel.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "label.value.pattern")); + label1.setToolTipText(this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "tooltip.regular.expression.html")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myValuePattern, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mySingleFileCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(mySingleFileCheckBox, + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "checkbox.single.file")); + panel1.add(mySingleFileCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myValuePattern); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override protected void apply(BaseInjection other) { other.setValuePattern(myValuePattern.getText()); @@ -53,16 +177,4 @@ public final class AdvancedPanel extends AbstractInjectionPanel { public JPanel getComponent() { return myRoot; } - - private void createUIComponents() { - myValuePattern = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getValuePattern(), new LanguageTextField.SimpleDocumentCreator() { - @Override - public void customizePsiFile(PsiFile psiFile) { - psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE); - } - }); - } - - private void $$$setupUI$$$() { - } } diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/BaseInjectionPanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/BaseInjectionPanel.java index 9629ae2c3eb4..95a12b7999a4 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/BaseInjectionPanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/BaseInjectionPanel.java @@ -17,14 +17,24 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; import org.intellij.plugins.intelliLang.inject.config.InjectionPlace; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.ResourceBundle; /** * @author Gregory.Shrago @@ -32,22 +42,66 @@ import java.util.ArrayList; public final class BaseInjectionPanel extends AbstractInjectionPanel { // read by reflection - LanguagePanel myLanguagePanel; - JPanel myCenterPanel; + final LanguagePanel myLanguagePanel; + final JPanel myCenterPanel; EditorTextField myTextArea; - AdvancedPanel myAdvancedPanel; + final AdvancedPanel myAdvancedPanel; - private JPanel myRoot; - private JTextField myNameTextField; + private final JPanel myRoot; + private final JTextField myNameTextField; private final PatternCompiler myHelper; public BaseInjectionPanel(BaseInjection injection, Project project) { super(injection, project); - $$$setupUI$$$(); // see IDEA-9987 + { + myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); + myAdvancedPanel = new AdvancedPanel(myProject, myOrigInjection); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(myLanguagePanel.$$$getRootComponent$$$(), + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCenterPanel = new JPanel(); + myCenterPanel.setLayout(new BorderLayout(0, 0)); + myCenterPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myRoot.add(myCenterPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCenterPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "base.injection.panel.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, + null, null)); + myRoot.add(myAdvancedPanel.$$$getRootComponent$$$(), + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "base.injection.panel.label.name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameTextField = new JTextField(); + panel1.add(myNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + label1.setLabelFor(myNameTextField); + } myHelper = injection.getCompiler(); final FileType groovy = FileTypeManager.getInstance().getFileTypeByExtension("groovy"); final FileType realFileType = groovy == UnknownFileType.INSTANCE ? FileTypes.PLAIN_TEXT : groovy; - final PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("injection." + realFileType.getDefaultExtension(), realFileType, "", 0, true); + final PsiFile psiFile = + PsiFileFactory.getInstance(project).createFileFromText("injection." + realFileType.getDefaultExtension(), realFileType, "", 0, true); final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); psiFile.putUserData(BaseInjection.INJECTION_KEY, injection); myTextArea = new EditorTextField(document, project, realFileType) { @@ -70,6 +124,53 @@ public final class BaseInjectionPanel extends AbstractInjectionPanel thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override protected void apply(BaseInjection other) { final String displayName = myNameTextField.getText(); @@ -124,7 +225,7 @@ public final class BaseInjectionPanel extends AbstractInjectionPanel { - private JPanel myRoot; - private ComboBox<@Nls String> myLanguage; - private EditorTextField myPrefix; - private EditorTextField mySuffix; + private final JPanel myRoot; + private final ComboBox<@Nls String> myLanguage; + private final EditorTextField myPrefix; + private final EditorTextField mySuffix; public LanguagePanel(Project project, BaseInjection injection) { super(injection, project); - $$$setupUI$$$(); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "language.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "language.label.id")); + myRoot.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "language.label.prefix")); + myRoot.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "language.label.suffix")); + myRoot.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLanguage = new ComboBox(); + myRoot.add(myLanguage, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPrefix = new EditorTextField(); + myRoot.add(myPrefix, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySuffix = new EditorTextField(); + myRoot.add(mySuffix, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myLanguage); + label2.setLabelFor(myPrefix); + label3.setLabelFor(mySuffix); + } final String[] languageIDs = ContainerUtil.map2Array(InjectedLanguage.getAvailableLanguages(), String.class, Language::getID); Arrays.sort(languageIDs, String::compareToIgnoreCase); @@ -95,6 +143,53 @@ public final class LanguagePanel extends AbstractInjectionPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + void updateHighlighters() { final EditorImpl editor = (EditorImpl)myPrefix.getEditor(); if (editor == null) return; @@ -166,7 +261,4 @@ public final class LanguagePanel extends AbstractInjectionPanel { public JPanel getComponent() { return myRoot; } - - private void $$$setupUI$$$() { - } } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java index 5714b0713d3d..4e016e7fdde8 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java @@ -13,9 +13,13 @@ import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.ArtifactPropertiesEditor; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.config.ListProperty; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColumnInfo; @@ -23,14 +27,20 @@ import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { private static final ListProperty ANT_PROPERTIES = ListProperty.create("ant-properties"); @@ -74,11 +84,11 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { private final AntArtifactProperties myProperties; private final ArtifactEditorContext myContext; private final AntConfigurationListener myAntConfigurationListener; - private JPanel myMainPanel; - private JCheckBox myRunTargetCheckBox; - private FixedSizeButton mySelectTargetButton; + private final JPanel myMainPanel; + private final JCheckBox myRunTargetCheckBox; + private final FixedSizeButton mySelectTargetButton; private final JBTable myPropertiesTable; - private JPanel myPropertiesPanel; + private final JPanel myPropertiesPanel; private AntBuildTarget myTarget; private final boolean myPostProcessing; private final UIPropertyBinding.TableListBinding myBinding; @@ -88,6 +98,46 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { myProperties = properties; myContext = context; myPostProcessing = postProcessing; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRunTargetCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myRunTargetCheckBox, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "checkbox.ant.artifact.properties.run")); + panel1.add(myRunTargetCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mySelectTargetButton = new FixedSizeButton(); + panel1.add(mySelectTargetButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new BorderLayout(0, 0)); + myPropertiesPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myPropertiesPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(-1, 250), null, 1, false)); + myPropertiesPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/AntBundle", "table.title.ant.artifact.properties.editor"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + } mySelectTargetButton.addActionListener(e -> selectTarget()); myRunTargetCheckBox.addActionListener(e -> { mySelectTargetButton.setEnabled(myRunTargetCheckBox.isSelected()); @@ -125,20 +175,20 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { } } }).setRemoveAction(button -> TableUtil.removeSelectedItems(myPropertiesTable)).setRemoveActionUpdater(e -> { - final ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel(); - ListTableModel model = (ListTableModel)myPropertiesTable.getModel(); - boolean enable = false; - if (!selectionModel.isSelectionEmpty()) { - enable = true; - for (int i : myPropertiesTable.getSelectedRows()) { - if (AntArtifactProperties.isPredefinedProperty(model.getItems().get(i).getPropertyName())) { - enable = false; - break; + final ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel(); + ListTableModel model = (ListTableModel)myPropertiesTable.getModel(); + boolean enable = false; + if (!selectionModel.isSelectionEmpty()) { + enable = true; + for (int i : myPropertiesTable.getSelectedRows()) { + if (AntArtifactProperties.isPredefinedProperty(model.getItems().get(i).getPropertyName())) { + enable = false; + break; + } } } - } - return enable; - }).disableUpDownActions().createPanel(), BorderLayout.CENTER); + return enable; + }).disableUpDownActions().createPanel(), BorderLayout.CENTER); final AntConfiguration antConfiguration = AntConfiguration.getInstance(context.getProject()); myAntConfigurationListener = new AntConfigurationListener() { @Override @@ -152,6 +202,53 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { antConfiguration.addAntConfigurationListener(myAntConfigurationListener); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void selectTarget() { final TargetChooserDialog dialog = new TargetChooserDialog(myContext.getProject(), myTarget); if (dialog.showAndGet()) { diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AnActionListEditor.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AnActionListEditor.java index 1f8728b913dd..f5609e79a859 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AnActionListEditor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AnActionListEditor.java @@ -23,12 +23,17 @@ import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.NlsActions; import com.intellij.ui.ReorderableListController; import com.intellij.ui.ScrollingUtil; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import javax.swing.DefaultListModel; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -126,17 +131,40 @@ public class AnActionListEditor extends JPanel { myForm.createToolbar(); } - private static class Form { - private JComponent myWholePanel; - private JPanel myActionsPlace; - private JList myList; + private static class Form { + private final JComponent myWholePanel; + private final JPanel myActionsPlace; + private final JList myList; private final ReorderableListToolbar myListController; Form() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myActionsPlace = new JPanel(); + myWholePanel.add(myActionsPlace, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myWholePanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myList = new JBList(); + myList.setSelectionMode(0); + jBScrollPane1.setViewportView(myList); + } myList.setModel(new DefaultListModel<>()); myListController = new ReorderableListToolbar<>(myList); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public void createToolbar() { myActionsPlace.removeAll(); myActionsPlace.setLayout(new BorderLayout()); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java index 2877cdd63cee..6b826244f866 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java @@ -19,16 +19,25 @@ import com.intellij.lang.ant.config.impl.AllJarsUnderDirEntry; import com.intellij.lang.ant.config.impl.AntClasspathEntry; import com.intellij.lang.ant.config.impl.SinglePathEntry; import com.intellij.ui.ListUtil; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.config.AbstractProperty; import com.intellij.util.config.ListProperty; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.ResourceBundle; public class AntClasspathEditorPanel extends JPanel { private ListProperty myClasspathProperty; @@ -75,16 +84,59 @@ public class AntClasspathEditorPanel extends JPanel { } public static class Form { - private JButton myAddButton; - private JButton myAddAllInDir; - private JButton myRemoveButton; - private JButton myMoveUpButton; - private JButton myMoveDownButton; - private JPanel myWholePanel; - private JList myClasspathList; + private final JButton myAddButton; + private final JButton myAddAllInDir; + private final JButton myRemoveButton; + private final JButton myMoveUpButton; + private final JButton myMoveDownButton; + private final JPanel myWholePanel; + private final JList myClasspathList; private final ArrayList myUpdatables = new ArrayList<>(); public Form() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + myAddButton = new JButton(); + this.$$$loadButtonText$$$(myAddButton, this.$$$getMessageFromBundle$$$("messages/AntBundle", "button.add")); + myWholePanel.add(myAddButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRemoveButton = new JButton(); + this.$$$loadButtonText$$$(myRemoveButton, this.$$$getMessageFromBundle$$$("messages/AntBundle", "button.remove")); + myWholePanel.add(myRemoveButton, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMoveUpButton = new JButton(); + this.$$$loadButtonText$$$(myMoveUpButton, this.$$$getMessageFromBundle$$$("messages/AntBundle", "button.move.up")); + myWholePanel.add(myMoveUpButton, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMoveDownButton = new JButton(); + this.$$$loadButtonText$$$(myMoveDownButton, this.$$$getMessageFromBundle$$$("messages/AntBundle", "button.move.down")); + myWholePanel.add(myMoveDownButton, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myWholePanel.add(jBScrollPane1, new GridConstraints(0, 0, 6, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myClasspathList = new JBList(); + jBScrollPane1.setViewportView(myClasspathList); + myAddAllInDir = new JButton(); + this.$$$loadButtonText$$$(myAddAllInDir, this.$$$getMessageFromBundle$$$("messages/AntBundle", + "additional.classpath.tab.add.all.in.directory.button")); + myWholePanel.add(myAddAllInDir, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myClasspathList.setCellRenderer(new AntUIUtil.ClasspathRenderer()); myUpdatables.add(ListUtil.addRemoveListener(myRemoveButton, myClasspathList)); @@ -92,6 +144,53 @@ public class AntClasspathEditorPanel extends JPanel { myUpdatables.add(ListUtil.addMoveDownListener(myMoveDownButton, myClasspathList)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public void enableButtons(boolean enable) { for (ListUtil.Updatable updatable : myUpdatables) { updatable.enable(enable); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java index c5a23f93d42f..6bf9da65454a 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java @@ -15,6 +15,8 @@ import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.JBSplitter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.config.AbstractProperty; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -27,13 +29,17 @@ import javax.swing.JTextField; import javax.swing.ListModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.Dimension; +import java.awt.Insets; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; public class AntSetPanel { @@ -187,18 +193,107 @@ public class AntSetPanel { } private static class RightPanel { - private JLabel myNameLabel; - private JLabel myHome; - private JTextField myName; - private AntClasspathEditorPanel myClasspath; - private JPanel myWholePanel; + private final JLabel myNameLabel; + private final JLabel myHome; + private final JTextField myName; + private final AntClasspathEditorPanel myClasspath; + private final JPanel myWholePanel; RightPanel(UIPropertyBinding.Composite binding, PropertyChangeListener immediateUpdater) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/AntBundle", "ant.settings.name.label")); + myWholePanel.add(myNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/AntBundle", "ant.settings.home.label")); + myWholePanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myClasspath = new AntClasspathEditorPanel(); + myClasspath.setEnabled(true); + myWholePanel.add(myClasspath, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + myName = new JTextField(); + panel1.add(myName, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myHome = new JLabel(); + myHome.setText(""); + myWholePanel.add(myHome, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + } myNameLabel.setLabelFor(myName); binding.addBinding(myClasspath.setClasspathProperty(AntInstallation.CLASS_PATH)); binding.bindString(myHome, AntInstallation.HOME_DIR); binding.bindString(myName, AntInstallation.NAME).addChangeListener(immediateUpdater); } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } } } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java index def5023a580f..0f137413c241 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java @@ -28,13 +28,20 @@ import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.TabbedPaneWrapper; import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.config.AbstractProperty; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -46,13 +53,17 @@ import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.table.TableCellEditor; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; +import java.util.ResourceBundle; public final class BuildFilePropertiesPanel { private static final @NonNls String DIMENSION_SERVICE_KEY = "antBuildFilePropertiesDialogDimension"; @@ -132,20 +143,92 @@ public final class BuildFilePropertiesPanel { } private static final class Form implements Disposable { - private JLabel myBuildFileName; - private JTextField myXmx; - private JTextField myXss; - private JCheckBox myRunInBackground; - private JCheckBox myCloseOnNoError; - private JPanel myTabsPlace; - private JPanel myWholePanel; - private JLabel myHeapSizeLabel; - private JCheckBox myColoredOutputMessages; - private JCheckBox myCollapseFinishedTargets; + private final JLabel myBuildFileName; + private final JTextField myXmx; + private final JTextField myXss; + private final JCheckBox myRunInBackground; + private final JCheckBox myCloseOnNoError; + private final JPanel myTabsPlace; + private final JPanel myWholePanel; + private final JLabel myHeapSizeLabel; + private final JCheckBox myColoredOutputMessages; + private final JCheckBox myCollapseFinishedTargets; private final Tab[] myTabs; private final UIPropertyBinding.Composite myBinding = new UIPropertyBinding.Composite(); private Form() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(5, 4, new Insets(0, 0, 0, 0), -1, -1)); + myBuildFileName = new JLabel(); + myBuildFileName.setText("<######## ## ####> "); + myWholePanel.add(myBuildFileName, new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myRunInBackground = new JCheckBox(); + this.$$$loadButtonText$$$(myRunInBackground, + this.$$$getMessageFromBundle$$$("messages/AntBundle", + "build.file.properties.make.in.background.cjeclbox")); + myWholePanel.add(myRunInBackground, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTabsPlace = new JPanel(); + myWholePanel.add(myTabsPlace, new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myHeapSizeLabel = new JLabel(); + this.$$$loadLabelText$$$(myHeapSizeLabel, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "build.file.properties.maximum.heap.size.label")); + myWholePanel.add(myHeapSizeLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, + null, 0, false)); + myCloseOnNoError = new JCheckBox(); + this.$$$loadButtonText$$$(myCloseOnNoError, + this.$$$getMessageFromBundle$$$("messages/AntBundle", + "build.file.properties.close.message.view.checkbox")); + myCloseOnNoError.setToolTipText(""); + myWholePanel.add(myCloseOnNoError, new GridConstraints(2, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myXmx = new JTextField(); + myXmx.setColumns(4); + myWholePanel.add(myXmx, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "build.file.properties.maximum.stack.size.label")); + myWholePanel.add(label1, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myXss = new JTextField(); + myXss.setColumns(4); + myWholePanel.add(myXss, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + myColoredOutputMessages = new JCheckBox(); + this.$$$loadButtonText$$$(myColoredOutputMessages, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "checkbox.colored.output.messages")); + myWholePanel.add(myColoredOutputMessages, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCollapseFinishedTargets = new JCheckBox(); + this.$$$loadButtonText$$$(myCollapseFinishedTargets, this.$$$getMessageFromBundle$$$("messages/AntBundle", + "checkbox.collapse.finished.targets.in.message.view")); + myWholePanel.add(myCollapseFinishedTargets, new GridConstraints(3, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } myTabs = new Tab[]{ new PropertiesTab(), new ExecutionTab(GlobalAntConfiguration.getInstance()), @@ -170,6 +253,78 @@ public final class BuildFilePropertiesPanel { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public JComponent getComponent() { return myWholePanel; } @@ -305,8 +460,8 @@ public final class BuildFilePropertiesPanel { } private static class FiltersTab extends Tab { - private JTable myFiltersTable; - private JPanel myWholePanel; + private final JTable myFiltersTable; + private final JPanel myWholePanel; private static final int PREFERRED_CHECKBOX_COLUMN_WIDTH = new JCheckBox().getPreferredSize().width + 4; private static final ColumnInfo CHECK_BOX_COLUMN = new ColumnInfo<>("") { @@ -382,6 +537,20 @@ public final class BuildFilePropertiesPanel { private static final ColumnInfo[] COLUMNS = new ColumnInfo[]{CHECK_BOX_COLUMN, NAME_COLUMN, DESCRIPTION}; FiltersTab() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myWholePanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myFiltersTable = new JBTable(); + jBScrollPane1.setViewportView(myFiltersTable); + } myFiltersTable.getTableHeader().setReorderingAllowed(false); UIPropertyBinding.TableListBinding tableListBinding = getBinding().bindList(myFiltersTable, COLUMNS, AntBuildFileImpl.TARGET_FILTERS); @@ -389,6 +558,9 @@ public final class BuildFilePropertiesPanel { tableListBinding.setSortable(true); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public JComponent getComponent() { return myWholePanel; @@ -406,23 +578,121 @@ public final class BuildFilePropertiesPanel { } static class ExecutionTab extends Tab { - private JPanel myWholePanel; - private JLabel myAntCmdLineLabel; - private JLabel myJDKLabel; - private RawCommandLineEditor myAntCommandLine; - private ComboboxWithBrowseButton myAnts; - private ComboboxWithBrowseButton myJDKs; + private final JPanel myWholePanel; + private final JLabel myAntCmdLineLabel; + private final JLabel myJDKLabel; + private final RawCommandLineEditor myAntCommandLine; + private final ComboboxWithBrowseButton myAnts; + private final ComboboxWithBrowseButton myJDKs; private final ChooseAndEditComboBoxController myJDKsController; - private JButton mySetDefaultAnt; - private SimpleColoredComponent myDefaultAnt; - private JRadioButton myUseCastomAnt; - private JRadioButton myUseDefaultAnt; + private final JButton mySetDefaultAnt; + private final SimpleColoredComponent myDefaultAnt; + private final JRadioButton myUseCastomAnt; + private final JRadioButton myUseDefaultAnt; private AntReference myProjectDefaultAnt = null; private final GlobalAntConfiguration myAntGlobalConfiguration; ExecutionTab(final GlobalAntConfiguration antConfiguration) { myAntGlobalConfiguration = antConfiguration; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(1, 1, new Insets(6, 6, 6, 6), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 2, new Insets(0, 3, 0, 3), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + myJDKLabel = new JLabel(); + this.$$$loadLabelText$$$(myJDKLabel, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.run.under.jdk.label")); + panel1.add(myJDKLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJDKs = new ComboboxWithBrowseButton(); + panel1.add(myJDKs, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(10, 0, 10, 0), -1, 0)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, true)); + myAntCommandLine = new RawCommandLineEditor(); + panel2.add(myAntCommandLine, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myAntCmdLineLabel = new JLabel(); + this.$$$loadLabelText$$$(myAntCmdLineLabel, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.ant.command.line.label")); + panel2.add(myAntCmdLineLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel1.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.ant.command.line.hint")); + panel2.add(jBLabel1, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.run.with.ant.border")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, false)); + myUseDefaultAnt = new JRadioButton(); + this.$$$loadButtonText$$$(myUseDefaultAnt, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.use.project.default.ant.radio")); + panel3.add(myUseDefaultAnt, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, false)); + mySetDefaultAnt = new JButton(); + this.$$$loadButtonText$$$(mySetDefaultAnt, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.set.default.button")); + panel4.add(mySetDefaultAnt, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDefaultAnt = new SimpleColoredComponent(); + panel4.add(myDefaultAnt, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + myUseCastomAnt = new JRadioButton(); + this.$$$loadButtonText$$$(myUseCastomAnt, + this.$$$getMessageFromBundle$$$("messages/AntBundle", "run.execution.tab.use.custom.ant.radio")); + panel3.add(myUseCastomAnt, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnts = new ComboboxWithBrowseButton(); + panel3.add(myAnts, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } myAntCommandLine.attachLabel(myAntCmdLineLabel); myAntCommandLine.setDialogCaption(AntBundle.message("run.execution.tab.ant.command.line.dialog.title")); setLabelFor(myJDKLabel, myJDKs); @@ -469,6 +739,78 @@ public final class BuildFilePropertiesPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public JComponent getComponent() { return myWholePanel; @@ -509,13 +851,30 @@ public final class BuildFilePropertiesPanel { } private static class AdditionalClasspathTab extends Tab { - private JPanel myWholePanel; - private AntClasspathEditorPanel myClasspath; + private final JPanel myWholePanel; + private final AntClasspathEditorPanel myClasspath; AdditionalClasspathTab() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(1, 1, new Insets(6, 6, 6, 6), -1, -1)); + myClasspath = new AntClasspathEditorPanel(); + myClasspath.setEnabled(true); + myWholePanel.add(myClasspath, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, + null, null, 0, false)); + } getBinding().addBinding(myClasspath.setClasspathProperty(AntBuildFileImpl.ADDITIONAL_CLASSPATH)); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public JComponent getComponent() { return myWholePanel; diff --git a/plugins/built-in-help/src/com/jetbrains/builtInHelp/settings/SettingsPage.java b/plugins/built-in-help/src/com/jetbrains/builtInHelp/settings/SettingsPage.java index 467d82cff8fe..06861c7da20f 100644 --- a/plugins/built-in-help/src/com/jetbrains/builtInHelp/settings/SettingsPage.java +++ b/plugins/built-in-help/src/com/jetbrains/builtInHelp/settings/SettingsPage.java @@ -6,19 +6,30 @@ import com.intellij.ide.browsers.WebBrowser; import com.intellij.ide.browsers.WebBrowserManager; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.util.Pair; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.builtInHelp.BuiltInHelpBundle; import com.jetbrains.builtInHelp.Utils; import org.jetbrains.annotations.NonNls; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class SettingsPage implements Configurable { @@ -91,10 +102,115 @@ public class SettingsPage implements Configurable { } }; - JPanel root; - JCheckBox openWebSite; - JTextField baseUrl; - JComboBox webBrowserList; + final JPanel root; + final JCheckBox openWebSite; + final JTextField baseUrl; + final JComboBox webBrowserList; + + public SettingsPageUI() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + root = new JPanel(); + root.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 2, new Insets(5, 5, 5, 5), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + root.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, + false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/BuiltInHelpBundle", "settings.border.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/BuiltInHelpBundle", "try.opening.online.help.when.available")); + panel1.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + openWebSite = new JCheckBox(); + openWebSite.setText(""); + panel1.add(openWebSite, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/BuiltInHelpBundle", "online.help.base.url")); + panel1.add(label2, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/BuiltInHelpBundle", "use.this.browser")); + panel1.add(label3, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + webBrowserList = new JComboBox(); + panel1.add(webBrowserList, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + baseUrl = new JTextField(); + panel1.add(baseUrl, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + root.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return root; } DocumentListener textChangeListener = new DocumentListener() { @Override diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java index 24ad077417d4..35acf5d14c04 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java @@ -20,6 +20,9 @@ import com.intellij.ui.EditorCustomization; import com.intellij.ui.EditorTextField; import com.intellij.ui.EditorTextFieldProvider; import com.intellij.ui.SoftWrapsEditorCustomization; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.DocumentUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; @@ -30,6 +33,7 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -37,9 +41,13 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.HashSet; +import java.util.ResourceBundle; import java.util.Set; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -47,17 +55,17 @@ import java.util.regex.PatternSyntaxException; public class CopyrightConfigurable extends NamedConfigurable { private final CopyrightProfile myCopyrightProfile; private boolean myShareProfile; - private JPanel myWholePanel; + private final JPanel myWholePanel; private final Project myProject; private boolean myModified; private String myDisplayName; private final EditorTextField myEditor; - private JButton myValidateButton; - private JTextField myKeywordTf; - private JTextField myAllowReplaceTextField; - private JPanel myEditorPanel; + private final JButton myValidateButton; + private final JTextField myKeywordTf; + private final JTextField myAllowReplaceTextField; + private final JPanel myEditorPanel; private final JCheckBox mySharedCheckbox; private final JLabel mySharedContextHelp; @@ -67,6 +75,55 @@ public class CopyrightConfigurable extends NamedConfigurable { myProject = project; myCopyrightProfile = copyrightProfile; myShareProfile = shareProfile; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/CopyrightBundle", "label.regexp.to.detect.copyright.in.comments")); + myWholePanel.add(label1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myKeywordTf = new JTextField(); + myWholePanel.add(myKeywordTf, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myValidateButton = new JButton(); + this.$$$loadButtonText$$$(myValidateButton, this.$$$getMessageFromBundle$$$("messages/CopyrightBundle", "button.validate")); + myWholePanel.add(myValidateButton, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/CopyrightBundle", + "label.allow.replacing.copyright.if.old.copyright.matches")); + myWholePanel.add(label2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAllowReplaceTextField = new JTextField(); + myWholePanel.add(myAllowReplaceTextField, + new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/CopyrightBundle", + "label.copyright.text.may.contain.velocity.templates")); + myWholePanel.add(label3, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + myWholePanel.add(myEditorPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + label2.setLabelFor(myAllowReplaceTextField); + } myDisplayName = myCopyrightProfile.getName(); final Set features = new HashSet<>(); ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization()); @@ -84,6 +141,78 @@ public class CopyrightConfigurable extends NamedConfigurable { mySharedContextHelp.setBorder(JBUI.Borders.empty(0, 5)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public void setDisplayName(String s) { myCopyrightProfile.setName(s); @@ -146,8 +275,10 @@ public class CopyrightConfigurable extends NamedConfigurable { public void apply() throws ConfigurationException { myCopyrightProfile.setNotice(EntityUtil.encode(myEditor.getDocument().getText())); myCopyrightProfile.setKeyword(validateRegexpAndGet(myKeywordTf.getText().trim(), - CopyrightBundle.message("detect.copyright.regexp.is.incorrect.configuration.error"))); - myCopyrightProfile.setAllowReplaceRegexp(validateRegexpAndGet(myAllowReplaceTextField.getText().trim(), CopyrightBundle.message("replace.copyright.regexp.is.incorrect.configuration.error"))); + CopyrightBundle.message( + "detect.copyright.regexp.is.incorrect.configuration.error"))); + myCopyrightProfile.setAllowReplaceRegexp(validateRegexpAndGet(myAllowReplaceTextField.getText().trim(), CopyrightBundle.message( + "replace.copyright.regexp.is.incorrect.configuration.error"))); myShareProfile = mySharedCheckbox.isSelected(); if (myShareProfile) { IdeCopyrightManager.getInstance().removeCopyright(myCopyrightProfile); @@ -161,7 +292,8 @@ public class CopyrightConfigurable extends NamedConfigurable { myModified = false; } - private static @NotNull String validateRegexpAndGet(final String regexp, final @NlsContexts.DialogMessage String message) throws ConfigurationException { + private static @NotNull String validateRegexpAndGet(final String regexp, final @NlsContexts.DialogMessage String message) + throws ConfigurationException { try { if (!StringUtil.isEmptyOrSpaces(regexp)) { Pattern.compile(regexp); diff --git a/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java b/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java index 930a29971a67..2f36a1e91f12 100644 --- a/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java +++ b/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java @@ -90,6 +90,7 @@ import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.SortedComboBoxModel; import com.intellij.ui.TitledSeparator; import com.intellij.ui.TreeUIHelper; +import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.tabs.JBTabs; @@ -98,6 +99,8 @@ import com.intellij.ui.tabs.TabInfo; import com.intellij.ui.tree.AsyncTreeModel; import com.intellij.ui.tree.StructureTreeModel; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.ObjectUtils; @@ -115,6 +118,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.AbstractAction; import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; @@ -129,6 +133,7 @@ import javax.swing.JTree; import javax.swing.KeyStroke; import javax.swing.LayoutFocusTraversalPolicy; import javax.swing.ToolTipManager; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TreeSelectionEvent; @@ -142,6 +147,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.FocusTraversalPolicy; import java.awt.Font; +import java.awt.Insets; import java.awt.Window; import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; @@ -176,27 +182,27 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { private final StructureTreeModel myStructureTreeModel; private final ViewerTreeStructure myTreeStructure; - private JPanel myPanel; - private ComboBox myFileTypeComboBox; - private JCheckBox myShowWhiteSpacesBox; - private JCheckBox myShowTreeNodesCheckBox; - private JCheckBox myShowEmptyPropertiesCheckBox; + private final JPanel myPanel; + private final ComboBox myFileTypeComboBox; + private final JCheckBox myShowWhiteSpacesBox; + private final JCheckBox myShowTreeNodesCheckBox; + private final JCheckBox myShowEmptyPropertiesCheckBox; - private JCheckBox myUpdatePsiTreeCheckbox; + private final JCheckBox myUpdatePsiTreeCheckbox; - private JBLabel myDialectLabel; - private JComboBox myDialectComboBox; - private JLabel myExtensionLabel; - private JComboBox myExtensionComboBox; - private JPanel myTextPanel; - private JSplitPane myTextSplit; - private JSplitPane myTreeSplit; + private final JBLabel myDialectLabel; + private final JComboBox myDialectComboBox; + private final JLabel myExtensionLabel; + private final JComboBox myExtensionComboBox; + private final JPanel myTextPanel; + private final JSplitPane myTextSplit; + private final JSplitPane myTreeSplit; private final JPanel myPsiTreePanel; private final Tree myPsiTree; private final JList myRefs; - private TitledSeparator myTextSeparator; + private final TitledSeparator myTextSeparator; private final TitledSeparator myPsiTreeSeparator; private final @NotNull StubViewerPsiBasedTree myStubTree; @@ -250,6 +256,132 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { public PsiViewerDialog(@NotNull Project project, @Nullable Editor selectedEditor) { super(project, true, IdeModalityType.MODELESS); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 7, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setDoubleBuffered(true); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowWhiteSpacesBox = new JCheckBox(); + myShowWhiteSpacesBox.setMargin(new Insets(0, 0, 0, 0)); + myShowWhiteSpacesBox.setSelected(true); + myShowWhiteSpacesBox.setText("Show PsiWhiteSpace"); + myShowWhiteSpacesBox.setMnemonic('W'); + myShowWhiteSpacesBox.setDisplayedMnemonicIndex(8); + panel1.add(myShowWhiteSpacesBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowTreeNodesCheckBox = new JCheckBox(); + myShowTreeNodesCheckBox.setMargin(new Insets(0, 0, 0, 0)); + myShowTreeNodesCheckBox.setSelected(true); + myShowTreeNodesCheckBox.setText("Show tree nodes"); + myShowTreeNodesCheckBox.setMnemonic('N'); + myShowTreeNodesCheckBox.setDisplayedMnemonicIndex(10); + panel1.add(myShowTreeNodesCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myExtensionLabel = new JLabel(); + myExtensionLabel.setText("Extension:"); + myExtensionLabel.setDisplayedMnemonic('X'); + myExtensionLabel.setDisplayedMnemonicIndex(1); + panel2.add(myExtensionLabel, BorderLayout.WEST); + myExtensionComboBox = new JComboBox(); + panel2.add(myExtensionComboBox, BorderLayout.CENTER); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new BorderLayout(0, 0)); + panel1.add(panel3, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myDialectLabel = new JBLabel(); + myDialectLabel.setText("Dialect:"); + myDialectLabel.setDisplayedMnemonic('D'); + myDialectLabel.setDisplayedMnemonicIndex(0); + panel3.add(myDialectLabel, BorderLayout.WEST); + myDialectComboBox = new JComboBox(); + panel3.add(myDialectComboBox, BorderLayout.CENTER); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new BorderLayout(0, 0)); + panel1.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + label1.setIconTextGap(0); + label1.setText("Show PSI structure for:"); + label1.setDisplayedMnemonic('P'); + label1.setDisplayedMnemonicIndex(5); + panel4.add(label1, BorderLayout.WEST); + myFileTypeComboBox = new ComboBox(); + myFileTypeComboBox.setMaximumRowCount(30); + panel4.add(myFileTypeComboBox, BorderLayout.CENTER); + myShowEmptyPropertiesCheckBox = new JCheckBox(); + myShowEmptyPropertiesCheckBox.setEnabled(true); + myShowEmptyPropertiesCheckBox.setMargin(new Insets(0, 0, 0, 0)); + myShowEmptyPropertiesCheckBox.setSelected(false); + myShowEmptyPropertiesCheckBox.setText("Show empty properties"); + panel1.add(myShowEmptyPropertiesCheckBox, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myUpdatePsiTreeCheckbox = new JBCheckBox(); + myUpdatePsiTreeCheckbox.setText("Update PSI tree on file changes"); + panel1.add(myUpdatePsiTreeCheckbox, + new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTextSeparator = new TitledSeparator(); + myTextSeparator.setText("&Text"); + myTextSeparator.setToolTipText("Type or paste source code which you want to explore, then click Build PSI Tree"); + myPanel.add(myTextSeparator, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myTextSplit = new JSplitPane(); + myTextSplit.setDividerLocation(134); + myTextSplit.setDividerSize(4); + myTextSplit.setOrientation(0); + panel5.add(myTextSplit, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(200, 200), null, 0, false)); + myTextSplit.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myTextPanel = new JPanel(); + myTextPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTextSplit.setLeftComponent(myTextPanel); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTextSplit.setRightComponent(panel6); + myTreeSplit = new JSplitPane(); + myTreeSplit.setDividerLocation(98); + myTreeSplit.setDividerSize(4); + panel6.add(myTreeSplit, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(200, 200), null, 0, false)); + myTreeSplit.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myExtensionLabel.setLabelFor(myExtensionComboBox); + myDialectLabel.setLabelFor(myDialectComboBox); + label1.setLabelFor(myFileTypeComboBox); + } myPsiTreePanel = new JPanel(new BorderLayout()); myPsiTreeSeparator = new TitledSeparator(DevPsiViewerBundle.message("separator.psi.tree")); myPsiTree = new Tree(); @@ -263,10 +395,11 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { myPsiUpdateAlarm = new SingleAlarm(this::doUpdatePsi, 1500, getDisposable()); myCoroutineScope = CoroutineScopeKt.CoroutineScope(ModalityKt.asContextElement(ModalityState.nonModal())); - myPsiViewerPropertiesTabViewModel = new PsiViewerPropertiesTabViewModel(myProject, myCoroutineScope, myOriginalPsiFile, PsiViewerSettings.getSettings(), (psiElement) -> { - focusTree(); - selectElement(psiElement); - }); + myPsiViewerPropertiesTabViewModel = + new PsiViewerPropertiesTabViewModel(myProject, myCoroutineScope, myOriginalPsiFile, PsiViewerSettings.getSettings(), (psiElement) -> { + focusTree(); + selectElement(psiElement); + }); myTreeStructure = new ViewerTreeStructure(myProject); myStructureTreeModel = new StructureTreeModel<>(myTreeStructure, IndexComparator.getInstance(), getDisposable()); @@ -312,8 +445,8 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { setCancelButtonText(DevPsiViewerBundle.message("button.close")); Disposer.register(myProject, getDisposable()); VirtualFile selectedFile = selectedEditor == null ? null : FileDocumentManager.getInstance().getFile(selectedEditor.getDocument()); - setTitle(selectedFile == null ? - DevPsiViewerBundle.message("dialog.title.psi.viewer") : + setTitle(selectedFile == null ? + DevPsiViewerBundle.message("dialog.title.psi.viewer") : DevPsiViewerBundle.message("dialog.title.psi.viewer.with.file", selectedFile.getName())); if (selectedEditor != null) { myEditor = (EditorEx)EditorFactory.getInstance().createEditor(selectedEditor.getDocument(), myProject); @@ -342,6 +475,9 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { } } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private static @Nullable PsiFile getOriginalPsiFile(@NotNull Project project, @Nullable Editor selectedEditor) { return selectedEditor != null ? PsiDocumentManager.getInstance(project).getPsiFile(selectedEditor.getDocument()) : null; } @@ -409,7 +545,8 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { settings.lastSelectedTabIndex = myTabs.getIndexOf(tab); if (tab == propertiesTabInfo) { myPsiViewerPropertiesTabViewModel.openTab(); - } else { + } + else { myPsiViewerPropertiesTabViewModel.closeTab(); } return el.run(); @@ -862,8 +999,8 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { if (!(node.getUserObject() instanceof ViewerNodeDescriptor descriptor)) return; Object elementObject = descriptor.getElement(); PsiElement element = elementObject instanceof PsiElement - ? (PsiElement)elementObject - : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null; + ? (PsiElement)elementObject + : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null; if (element != null) { TextRange rangeInHostFile = ReadAction.compute( () -> InjectedLanguageManager.getInstance(myProject).injectedToHost(element, element.getTextRange()) @@ -1050,22 +1187,22 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { } @Override - public void keyTyped(@NotNull KeyEvent e) {} + public void keyTyped(@NotNull KeyEvent e) { } @Override - public void keyReleased(KeyEvent e) {} + public void keyReleased(KeyEvent e) { } @Override - public void mousePressed(@NotNull MouseEvent e) {} + public void mousePressed(@NotNull MouseEvent e) { } @Override - public void mouseReleased(@NotNull MouseEvent e) {} + public void mouseReleased(@NotNull MouseEvent e) { } @Override - public void mouseEntered(@NotNull MouseEvent e) {} + public void mouseEntered(@NotNull MouseEvent e) { } @Override - public void mouseExited(@NotNull MouseEvent e) {} + public void mouseExited(@NotNull MouseEvent e) { } } private void updateEditor() { @@ -1099,7 +1236,8 @@ public class PsiViewerDialog extends DialogWrapper implements UiDataProvider { ReadAction .nonBlocking(() -> getElementToChooseInPsiTree(element)) .finishOnUiThread(ModalityState.nonModal(), elementToChoose -> { - myStructureTreeModel.select(elementToChoose, myPsiTree, path -> {}); + myStructureTreeModel.select(elementToChoose, myPsiTree, path -> { + }); }) .expireWith(getDisposable()) .submit(AppExecutorUtil.getAppExecutorService()); diff --git a/plugins/devkit/devkit-core/src/actions/obsolete/NewActionDialog.java b/plugins/devkit/devkit-core/src/actions/obsolete/NewActionDialog.java index 6d3fe5cb8b83..8180fe89181b 100644 --- a/plugins/devkit/devkit-core/src/actions/obsolete/NewActionDialog.java +++ b/plugins/devkit/devkit-core/src/actions/obsolete/NewActionDialog.java @@ -17,8 +17,14 @@ import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiNameHelper; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.ColoredListCellRenderer; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.ListSpeedSearch; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ExceptionUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -33,16 +39,20 @@ import org.jetbrains.idea.devkit.dom.index.IdeaPluginRegistrationIndex; import org.jetbrains.idea.devkit.util.ActionData; import org.jetbrains.idea.devkit.util.ActionType; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.ButtonModel; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; @@ -50,37 +60,40 @@ import javax.swing.event.ListSelectionListener; import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; @ApiStatus.Obsolete public class NewActionDialog extends DialogWrapper implements ActionData { - private JPanel myRootPanel; - private JList myGroupList; - private JList myActionList; - private JTextField myActionClassNameEdit; - private JTextField myActionIdEdit; - private JTextField myActionNameEdit; - private JTextField myActionDescriptionEdit; - private JRadioButton myAnchorFirstRadio; - private JRadioButton myAnchorLastRadio; - private JRadioButton myAnchorBeforeRadio; - private JRadioButton myAnchorAfterRadio; - private JPanel myShortcutPanel; - private JPanel myFirstKeystrokeEditPlaceholder; - private JPanel mySecondKeystrokeEditPlaceholder; - private JButton myClearFirstKeystroke; - private JButton myClearSecondKeystroke; + private final JPanel myRootPanel; + private final JList myGroupList; + private final JList myActionList; + private final JTextField myActionClassNameEdit; + private final JTextField myActionIdEdit; + private final JTextField myActionNameEdit; + private final JTextField myActionDescriptionEdit; + private final JRadioButton myAnchorFirstRadio; + private final JRadioButton myAnchorLastRadio; + private final JRadioButton myAnchorBeforeRadio; + private final JRadioButton myAnchorAfterRadio; + private final JPanel myShortcutPanel; + private final JPanel myFirstKeystrokeEditPlaceholder; + private final JPanel mySecondKeystrokeEditPlaceholder; + private final JButton myClearFirstKeystroke; + private final JButton myClearSecondKeystroke; private final ShortcutTextField myFirstKeystrokeEdit; private final ShortcutTextField mySecondKeystrokeEdit; private final Project myProject; private final PsiDirectory myDirectory; - private ButtonGroup myAnchorButtonGroup; + private final ButtonGroup myAnchorButtonGroup; public NewActionDialog(@NotNull PsiClass actionClass) { @@ -98,6 +111,190 @@ public class NewActionDialog extends DialogWrapper implements ActionData { super(project, false); myProject = project; myDirectory = directory; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myRootPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", + "new.action.add.to.group"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myGroupList = new JBList(); + myGroupList.setSelectionMode(0); + jBScrollPane1.setViewportView(myGroupList); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.actions")); + panel1.add(label1, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + panel1.add(jBScrollPane2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myActionList = new JBList(); + myActionList.setSelectionMode(0); + jBScrollPane2.setViewportView(myActionList); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", ""); + panel1.add(panel2, new GridConstraints(0, 2, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.anchor"), + TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + myAnchorFirstRadio = new JRadioButton(); + this.$$$loadButtonText$$$(myAnchorFirstRadio, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.anchor.first")); + panel2.add(myAnchorFirstRadio, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnchorLastRadio = new JRadioButton(); + this.$$$loadButtonText$$$(myAnchorLastRadio, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.anchor.")); + panel2.add(myAnchorLastRadio, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnchorBeforeRadio = new JRadioButton(); + this.$$$loadButtonText$$$(myAnchorBeforeRadio, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.anchor.before")); + panel2.add(myAnchorBeforeRadio, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnchorAfterRadio = new JRadioButton(); + this.$$$loadButtonText$$$(myAnchorAfterRadio, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.anchor.after")); + panel2.add(myAnchorAfterRadio, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.group.groups")); + panel1.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myActionClassNameEdit = new JTextField(); + panel3.add(myActionClassNameEdit, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.id")); + panel3.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myActionNameEdit = new JTextField(); + panel3.add(myActionNameEdit, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myActionDescriptionEdit = new JTextField(); + panel3.add(myActionDescriptionEdit, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.description")); + panel3.add(label4, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.class.name")); + panel3.add(label5, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.text")); + panel3.add(label6, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myActionIdEdit = new JTextField(); + panel3.add(myActionIdEdit, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myShortcutPanel = new JPanel(); + myShortcutPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myShortcutPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(myShortcutPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myShortcutPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/DevKitBundle", "new.action.keyboard.shortcuts"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.first")); + myShortcutPanel.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label8 = new JLabel(); + this.$$$loadLabelText$$$(label8, this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.second")); + myShortcutPanel.add(label8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myFirstKeystrokeEditPlaceholder = new JPanel(); + myFirstKeystrokeEditPlaceholder.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myShortcutPanel.add(myFirstKeystrokeEditPlaceholder, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + mySecondKeystrokeEditPlaceholder = new JPanel(); + mySecondKeystrokeEditPlaceholder.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myShortcutPanel.add(mySecondKeystrokeEditPlaceholder, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myClearFirstKeystroke = new JButton(); + this.$$$loadButtonText$$$(myClearFirstKeystroke, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.clear")); + myClearFirstKeystroke.setToolTipText(this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.clear.tooltip")); + myShortcutPanel.add(myClearFirstKeystroke, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(20, 20), new Dimension(20, 20), new Dimension(20, 20), 0, + false)); + myClearSecondKeystroke = new JButton(); + this.$$$loadButtonText$$$(myClearSecondKeystroke, + this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.clear")); + myClearSecondKeystroke.setToolTipText(this.$$$getMessageFromBundle$$$("messages/DevKitBundle", "new.action.keyboard.clear.tooltip")); + myShortcutPanel.add(myClearSecondKeystroke, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(20, 20), new Dimension(20, 20), new Dimension(20, 20), + 0, false)); + label1.setLabelFor(jBScrollPane2); + label2.setLabelFor(jBScrollPane1); + label3.setLabelFor(myActionIdEdit); + label4.setLabelFor(myActionDescriptionEdit); + label5.setLabelFor(myActionClassNameEdit); + label6.setLabelFor(myActionNameEdit); + myAnchorButtonGroup = new ButtonGroup(); + myAnchorButtonGroup.add(myAnchorFirstRadio); + myAnchorButtonGroup.add(myAnchorLastRadio); + myAnchorButtonGroup.add(myAnchorBeforeRadio); + myAnchorButtonGroup.add(myAnchorAfterRadio); + } init(); setTitle(DevKitBundle.message("new.action.dialog.title")); ActionManager actionManager = ActionManager.getInstance(); @@ -130,7 +327,7 @@ public class NewActionDialog extends DialogWrapper implements ActionData { AnAction[] actions = group.getChildren(actionManager); // filter out actions that don't have IDs - they can't be used for anchoring in plugin.xml List realActions = new ArrayList<>(); - for(AnAction action: actions) { + for (AnAction action : actions) { if (actionManager.getId(action) != null) { realActions.add(action); } @@ -192,6 +389,78 @@ public class NewActionDialog extends DialogWrapper implements ActionData { updateControls(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override protected JComponent createCenterPanel() { @@ -298,7 +567,8 @@ public class NewActionDialog extends DialogWrapper implements ActionData { if (myDirectory != null) { try { DevkitActionsUtil.checkCanCreateClass(myDirectory, myActionClassNameEdit.getText()); - } catch (IncorrectOperationException e) { + } + catch (IncorrectOperationException e) { String exceptionMessage = ExceptionUtil.getMessage(e); return exceptionMessage != null ? exceptionMessage : DevKitBundle.message("new.action.cannot.create.class"); } @@ -378,8 +648,7 @@ public class NewActionDialog extends DialogWrapper implements ActionData { keyCode != KeyEvent.VK_ALT && keyCode != KeyEvent.VK_CONTROL && keyCode != KeyEvent.VK_ALT_GRAPH && - keyCode != KeyEvent.VK_META) - { + keyCode != KeyEvent.VK_META) { setKeyStroke(KeyStroke.getKeyStroke(keyCode, e.getModifiers())); } } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsDialog.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsDialog.java index 69371d08d805..87d4f5bd1295 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsDialog.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsDialog.java @@ -7,29 +7,98 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.eclipse.EclipseBundle; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; public class ExportEclipseProjectsDialog extends DialogWrapper { - private JPanel contentPane; - private ElementsChooser moduleChooser; - private JCheckBox linkCheckBox; - private TextFieldWithBrowseButton myUserLibrariesTF; - private JCheckBox myExportProjectLibrariesCb; - private JLabel myPathToUserLibsLabel; + private final JPanel contentPane; + private final ElementsChooser moduleChooser; + private final JCheckBox linkCheckBox; + private final TextFieldWithBrowseButton myUserLibrariesTF; + private final JCheckBox myExportProjectLibrariesCb; + private final JLabel myPathToUserLibsLabel; public ExportEclipseProjectsDialog(final Project project, List modules) { super(project, false); + { + moduleChooser = new ElementsChooser<>(true) { + @Override + protected String getItemText(final @NotNull java.lang.Module module) { + return module.getName(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 2, new Insets(4, 4, 4, 4), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "border.title.modules.to.export"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, + this.$$$getFont$$$(null, -1, -1, panel1.getFont()), + null)); + panel1.add(moduleChooser, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + linkCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(linkCheckBox, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "checkbox.switch.selected.modules.to.eclipse.compatible.format")); + contentPane.add(linkCheckBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPathToUserLibsLabel = new JLabel(); + this.$$$loadLabelText$$$(myPathToUserLibsLabel, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "label.path.to.resulting.userlibraries")); + contentPane.add(myPathToUserLibsLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 2, false)); + myUserLibrariesTF = new TextFieldWithBrowseButton(); + contentPane.add(myUserLibrariesTF, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myExportProjectLibrariesCb = new JCheckBox(); + this.$$$loadButtonText$$$(myExportProjectLibrariesCb, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "checkbox.export.non.module.libraries")); + contentPane.add(myExportProjectLibrariesCb, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myPathToUserLibsLabel.setLabelFor(myUserLibrariesTF); + } moduleChooser.setElements(modules, true); setTitle(EclipseBundle.message("eclipse.export.dialog.title")); init(); @@ -47,20 +116,107 @@ public class ExportEclipseProjectsDialog extends DialogWrapper { }); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + @Override protected @Nullable JComponent createCenterPanel() { return contentPane; } - private void createUIComponents() { - moduleChooser = new ElementsChooser<>(true) { - @Override - protected String getItemText(final @NotNull Module module) { - return module.getName(); - } - }; - } - public boolean isLink() { return linkCheckBox.isSelected(); } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseCodeStyleImportStep.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseCodeStyleImportStep.java index 3d54f458d7de..91614c5da30e 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseCodeStyleImportStep.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseCodeStyleImportStep.java @@ -9,6 +9,10 @@ import com.intellij.ui.JBColor; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBRadioButton; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -16,6 +20,8 @@ import org.jetbrains.idea.eclipse.EclipseBundle; import org.jetbrains.idea.eclipse.EclipseProjectFinder; import org.jetbrains.idea.eclipse.importer.EclipseProjectCodeStyleData; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; @@ -23,27 +29,109 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; public class EclipseCodeStyleImportStep extends ProjectImportWizardStep { - private JPanel myTopPanel; - private JBList myCodeStylesList; - private JBRadioButton myUseDefaultCodeStyleRB; - private JBRadioButton myImportCodeStyleRB; - private JPanel myTitlePanel; - private JLabel myImportCodeStyleLabel; - private JBLabel myUseDefaultHint; - private JBLabel myImportHint; - private JCheckBox myOrganizeImportsCheckBox; + private final JPanel myTopPanel; + private final JBList myCodeStylesList; + private final JBRadioButton myUseDefaultCodeStyleRB; + private final JBRadioButton myImportCodeStyleRB; + private final JPanel myTitlePanel; + private final JLabel myImportCodeStyleLabel; + private final JBLabel myUseDefaultHint; + private final JBLabel myImportHint; + private final JCheckBox myOrganizeImportsCheckBox; private final DefaultListModel myCodeStylesListModel; public EclipseCodeStyleImportStep(WizardContext context) { super(context); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTitlePanel = new JPanel(); + myTitlePanel.setLayout(new GridLayoutManager(8, 3, new Insets(0, 0, 0, 0), -1, -1)); + myTitlePanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myTopPanel.add(myTitlePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myTitlePanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEmptyBorder(), + this.$$$getMessageFromBundle$$$( + "messages/EclipseBundle", + "border.title.choose.project.code.style"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myUseDefaultCodeStyleRB = new JBRadioButton(); + myTitlePanel.add(myUseDefaultCodeStyleRB, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "eclipse.import.code.style.default.option")); + myTitlePanel.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myImportCodeStyleRB = new JBRadioButton(); + myTitlePanel.add(myImportCodeStyleRB, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myImportCodeStyleLabel = new JLabel(); + this.$$$loadLabelText$$$(myImportCodeStyleLabel, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "eclipse.import.code.style.import.option")); + myTitlePanel.add(myImportCodeStyleLabel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myTitlePanel.add(spacer1, new GridConstraints(7, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myTitlePanel.add(jBScrollPane1, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCodeStylesList = new JBList(); + final DefaultListModel defaultListModel1 = new DefaultListModel(); + myCodeStylesList.setModel(defaultListModel1); + jBScrollPane1.setViewportView(myCodeStylesList); + myUseDefaultHint = new JBLabel(); + myUseDefaultHint.setText(""); + myTitlePanel.add(myUseDefaultHint, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + myTitlePanel.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myImportHint = new JBLabel(); + myImportHint.setText(""); + myTitlePanel.add(myImportHint, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer3 = new Spacer(); + myTitlePanel.add(spacer3, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 5), new Dimension(-1, 5), 0, + false)); + myOrganizeImportsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myOrganizeImportsCheckBox, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "eclipse.import.code.style.organize.imports.box")); + myTitlePanel.add(myOrganizeImportsCheckBox, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } myCodeStylesListModel = new DefaultListModel<>(); myCodeStylesList.setModel(myCodeStylesListModel); ButtonGroup group = new ButtonGroup(); @@ -83,6 +171,78 @@ public class EclipseCodeStyleImportStep extends ProjectImportWizardStep { customizeHintLabel(myImportHint); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private static void customizeHintLabel(@NotNull JBLabel hintLabel) { hintLabel.setForeground(JBColor.GRAY); hintLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); @@ -117,7 +277,7 @@ public class EclipseCodeStyleImportStep extends ProjectImportWizardStep { @Override public void updateStep() { myCodeStylesListModel.clear(); - for(EclipseProjectCodeStyleData codeStyleData : getCodeStylesList()) { + for (EclipseProjectCodeStyleData codeStyleData : getCodeStylesList()) { myCodeStylesListModel.addElement(codeStyleData); } boolean isEnabled = !myCodeStylesListModel.isEmpty(); @@ -156,5 +316,4 @@ public class EclipseCodeStyleImportStep extends ProjectImportWizardStep { } return codeStyleDataList; } - } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java index 1e1238289a65..a1f425f43e0c 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java @@ -10,36 +10,136 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.projectImport.ProjectFormatPanel; import com.intellij.projectImport.ProjectImportWizardStep; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.idea.eclipse.EclipseBundle; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { private static final String _ECLIPSE_PROJECT_DIR = "eclipse.project.dir"; - private JPanel myPanel; - private JCheckBox myLinkCheckBox; - private JRadioButton rbModulesColocated; - private JRadioButton rbModulesDedicated; - private JTextField myTestSourcesMask; - private TextFieldWithBrowseButton myDirComponent; - private TextFieldWithBrowseButton myWorkspaceRootComponent; + private final JPanel myPanel; + private final JCheckBox myLinkCheckBox; + private final JRadioButton rbModulesColocated; + private final JRadioButton rbModulesDedicated; + private final JTextField myTestSourcesMask; + private final TextFieldWithBrowseButton myDirComponent; + private final TextFieldWithBrowseButton myWorkspaceRootComponent; private ProjectFormatPanel myProjectFormatPanel; - private JPanel myFormatPanel; + private final JPanel myFormatPanel; private EclipseImportBuilder.Parameters myParameters; public EclipseWorkspaceRootStep(final WizardContext context) { super(context); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 1, new Insets(4, 4, 4, 4), -1, -1)); + myLinkCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myLinkCheckBox, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "checkbox.link.created.intellij.idea.modules.to.eclipse.project.files")); + myPanel.add(myLinkCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "border.title.intellij.idea.project.and.module.files.location"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + rbModulesColocated = new JRadioButton(); + this.$$$loadButtonText$$$(rbModulesColocated, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "radio.button.create.module.files.near.classpath.files")); + panel1.add(rbModulesColocated, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + rbModulesDedicated = new JRadioButton(); + this.$$$loadButtonText$$$(rbModulesDedicated, + this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "radio.button.keep.project.and.module.files.in")); + panel1.add(rbModulesDedicated, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDirComponent = new TextFieldWithBrowseButton(); + panel1.add(myDirComponent, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myFormatPanel = new JPanel(); + myFormatPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myFormatPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myWorkspaceRootComponent = new TextFieldWithBrowseButton(); + myPanel.add(myWorkspaceRootComponent, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + Font label1Font = this.$$$getFont$$$(null, Font.BOLD, -1, label1.getFont()); + if (label1Font != null) label1.setFont(label1Font); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", "eclipse.import.label.select.workspace")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(4, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/EclipseBundle", + "label.detect.test.sources.comma.separated.path.masks.and.wildcards.allowed")); + panel2.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestSourcesMask = new JTextField(); + panel2.add(myTestSourcesMask, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + label2.setLabelFor(myTestSourcesMask); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(rbModulesColocated); + buttonGroup.add(rbModulesDedicated); + } myWorkspaceRootComponent.addBrowseFolderListener(null, FileChooserDescriptorFactory.createSingleFolderDescriptor() .withTitle(EclipseBundle.message("eclipse.import.title.select.workspace"))); @@ -53,7 +153,8 @@ public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { myDirComponent.setEnabled(dedicated); if (dedicated && myDirComponent.getText().isEmpty()) { final String remoteStorage = Options.getProjectStorageDir(context.getProject()); - myDirComponent.setText(remoteStorage != null ? remoteStorage : FileUtil.toSystemDependentName(myWorkspaceRootComponent.getText())); + myDirComponent.setText( + remoteStorage != null ? remoteStorage : FileUtil.toSystemDependentName(myWorkspaceRootComponent.getText())); } } }; @@ -67,6 +168,102 @@ public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { } } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent getComponent() { return myPanel; @@ -118,7 +315,8 @@ public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { myWorkspaceRootComponent.getTextField().selectAll(); final String storageDir = Options.getProjectStorageDir(getWizardContext().getProject()); - final boolean colocated = StringUtil.isEmptyOrSpaces(getParameters().converterOptions.commonModulesDirectory) && StringUtil.isEmptyOrSpaces(storageDir); + final boolean colocated = + StringUtil.isEmptyOrSpaces(getParameters().converterOptions.commonModulesDirectory) && StringUtil.isEmptyOrSpaces(storageDir); rbModulesColocated.setSelected(colocated); rbModulesDedicated.setSelected(!colocated); myDirComponent.setEnabled(!colocated); @@ -136,16 +334,16 @@ public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { private static String wildcardToRegexp(String string) { return string == null ? null : string.replaceAll("\\.", "\\.") // "." -> "\." - .replaceAll("\\*", ".*") // "*" -> ".*" - .replaceAll("\\?", ".") // "?" -> "." - .replaceAll(",\\s*", "|"); // "," possible followed by whitespace -> "|" + .replaceAll("\\*", ".*") // "*" -> ".*" + .replaceAll("\\?", ".") // "?" -> "." + .replaceAll(",\\s*", "|"); // "," possible followed by whitespace -> "|" } private static String regexpToWildcard(String string) { return string == null ? null : string.replaceAll("\\.\\*", "*") // ".*" -> "*" - .replaceAll("\\.", "?") // "." -> "?" - .replaceAll("\\\\\\?", ".") // "\?" -> "." - .replaceAll("\\|", ", "); // "|" -> ","; + .replaceAll("\\.", "?") // "." -> "?" + .replaceAll("\\\\\\?", ".") // "\?" -> "." + .replaceAll("\\|", ", "); // "|" -> ","; } @Override diff --git a/plugins/editorconfig/backend/src/configmanagement/create/CreateEditorConfigForm.java b/plugins/editorconfig/backend/src/configmanagement/create/CreateEditorConfigForm.java index 4665091b286b..ec4fb2b95cca 100644 --- a/plugins/editorconfig/backend/src/configmanagement/create/CreateEditorConfigForm.java +++ b/plugins/editorconfig/backend/src/configmanagement/create/CreateEditorConfigForm.java @@ -14,46 +14,160 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.BrowserLink; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.JBDimension; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.border.TitledBorder; import java.awt.Component; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; import java.util.stream.Collectors; public class CreateEditorConfigForm { - private JPanel myTopPanel; - private JBCheckBox myStandardPropertiesCb; - private JBCheckBox myIntelliJPropertiesCb; - private JBCheckBox myRootCb; - private JPanel myPropertiesPanel; - private JPanel myLanguagesPanel; - private JBCheckBox myCommentProperties; - private JBLabel myAddPropertiesForLabel; + private final JPanel myTopPanel; + private final JBCheckBox myStandardPropertiesCb; + private final JBCheckBox myIntelliJPropertiesCb; + private final JBCheckBox myRootCb; + private final JPanel myPropertiesPanel; + private final JPanel myLanguagesPanel; + private final JBCheckBox myCommentProperties; + private final JBLabel myAddPropertiesForLabel; @SuppressWarnings("unused") - private BrowserLink myAboutEditorConfigLink; + private final BrowserLink myAboutEditorConfigLink; @SuppressWarnings("unused") - private ContextHelpLabel myContextHelpLabel; - private JBLabel myIntelliJPropertiesLabel; + private final ContextHelpLabel myContextHelpLabel; + private final JBLabel myIntelliJPropertiesLabel; private final List myLanguageCheckBoxes; - private final Project myProject; + private final Project myProject; private static final int MAX_LANGUAGES_ROWS = 10; public CreateEditorConfigForm(@NotNull Project project) { myProject = project; + { + myAboutEditorConfigLink = + new BrowserLink( + EditorConfigBundle.message("export.editor.config.about"), + "http://editorconfig.org"); + myAboutEditorConfigLink.setIconTextGap(0); + myAboutEditorConfigLink.setHorizontalTextPosition(SwingConstants.LEFT); + myContextHelpLabel = ContextHelpLabel.create("", EditorConfigBundle.message("export.editor.config.root.help")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myTopPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myTopPanel.add(myPropertiesPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myPropertiesPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/EditorConfigBundle", "export.properties.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + myStandardPropertiesCb = new JBCheckBox(); + myStandardPropertiesCb.setText(""); + myPropertiesPanel.add(myStandardPropertiesCb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPropertiesPanel.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myIntelliJPropertiesCb = new JBCheckBox(); + myIntelliJPropertiesCb.setText(""); + myPropertiesPanel.add(myIntelliJPropertiesCb, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myLanguagesPanel = new JPanel(); + myLanguagesPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPropertiesPanel.add(myLanguagesPanel, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.properties.standard")); + myPropertiesPanel.add(jBLabel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myCommentProperties = new JBCheckBox(); + myCommentProperties.setSelected(false); + this.$$$loadButtonText$$$(myCommentProperties, + this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.comment.out.properties")); + myPropertiesPanel.add(myCommentProperties, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myAddPropertiesForLabel = new JBLabel(); + myAddPropertiesForLabel.setHorizontalAlignment(2); + myAddPropertiesForLabel.setHorizontalTextPosition(2); + this.$$$loadLabelText$$$(myAddPropertiesForLabel, + this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.languages.title")); + myAddPropertiesForLabel.setVerticalAlignment(1); + myAddPropertiesForLabel.setVerticalTextPosition(1); + myPropertiesPanel.add(myAddPropertiesForLabel, + new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myIntelliJPropertiesLabel = new JBLabel(); + this.$$$loadLabelText$$$(myIntelliJPropertiesLabel, + this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.properties.intellij")); + myPropertiesPanel.add(myIntelliJPropertiesLabel, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + this.$$$loadButtonText$$$(myAboutEditorConfigLink, + this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.editor.config.about")); + myTopPanel.add(myAboutEditorConfigLink, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRootCb = new JBCheckBox(); + myRootCb.setSelected(true); + this.$$$loadButtonText$$$(myRootCb, this.$$$getMessageFromBundle$$$("messages/EditorConfigBundle", "export.topmost.file")); + panel1.add(myRootCb, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel1.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + panel1.add(myContextHelpLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myPropertiesPanel.setBorder(IdeBorderFactory.createTitledBorder(EditorConfigBundle.message("export.properties.title"))); myLanguagesPanel.setLayout(new BoxLayout(myLanguagesPanel, BoxLayout.X_AXIS)); myLanguageCheckBoxes = creteLanguageCheckBoxes(myLanguagesPanel); @@ -67,6 +181,78 @@ public class CreateEditorConfigForm { EditorConfigBundle.message("export.properties.intellij", ApplicationNamesInfo.getInstance().getFullProductName())); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private static void adjustVerticalSize(JComponent component, float factor) { final Dimension originalDim = component.getMinimumSize(); final Dimension newDim = new Dimension(originalDim.width, Math.round(originalDim.height * factor)); @@ -99,7 +285,7 @@ public class CreateEditorConfigForm { final JBCheckBox checkBox = new JBCheckBox(langName); checkBoxes.add(new LanguageCheckBoxRec(language, checkBox)); currPanel.add(checkBox); - rowCount ++; + rowCount++; if (rowCount >= MAX_LANGUAGES_ROWS) { currPanel = null; } @@ -135,16 +321,6 @@ public class CreateEditorConfigForm { return colPanel; } - private void createUIComponents() { - myAboutEditorConfigLink = - new BrowserLink( - EditorConfigBundle.message("export.editor.config.about"), - "http://editorconfig.org"); - myAboutEditorConfigLink.setIconTextGap(0); - myAboutEditorConfigLink.setHorizontalTextPosition(SwingConstants.LEFT); - myContextHelpLabel = ContextHelpLabel.create("", EditorConfigBundle.message("export.editor.config.root.help")); - } - public JPanel getTopPanel() { return myTopPanel; } @@ -172,7 +348,7 @@ public class CreateEditorConfigForm { } private static final class LanguageCheckBoxRec { - private final Language myLanguage; + private final Language myLanguage; private final JCheckBox myCheckBox; private LanguageCheckBoxRec(Language language, JCheckBox checkBox) { diff --git a/plugins/git4idea/src/git4idea/ui/GitResetDialog.java b/plugins/git4idea/src/git4idea/ui/GitResetDialog.java index 8a7d970eca1c..619647096381 100644 --- a/plugins/git4idea/src/git4idea/ui/GitResetDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitResetDialog.java @@ -5,6 +5,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import git4idea.commands.GitCommand; import git4idea.commands.GitLineHandler; import git4idea.i18n.GitBundle; @@ -13,13 +16,18 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.PropertyKey; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; /** * The dialog for the "git reset" operation @@ -28,27 +36,27 @@ public class GitResetDialog extends DialogWrapper { /** * Git root selector */ - private JComboBox myGitRootComboBox; + private final JComboBox myGitRootComboBox; /** * The label for the current branch */ - private JLabel myCurrentBranchLabel; + private final JLabel myCurrentBranchLabel; /** * The selector for reset type */ - private ComboBox myResetTypeComboBox; + private final ComboBox myResetTypeComboBox; /** * The text field that contains commit expressions */ - private JTextField myCommitTextField; + private final JTextField myCommitTextField; /** * The validate button */ - private JButton myValidateButton; + private final JButton myValidateButton; /** * The root panel for the dialog */ - private JPanel myPanel; + private final JPanel myPanel; /** * The project @@ -69,6 +77,81 @@ public class GitResetDialog extends DialogWrapper { public GitResetDialog(final Project project, final List roots, final VirtualFile defaultRoot) { super(project, true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch")); + myPanel.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCurrentBranchLabel = new JLabel(); + myCurrentBranchLabel.setText(""); + myCurrentBranchLabel.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch.tooltip")); + myPanel.add(myCurrentBranchLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/GitBundle", "reset.type")); + myPanel.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGitRootComboBox = new JComboBox(); + myGitRootComboBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root.tooltip")); + myPanel.add(myGitRootComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myResetTypeComboBox = new ComboBox(); + myResetTypeComboBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "reset.type.tooltip")); + panel1.add(myResetTypeComboBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/GitBundle", "reset.commit.label")); + myPanel.add(label4, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myCommitTextField = new JTextField(); + myCommitTextField.setText("HEAD"); //NON-NLS + myCommitTextField.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "reset.commit.tooltip")); + panel2.add(myCommitTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myValidateButton = new JButton(); + this.$$$loadButtonText$$$(myValidateButton, this.$$$getMessageFromBundle$$$("messages/GitBundle", "reset.validate")); + panel2.add(myValidateButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myGitRootComboBox); + label3.setLabelFor(myResetTypeComboBox); + label4.setLabelFor(myCommitTextField); + } setTitle(GitBundle.message("reset.title")); setOKButtonText(GitBundle.message("git.reset.button")); myResetTypeComboBox.addItem(ResetMode.MIXED); @@ -81,6 +164,78 @@ public class GitResetDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @Nullable JComponent getPreferredFocusedComponent() { return myCommitTextField; diff --git a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java index 2b49359823c3..08e1c8304e83 100644 --- a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java @@ -13,6 +13,9 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.platform.eel.provider.utils.EelPathUtils; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import git4idea.GitUtil; import git4idea.branch.GitBranchUtil; import git4idea.commands.Git; @@ -26,6 +29,7 @@ import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -35,15 +39,19 @@ import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; +import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import static git4idea.GitNotificationIdsHolder.TAG_CREATED; @@ -53,14 +61,14 @@ public class GitTagDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance(GitTagDialog.class); - private JPanel myPanel; - private JComboBox myGitRootComboBox; - private JLabel myCurrentBranch; - private JTextField myTagNameTextField; - private JCheckBox myForceCheckBox; - private JTextArea myMessageTextArea; - private JTextField myCommitTextField; - private JButton myValidateButton; + private final JPanel myPanel; + private final JComboBox myGitRootComboBox; + private final JLabel myCurrentBranch; + private final JTextField myTagNameTextField; + private final JCheckBox myForceCheckBox; + private final JTextArea myMessageTextArea; + private final JTextField myCommitTextField; + private final JButton myValidateButton; private final GitReferenceValidator myCommitTextFieldValidator; private final Project myProject; private final @NotNull Git myGit; @@ -73,6 +81,92 @@ public class GitTagDialog extends DialogWrapper { public GitTagDialog(Project project, List roots, VirtualFile defaultRoot) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGitRootComboBox = new JComboBox(); + myGitRootComboBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root.tooltip")); + myPanel.add(myGitRootComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch")); + myPanel.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCurrentBranch = new JLabel(); + myCurrentBranch.setText(""); + myCurrentBranch.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch.tooltip")); + myPanel.add(myCurrentBranch, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.name.label")); + myPanel.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTagNameTextField = new JTextField(); + myTagNameTextField.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.name.tooltip")); + myPanel.add(myTagNameTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.message.label")); + label4.setVerticalAlignment(0); + myPanel.add(label4, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myMessageTextArea = new JTextArea(); + myMessageTextArea.setRows(4); + myMessageTextArea.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.message.tooltip")); + jBScrollPane1.setViewportView(myMessageTextArea); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.commit.label")); + myPanel.add(label5, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myForceCheckBox = new JCheckBox(); + myForceCheckBox.setEnabled(false); + this.$$$loadButtonText$$$(myForceCheckBox, this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.force")); + myForceCheckBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.force.tooltip")); + myPanel.add(myForceCheckBox, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myCommitTextField = new JTextField(); + myCommitTextField.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.commit.tooltip")); + panel1.add(myCommitTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myValidateButton = new JButton(); + this.$$$loadButtonText$$$(myValidateButton, this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.validate")); + myValidateButton.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "tag.validate.tooltip")); + panel1.add(myValidateButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myGitRootComboBox); + label3.setLabelFor(myTagNameTextField); + label4.setLabelFor(myMessageTextArea); + label5.setLabelFor(myCommitTextField); + } setTitle(GitBundle.message("tag.title")); setOKButtonText(GitBundle.message("tag.button")); myProject = project; @@ -108,6 +202,78 @@ public class GitTagDialog extends DialogWrapper { validateFields(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myTagNameTextField; diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index 798c79e9b1a1..80e59d924f0b 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -12,6 +12,11 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import git4idea.GitStashUsageCollector; import git4idea.GitUtil; import git4idea.i18n.GitBundle; @@ -22,6 +27,7 @@ import git4idea.util.GitUIUtil; import git4idea.validators.GitBranchValidatorKt; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -34,9 +40,13 @@ import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; import static java.util.Collections.singletonList; @@ -44,23 +54,125 @@ import static java.util.Collections.singletonList; * The unstash dialog */ public class GitUnstashDialog extends DialogWrapper { - private JComboBox myGitRootComboBox; - private JLabel myCurrentBranch; - private JButton myViewButton; - private JButton myDropButton; - private JButton myClearButton; - private JCheckBox myPopStashCheckBox; - private JTextField myBranchTextField; - private JPanel myPanel; - private JList myStashList; + private final JComboBox myGitRootComboBox; + private final JLabel myCurrentBranch; + private final JButton myViewButton; + private final JButton myDropButton; + private final JButton myClearButton; + private final JCheckBox myPopStashCheckBox; + private final JTextField myBranchTextField; + private final JPanel myPanel; + private final JList myStashList; private final DefaultListModel myStashListModel; - private JCheckBox myReinstateIndexCheckBox; + private final JCheckBox myReinstateIndexCheckBox; private final Project myProject; private static final Logger LOG = Logger.getInstance(GitUnstashDialog.class); public GitUnstashDialog(final Project project, final List roots, final VirtualFile defaultRoot) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGitRootComboBox = new JComboBox(); + myGitRootComboBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.git.root.tooltip")); + myPanel.add(myGitRootComboBox, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch")); + myPanel.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCurrentBranch = new JLabel(); + myCurrentBranch.setText(" "); + myCurrentBranch.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "common.current.branch.tooltip")); + myPanel.add(myCurrentBranch, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.stashes")); + myPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myViewButton = new JButton(); + this.$$$loadButtonText$$$(myViewButton, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.view")); + myViewButton.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.view.tooltip")); + panel1.add(myViewButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myDropButton = new JButton(); + this.$$$loadButtonText$$$(myDropButton, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.drop")); + myDropButton.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.drop.tooltip")); + panel1.add(myDropButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClearButton = new JButton(); + this.$$$loadButtonText$$$(myClearButton, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.clear")); + myClearButton.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.clear.tooltip")); + panel1.add(myClearButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.branch.label")); + myPanel.add(label4, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBranchTextField = new JTextField(); + myBranchTextField.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.branch.tooltip")); + myPanel.add(myBranchTextField, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myStashList = new JBList(); + myStashList.setSelectionMode(0); + jBScrollPane1.setViewportView(myStashList); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myPopStashCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myPopStashCheckBox, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.pop.stash")); + myPopStashCheckBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.pop.stash.tooltip")); + panel2.add(myPopStashCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myReinstateIndexCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myReinstateIndexCheckBox, this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.reinstate.index")); + myReinstateIndexCheckBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/GitBundle", "unstash.reinstate.index.tooltip")); + panel2.add(myReinstateIndexCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + label1.setLabelFor(myGitRootComboBox); + label3.setLabelFor(jBScrollPane1); + label4.setLabelFor(myBranchTextField); + } setModal(false); myProject = project; setTitle(GitBundle.message("unstash.title")); @@ -126,6 +238,78 @@ public class GitUnstashDialog extends DialogWrapper { updateDialogState(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + /** * Update state dialog depending on the current state of the fields */ diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectCompositeSelectorDialog.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectCompositeSelectorDialog.java index e92437d9b2ee..dcdd9d5c42c6 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectCompositeSelectorDialog.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectCompositeSelectorDialog.java @@ -30,13 +30,18 @@ import org.jetbrains.plugins.gradle.util.GradleBundle; import org.jetbrains.plugins.gradle.util.GradleConstants; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeModel; import javax.swing.tree.TreeNode; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.openapi.util.io.FileUtil.pathsEqual; @@ -48,16 +53,37 @@ public class GradleProjectCompositeSelectorDialog extends DialogWrapper { private static final int MAX_PATH_LENGTH = 40; private final @NotNull Project myProject; private final @Nullable GradleProjectSettings myCompositeRootSettings; - private JPanel mainPanel; - private JPanel contentPanel; + private final JPanel mainPanel; + private final JPanel contentPanel; @SuppressWarnings("unused") - private JBLabel myDescriptionLbl; + private final JBLabel myDescriptionLbl; private final ExternalSystemUiAware myExternalSystemUiAware; private final CheckboxTree myTree; public GradleProjectCompositeSelectorDialog(@NotNull Project project, String compositeRootProjectPath) { super(project, true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(5, 5)); + mainPanel.setEnabled(true); + mainPanel.setMinimumSize(new Dimension(300, 100)); + mainPanel.setOpaque(false); + mainPanel.setPreferredSize(new Dimension(400, 300)); + contentPanel = new JPanel(); + contentPanel.setLayout(new BorderLayout(0, 0)); + contentPanel.setAutoscrolls(true); + contentPanel.setMinimumSize(new Dimension(0, 0)); + contentPanel.setPreferredSize(new Dimension(0, 0)); + mainPanel.add(contentPanel, BorderLayout.CENTER); + myDescriptionLbl = new JBLabel(); + this.$$$loadLabelText$$$(myDescriptionLbl, + this.$$$getMessageFromBundle$$$("messages/GradleBundle", "gradle.settings.composite.selector.description")); + mainPanel.add(myDescriptionLbl, BorderLayout.NORTH); + } myCompositeRootSettings = GradleSettings.getInstance(myProject).getLinkedProjectSettings(compositeRootProjectPath); myExternalSystemUiAware = ExternalSystemUiUtil.getUiAware(GradleConstants.SYSTEM_ID); myTree = createTree(); @@ -66,6 +92,53 @@ public class GradleProjectCompositeSelectorDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + @Override protected @Nullable JComponent createCenterPanel() { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree). diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java index 5dd53b81c14a..49d5447e1cd4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java @@ -23,27 +23,34 @@ import com.intellij.psi.PsiNameHelper; import com.intellij.psi.PsiPackage; import com.intellij.refactoring.util.RefactoringMessageUtil; import com.intellij.ui.EditorTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyBundle; import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class GroovyCreateClassDialog extends DialogWrapper { - private JPanel myContentPane; - private JLabel myInformationLabel; - private EditorTextField myPackageTextField; - private JButton myPackageChooseButton; + private final JPanel myContentPane; + private final JLabel myInformationLabel; + private final EditorTextField myPackageTextField; + private final JButton myPackageChooseButton; private PsiDirectory myTargetDirectory; private final Project myProject; private final String myClassName; @@ -58,6 +65,48 @@ public class GroovyCreateClassDialog extends DialogWrapper { myClassName = targetClassName; myProject = project; myModule = module; + { + myPackageTextField = new EditorTextField(); + myPackageChooseButton = new FixedSizeButton(myPackageTextField); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "destination.package")); + panel2.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(myPackageTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myInformationLabel = new JLabel(); + panel2.add(myInformationLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPackageChooseButton.setText(""); + panel2.add(myPackageChooseButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } setModal(true); setTitle(title); @@ -69,7 +118,8 @@ public class GroovyCreateClassDialog extends DialogWrapper { myPackageChooseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - PackageChooserDialog chooser = new PackageChooserDialog(GroovyBundle.message("dialog.create.class.package.chooser.title"), myProject); + PackageChooserDialog chooser = + new PackageChooserDialog(GroovyBundle.message("dialog.create.class.package.chooser.title"), myProject); chooser.selectPackage(myPackageTextField.getText()); chooser.show(); PsiPackage aPackage = chooser.getSelectedPackage(); @@ -80,11 +130,53 @@ public class GroovyCreateClassDialog extends DialogWrapper { }); } - private void createUIComponents() { - myPackageTextField = new EditorTextField(); - myPackageChooseButton = new FixedSizeButton(myPackageTextField); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + @Override protected @Nullable JComponent createCenterPanel() { myPackageTextField.getDocument().addDocumentListener(new DocumentListener() { @@ -101,7 +193,8 @@ public class GroovyCreateClassDialog extends DialogWrapper { public void actionPerformed(@NotNull AnActionEvent e) { myPackageChooseButton.doClick(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageTextField); + }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), + myPackageTextField); return myContentPane; } @@ -138,7 +231,7 @@ public class GroovyCreateClassDialog extends DialogWrapper { try { final PsiDirectory baseDir = myModule == null ? null : PackageUtil.findPossiblePackageDirectoryInModule(myModule, packageName); myTargetDirectory = myModule == null ? null - : PackageUtil.findOrCreateDirectoryForPackage(myModule, packageName, baseDir, true); + : PackageUtil.findOrCreateDirectoryForPackage(myModule, packageName, baseDir, true); if (myTargetDirectory == null) { errorStringRef.set(""); return; @@ -162,6 +255,4 @@ public class GroovyCreateClassDialog extends DialogWrapper { public String getClassName() { return myClassName; } - - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java index 6c20f314d190..71f82279dd52 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java @@ -24,7 +24,10 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.ProjectScope; import com.intellij.ui.EditorComboBoxEditor; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nullable; @@ -42,23 +45,29 @@ import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.TypeConstraint; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.UIManager; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public abstract class DynamicDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance(DynamicDialog.class); - private JComboBox myClassComboBox; - private JPanel myPanel; - private JComboBox myTypeComboBox; - private JLabel myTypeLabel; - protected JBTable myParametersTable; - private JCheckBox myStaticCheckBox; - private JPanel myTablePane; + private final JComboBox myClassComboBox; + private final JPanel myPanel; + private final JComboBox myTypeComboBox; + private final JLabel myTypeLabel; + protected final JBTable myParametersTable; + private final JCheckBox myStaticCheckBox; + private final JPanel myTablePane; private final DynamicManager myDynamicManager; protected final Project myProject; @@ -67,6 +76,64 @@ public abstract class DynamicDialog extends DialogWrapper { public DynamicDialog(PsiElement context, DynamicElementSettings settings, TypeConstraint[] typeConstraints, boolean isTableVisible) { super(context.getProject(), true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myStaticCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myStaticCheckBox, + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "dynamic.dialog.static.checkbox")); + myPanel.add(myStaticCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTablePane = new JPanel(); + myTablePane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myTablePane, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myTablePane.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myParametersTable = new JBTable(); + myParametersTable.setAutoResizeMode(4); + myParametersTable.setBackground(UIManager.getColor("ArrowButton.background")); + myParametersTable.setEnabled(true); + myParametersTable.setPreferredScrollableViewportSize(new Dimension(450, 50)); + myParametersTable.setShowHorizontalLines(true); + myParametersTable.setShowVerticalLines(true); + jBScrollPane1.setViewportView(myParametersTable); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "dynamic.dialog.class.label")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClassComboBox = new JComboBox(); + panel1.add(myClassComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myTypeLabel = new JLabel(); + this.$$$loadLabelText$$$(myTypeLabel, this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "dynamic.dialog.type.label")); + panel1.add(myTypeLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTypeComboBox = new JComboBox(); + panel1.add(myTypeComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + label1.setLabelFor(myClassComboBox); + myTypeLabel.setLabelFor(myTypeComboBox); + } myProject = context.getProject(); mySettings = settings; myContext = context; @@ -87,6 +154,78 @@ public abstract class DynamicDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setUpStaticComboBox() { myStaticCheckBox.setSelected(mySettings.isStatic()); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java index 625c84494168..372c94621ab3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java @@ -2,15 +2,88 @@ package org.jetbrains.plugins.groovy.debugger; import com.intellij.openapi.options.ConfigurableUi; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; class GroovySteppingConfigurableUi implements ConfigurableUi { - private JCheckBox ignoreGroovyMethods; - private JPanel rootPanel; + private final JCheckBox ignoreGroovyMethods; + private final JPanel rootPanel; + + public GroovySteppingConfigurableUi() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + rootPanel = new JPanel(); + rootPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + ignoreGroovyMethods = new JCheckBox(); + this.$$$loadButtonText$$$(ignoreGroovyMethods, + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "groovy.debug.disable.specific.methods")); + rootPanel.add(ignoreGroovyMethods, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + rootPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return rootPanel; } @Override public void reset(@NotNull GroovyDebuggerSettings settings) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/GroovyMapParameterDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/GroovyMapParameterDialog.java index 4ad639f5f492..0b7441c3751e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/GroovyMapParameterDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/GroovyMapParameterDialog.java @@ -12,6 +12,8 @@ import com.intellij.ui.EditorComboBoxEditor; import com.intellij.ui.EditorComboBoxRenderer; import com.intellij.ui.EditorTextField; import com.intellij.ui.StringComboboxEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,44 +22,161 @@ import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; import org.jetbrains.plugins.groovy.settings.GroovyApplicationSettings; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.EventListener; +import java.util.ResourceBundle; public class GroovyMapParameterDialog extends DialogWrapper { - private JPanel contentPane; - private ComboBox myNameComboBox; - private JLabel myNameLabel; - private JCheckBox myCbTypeSpec; - private JCheckBox myCreateNew; + private final JPanel contentPane; + private final ComboBox myNameComboBox; + private final JLabel myNameLabel; + private final JCheckBox myCbTypeSpec; + private final JCheckBox myCreateNew; private final Project myProject; private final EventListenerList myListenerList = new EventListenerList(); public GroovyMapParameterDialog(Project project, final @NlsSafe String[] possibleNames, final boolean createNew) { super(true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "map.param.name")); + panel1.add(myNameLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCbTypeSpec = new JCheckBox(); + this.$$$loadButtonText$$$(myCbTypeSpec, + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "map.parameter.dialog.explicit.type.checkbox")); + panel1.add(myCbTypeSpec, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCreateNew = new JCheckBox(); + this.$$$loadButtonText$$$(myCreateNew, + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "map.parameter.dialog.create.new.checkbox")); + panel1.add(myCreateNew, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameComboBox = new ComboBox(); + panel1.add(myNameComboBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(100, -1), null, 0, false)); + } setUpDialog(possibleNames, createNew); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + private void setUpDialog(final @NlsSafe String[] possibleNames, boolean createNew) { setTitle(GroovyBundle.message("convert.param.to.map.entry")); if (GroovyApplicationSettings.getInstance().CONVERT_PARAM_CREATE_NEW_PARAM != null) { myCreateNew.setSelected(createNew = GroovyApplicationSettings.getInstance().CONVERT_PARAM_CREATE_NEW_PARAM.booleanValue()); - } else { + } + else { myCreateNew.setSelected(createNew); } @@ -68,7 +187,8 @@ public class GroovyMapParameterDialog extends DialogWrapper { setModal(true); if (GroovyApplicationSettings.getInstance().CONVERT_PARAM_SPECIFY_MAP_TYPE != null) { myCbTypeSpec.setSelected(GroovyApplicationSettings.getInstance().CONVERT_PARAM_SPECIFY_MAP_TYPE.booleanValue()); - } else { + } + else { myCbTypeSpec.setSelected(true); } @@ -122,7 +242,8 @@ public class GroovyMapParameterDialog extends DialogWrapper { protected @Nullable String getEnteredName() { if (myNameComboBox.getEditor().getItem() instanceof String && !((String)myNameComboBox.getEditor().getItem()).isEmpty()) { return (String)myNameComboBox.getEditor().getItem(); - } else { + } + else { return null; } } @@ -155,7 +276,8 @@ public class GroovyMapParameterDialog extends DialogWrapper { contentPane.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true)); } }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); @@ -183,5 +305,4 @@ public class GroovyMapParameterDialog extends DialogWrapper { String text = getEnteredName(); setOKActionEnabled(GroovyNamesUtil.isIdentifier(text)); } - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java index 1f06852ec1bc..133a93274faa 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java @@ -22,6 +22,9 @@ import com.intellij.refactoring.ui.MethodSignatureComponent; import com.intellij.refactoring.util.RefactoringUIUtil; import com.intellij.ui.EditorTextField; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.HashingStrategy; import com.intellij.util.containers.MultiMap; @@ -42,6 +45,7 @@ import org.jetbrains.plugins.groovy.refactoring.ui.GrMethodSignatureComponent; import org.jetbrains.plugins.groovy.refactoring.ui.GroovyComboboxVisibilityPanel; import org.jetbrains.plugins.groovy.settings.GroovyApplicationSettings; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -49,29 +53,125 @@ import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.EventListener; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; public class GroovyExtractMethodDialog extends DialogWrapper { private final ExtractMethodInfoHelper myHelper; private final EventListenerList myListenerList = new EventListenerList(); - private JPanel contentPane; - private EditorTextField myNameField; - private JCheckBox myCbSpecifyType; - private JLabel myNameLabel; + private final JPanel contentPane; + private final EditorTextField myNameField; + private final JCheckBox myCbSpecifyType; + private final JLabel myNameLabel; private MethodSignatureComponent mySignature; - private ComboBoxVisibilityPanel myVisibilityPanel; - private Splitter mySplitter; - private JCheckBox myForceReturnCheckBox; + private final ComboBoxVisibilityPanel myVisibilityPanel; + private final Splitter mySplitter; + private final JCheckBox myForceReturnCheckBox; private GrParameterTablePanel myParameterTablePanel; private final Project myProject; public GroovyExtractMethodDialog(InitialInfo info, PsiClass owner) { super(info.getProject(), true); + { + mySignature = new GrMethodSignatureComponent("", myProject); + mySignature.setPreferredSize(JBUI.size(500, 100)); + mySignature.setMinimumSize(JBUI.size(500, 100)); + mySignature.setBorder( + IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("signature.preview.border.title"), false)); + mySignature.setFocusable(false); + + myNameField = new EditorTextField("", myProject, GroovyFileType.GROOVY_FILE_TYPE); + myVisibilityPanel = new GroovyComboboxVisibilityPanel(); + + String visibility = GroovyApplicationSettings.getInstance().EXTRACT_METHOD_VISIBILITY; + if (visibility == null) { + visibility = PsiModifier.PRIVATE; + } + myVisibilityPanel.setVisibility(visibility); + myVisibilityPanel.addListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + myHelper.setVisibility(myVisibilityPanel.getVisibility()); + updateSignature(); + } + }); + + myParameterTablePanel = new GrParameterTablePanel() { + @Override + protected void updateSignature() { + GroovyExtractMethodDialog.this.updateSignature(); + } + + @Override + protected void doEnterAction() { + GroovyExtractMethodDialog.this.clickDefaultButton(); + } + + @Override + protected void doCancelAction() { + GroovyExtractMethodDialog.this.doCancelAction(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCbSpecifyType = new JCheckBox(); + this.$$$loadButtonText$$$(myCbSpecifyType, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "specify.type.label")); + contentPane.add(myCbSpecifyType, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.add(myVisibilityPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "name.label")); + panel2.add(myNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + panel2.add(myNameField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + mySplitter = new Splitter(); + contentPane.add(mySplitter, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myForceReturnCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myForceReturnCheckBox, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", + "extract.method.dialog.explicit.return.checkbox")); + contentPane.add(myForceReturnCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } myProject = info.getProject(); myHelper = new ExtractMethodInfoHelper(info, "", owner, false); @@ -85,6 +185,78 @@ public class GroovyExtractMethodDialog extends DialogWrapper { update(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + @Override protected void init() { super.init(); @@ -200,48 +372,6 @@ public class GroovyExtractMethodDialog extends DialogWrapper { return HelpID.EXTRACT_METHOD; } - private void createUIComponents() { - mySignature = new GrMethodSignatureComponent("", myProject); - mySignature.setPreferredSize(JBUI.size(500, 100)); - mySignature.setMinimumSize(JBUI.size(500, 100)); - mySignature.setBorder( - IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("signature.preview.border.title"), false)); - mySignature.setFocusable(false); - - myNameField = new EditorTextField("", myProject, GroovyFileType.GROOVY_FILE_TYPE); - myVisibilityPanel = new GroovyComboboxVisibilityPanel(); - - String visibility = GroovyApplicationSettings.getInstance().EXTRACT_METHOD_VISIBILITY; - if (visibility == null) { - visibility = PsiModifier.PRIVATE; - } - myVisibilityPanel.setVisibility(visibility); - myVisibilityPanel.addListener(new ChangeListener(){ - @Override - public void stateChanged(ChangeEvent e) { - myHelper.setVisibility(myVisibilityPanel.getVisibility()); - updateSignature(); - } - }); - - myParameterTablePanel = new GrParameterTablePanel() { - @Override - protected void updateSignature(){ - GroovyExtractMethodDialog.this.updateSignature(); - } - - @Override - protected void doEnterAction(){ - GroovyExtractMethodDialog.this.clickDefaultButton(); - } - - @Override - protected void doCancelAction(){ - GroovyExtractMethodDialog.this.doCancelAction(); - } - }; - } - private static boolean validateMethod(ExtractMethodInfoHelper helper) { MultiMap conflicts = new MultiMap<>(); GrMethod method = ExtractUtil.createMethod(helper); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java index f3d02d7e80f4..3fd13f78f5f3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java @@ -9,6 +9,9 @@ import com.intellij.psi.PsiType; import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; import com.intellij.refactoring.introduceField.IntroduceConstantHandler; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; @@ -25,9 +28,13 @@ import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo; import org.jetbrains.plugins.groovy.refactoring.introduce.field.GroovyInplaceFieldValidator; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public class GrInplaceConstantIntroducer extends GrAbstractInplaceIntroducer { private final GrInplaceIntroduceConstantPanel myPanel; @@ -193,9 +200,85 @@ public class GrInplaceConstantIntroducer extends GrAbstractInplaceIntroducer>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPane = new JPanel(); + myRootPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myRootPane.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myMoveToAnotherClassJBCheckBox = new JBCheckBox(); + myMoveToAnotherClassJBCheckBox.setFocusable(false); + myMoveToAnotherClassJBCheckBox.setRequestFocusEnabled(true); + this.$$$loadButtonText$$$(myMoveToAnotherClassJBCheckBox, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", + "inplace.introduce.constant.move.checkbox")); + myRootPane.add(myMoveToAnotherClassJBCheckBox, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRootPane.add(myPreview, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPane; } public boolean isMoveToAnotherClass() { return myMoveToAnotherClassJBCheckBox.isSelected(); @@ -204,9 +287,5 @@ public class GrInplaceConstantIntroducer extends GrAbstractInplaceIntroducer names = new ArrayList<>(); + if (var != null) { + names.add(var.getName()); + } + if (expression != null) { + names.addAll(suggestNames()); + } + + myNameField = new NameSuggestionsField(ArrayUtilRt.toStringArray(names), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE); + + GrTypeComboBox.registerUpDownHint(myNameField, myTypeCombo); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "type.label")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myTypeCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "name.label")); + panel1.add(myNameLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(35, 49), null, 0, false)); + panel1.add(myNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(myJavaVisibilityPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myReplaceAllOccurrences = new JCheckBox(); + this.$$$loadButtonText$$$(myReplaceAllOccurrences, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "replace.all.occurrences.checkbox")); + myPanel.add(myReplaceAllOccurrences, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargetClassPanel = new JPanel(); + myTargetClassPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myTargetClassPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myTargetClassLabel = new JLabel(); + this.$$$loadLabelText$$$(myTargetClassLabel, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "introduce.constant.class.label")); + myTargetClassPanel.add(myTargetClassLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + label1.setLabelFor(myTypeCombo); + } setTitle(GroovyBundle.message("introduce.constant.title")); @@ -117,6 +209,78 @@ public class GrIntroduceConstantDialog extends DialogWrapper init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public static @Nullable PsiClass getParentClass(PsiElement occurrence) { PsiElement cur = occurrence; while (true) { @@ -160,7 +324,8 @@ public class GrIntroduceConstantDialog extends DialogWrapper TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myContext.getProject()) .createWithInnerClassesScopeChooser(RefactoringBundle.message("choose.destination.class"), GlobalSearchScope.projectScope(myContext.getProject()), - aClass -> aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC), null); + aClass -> aClass.getParent() instanceof GroovyFile || + aClass.hasModifierProperty(PsiModifier.STATIC), null); if (myTargetClass != null) { chooser.selectDirectory(myTargetClass.getContainingFile().getContainingDirectory()); } @@ -169,7 +334,6 @@ public class GrIntroduceConstantDialog extends DialogWrapper if (aClass != null) { myTargetClassEditor.setText(aClass.getQualifiedName()); } - } }, "", myContext.getProject(), true, RECENTS_KEY); myTargetClassPanel.setLayout(new BorderLayout()); @@ -196,7 +360,7 @@ public class GrIntroduceConstantDialog extends DialogWrapper public void documentChanged(@NotNull DocumentEvent e) { targetClassChanged(); updateOkStatus(); - // enableEnumDependant(introduceEnumConstant()); + // enableEnumDependant(introduceEnumConstant()); } }); } @@ -207,7 +371,8 @@ public class GrIntroduceConstantDialog extends DialogWrapper myPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameField, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameField, true)); } }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); @@ -255,42 +420,12 @@ public class GrIntroduceConstantDialog extends DialogWrapper private static final @NonNls String RECENTS_KEY = "GrIntroduceConstantDialog.RECENTS_KEY"; - private void createUIComponents() { - myJavaVisibilityPanel = new JavaVisibilityPanel(false, true); - - final GrVariable var = myContext.getVar(); - final GrExpression expression = myContext.getExpression(); - final StringPartInfo stringPart = myContext.getStringPart(); - if (expression != null) { - myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(expression); - } - else if (stringPart != null) { - myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral()); - } - else { - assert var != null; - myTypeCombo = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var); - } - - List names = new ArrayList<>(); - if (var != null) { - names.add(var.getName()); - } - if (expression != null) { - names.addAll(suggestNames()); - } - - myNameField = new NameSuggestionsField(ArrayUtilRt.toStringArray(names), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE); - - GrTypeComboBox.registerUpDownHint(myNameField, myTypeCombo); - } - private void targetClassChanged() { final String targetClassName = getTargetClassName(); myTargetClass = JavaPsiFacade.getInstance(myContext.getProject()).findClass(targetClassName, GlobalSearchScope.projectScope(myContext.getProject())); updateVisibilityPanel(); -// myIntroduceEnumConstantCb.setEnabled(EnumConstantsUtil.isSuitableForEnumConstant(getSelectedType(), myTargetClassEditor)); + // myIntroduceEnumConstantCb.setEnabled(EnumConstantsUtil.isSuitableForEnumConstant(getSelectedType(), myTargetClassEditor)); } private void updateVisibilityPanel() { @@ -307,12 +442,13 @@ public class GrIntroduceConstantDialog extends DialogWrapper visible.add(PsiModifier.PUBLIC); for (PsiElement occurrence : myContext.getOccurrences()) { final PsiManager psiManager = PsiManager.getInstance(myContext.getProject()); - for (Iterator iterator = visible.iterator(); iterator.hasNext();) { + for (Iterator iterator = visible.iterator(); iterator.hasNext(); ) { String modifier = iterator.next(); try { final String modifierText = PsiModifier.PACKAGE_LOCAL.equals(modifier) ? "" : modifier + " "; - final PsiField field = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createFieldFromText(modifierText + "int xxx;", myTargetClass); + final PsiField field = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory() + .createFieldFromText(modifierText + "int xxx;", myTargetClass); if (!JavaResolveUtil.isAccessible(field, myTargetClass, field.getModifierList(), occurrence, myTargetClass, null)) { iterator.remove(); } @@ -357,7 +493,8 @@ public class GrIntroduceConstantDialog extends DialogWrapper protected void doOKAction() { final String targetClassName = getTargetClassName(); - if (myDefaultTargetClass == null || !targetClassName.isEmpty() && !Comparing.strEqual(targetClassName, myDefaultTargetClass.getQualifiedName())) { + if (myDefaultTargetClass == null || + !targetClassName.isEmpty() && !Comparing.strEqual(targetClassName, myDefaultTargetClass.getQualifiedName())) { final Module module = ModuleUtilCore.findModuleForPsiElement(myContext.getPlace()); JavaPsiFacade facade = JavaPsiFacade.getInstance(myContext.getProject()); PsiClass newClass = facade.findClass(targetClassName, GlobalSearchScope.projectScope(myContext.getProject())); @@ -367,7 +504,8 @@ public class GrIntroduceConstantDialog extends DialogWrapper IntroduceConstantHandler.getRefactoringNameText(), Messages.getErrorIcon()) != Messages.OK) { return; } - myTargetClassInfo = new TargetClassInfo(targetClassName, myContext.getPlace().getContainingFile().getContainingDirectory(), module, myContext.getProject()); + myTargetClassInfo = new TargetClassInfo(targetClassName, myContext.getPlace().getContainingFile().getContainingDirectory(), module, + myContext.getProject()); } else { myTargetClassInfo = new TargetClassInfo(myDefaultTargetClass); @@ -419,7 +557,7 @@ public class GrIntroduceConstantDialog extends DialogWrapper if (psiPackage != null) { final PsiDirectory[] directories = psiPackage.getDirectories(GlobalSearchScope.allScope(project)); psiDirectory = directories.length > 1 ? DirectoryChooserUtil - .chooseDirectory(directories, null, project, new HashMap<>()) : directories[0]; + .chooseDirectory(directories, null, project, new HashMap<>()) : directories[0]; } else { psiDirectory = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, baseDirectory, false); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java index 00a07d474ff5..6b6f422511bf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java @@ -15,6 +15,9 @@ import com.intellij.refactoring.introduce.inplace.KeyboardComboSwitcher; import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; import com.intellij.refactoring.introduceField.IntroduceFieldHandler; import com.intellij.ui.NonFocusableCheckBox; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; @@ -34,13 +37,18 @@ import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext; import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase; import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo; +import javax.swing.AbstractButton; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.EnumSet; import java.util.List; +import java.util.ResourceBundle; /** * @author Max Medvedev @@ -284,13 +292,53 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPane = new JPanel(); + myRootPane.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootPane.add(panel1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "initialize.in.label")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInitCB = new JComboBox(); + panel1.add(myInitCB, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myDeclareFinalCB = new NonFocusableCheckBox(); + myDeclareFinalCB.setHorizontalAlignment(10); + this.$$$loadButtonText$$$(myDeclareFinalCB, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "declare.final.checkbox")); + myRootPane.add(myDeclareFinalCB, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myRootPane.add(myPreview, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + jBLabel1.setLabelFor(myInitCB); + } KeyboardComboSwitcher.setupActions(myInitCB, myProject); for (GrIntroduceFieldSettings.Init place : myApplicablePlaces) { @@ -311,6 +359,78 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPane; } + public JPanel getRootPane() { return myRootPane; } @@ -322,9 +442,5 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer, GrIntroduceFieldSettings { - private JPanel myContentPane; - private NameSuggestionsField myNameField; - private JRadioButton myPrivateRadioButton; - private JRadioButton myProtectedRadioButton; - private JRadioButton myPublicRadioButton; - private JRadioButton myPropertyRadioButton; - private JRadioButton myCurrentMethodRadioButton; - private JRadioButton myFieldDeclarationRadioButton; - private JRadioButton myClassConstructorSRadioButton; - private JBRadioButton mySetUpMethodRadioButton; - private JCheckBox myDeclareFinalCheckBox; - private JCheckBox myReplaceAllOccurrencesCheckBox; - private GrTypeComboBox myTypeComboBox; - private JLabel myNameLabel; - private JLabel myTypeLabel; + private final JPanel myContentPane; + private final NameSuggestionsField myNameField; + private final JRadioButton myPrivateRadioButton; + private final JRadioButton myProtectedRadioButton; + private final JRadioButton myPublicRadioButton; + private final JRadioButton myPropertyRadioButton; + private final JRadioButton myCurrentMethodRadioButton; + private final JRadioButton myFieldDeclarationRadioButton; + private final JRadioButton myClassConstructorSRadioButton; + private final JBRadioButton mySetUpMethodRadioButton; + private final JCheckBox myDeclareFinalCheckBox; + private final JCheckBox myReplaceAllOccurrencesCheckBox; + private final GrTypeComboBox myTypeComboBox; + private final JLabel myNameLabel; + private final JLabel myTypeLabel; private final boolean myIsStatic; private final boolean isInvokedInAlwaysInvokedConstructor; private final boolean hasLHSUsages; @@ -90,6 +99,155 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce public GrIntroduceFieldDialog(final GrIntroduceContext context) { super(context.getProject(), true); myContext = context; + { + final GrExpression expression = myContext.getExpression(); + final GrVariable var = myContext.getVar(); + final StringPartInfo stringPart = myContext.getStringPart(); + + List list = new ArrayList<>(); + if (var != null) { + list.add(var.getName()); + } + list.addAll(suggestNames()); + myNameField = new NameSuggestionsField(ArrayUtilRt.toStringArray(list), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE); + + if (expression != null) { + myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(expression); + } + else if (stringPart != null) { + myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral()); + } + else { + myTypeComboBox = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var); + } + + GrTypeComboBox.registerUpDownHint(myNameField, myTypeComboBox); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myTypeLabel = new JLabel(); + this.$$$loadLabelText$$$(myTypeLabel, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "type.label")); + panel1.add(myTypeLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "name.label")); + panel1.add(myNameLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myTypeComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/GroovyRefactoringBundle", "initialize.in.border.title"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCurrentMethodRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCurrentMethodRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "initialize.in.current.method.choice")); + panel3.add(myCurrentMethodRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myFieldDeclarationRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myFieldDeclarationRadioButton, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", + "initialize.in.field.declaration.choice")); + panel3.add(myFieldDeclarationRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myClassConstructorSRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myClassConstructorSRadioButton, this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", + "initialize.in.class.constructor.choice")); + panel3.add(myClassConstructorSRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mySetUpMethodRadioButton = new JBRadioButton(); + mySetUpMethodRadioButton.setHorizontalAlignment(10); + this.$$$loadButtonText$$$(mySetUpMethodRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "initialize.in.setup.method.choice")); + panel3.add(mySetUpMethodRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(panel4, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/GroovyRefactoringBundle", "visibility.border.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, + null, null)); + myPrivateRadioButton = new JRadioButton(); + myPrivateRadioButton.setSelected(false); + this.$$$loadButtonText$$$(myPrivateRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "visibility.private.choice")); + panel4.add(myPrivateRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myProtectedRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myProtectedRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "visibility.protected.choice")); + panel4.add(myProtectedRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPublicRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPublicRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "visibility.public.choice")); + panel4.add(myPublicRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPropertyRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPropertyRadioButton, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "visibility.property.choice")); + panel4.add(myPropertyRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDeclareFinalCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myDeclareFinalCheckBox, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "declare.final.checkbox")); + myContentPane.add(myDeclareFinalCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myReplaceAllOccurrencesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myReplaceAllOccurrencesCheckBox, + this.$$$getMessageFromBundle$$$("messages/GroovyRefactoringBundle", "replace.all.occurrences.checkbox")); + myContentPane.add(myReplaceAllOccurrencesCheckBox, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } final PsiClass clazz = (PsiClass)context.getScope(); PsiElement scope = clazz instanceof GroovyScriptClass ? clazz.getContainingFile() : clazz; @@ -133,7 +291,7 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce myFieldDeclarationRadioButton.setSelected(true); } - myInvokedOnLocalVar = context.getVar() == null ? getInvokedOnLocalVar(context.getExpression()) : context.getVar().getName(); + myInvokedOnLocalVar = context.getVar() == null ? getInvokedOnLocalVar(context.getExpression()) : context.getVar().getName(); if (myInvokedOnLocalVar != null) { myReplaceAllOccurrencesCheckBox.setText(GroovyBundle.message("replace.all.occurrences.and.remove.variable.0", myInvokedOnLocalVar)); if (context.getVar() != null) { @@ -190,12 +348,87 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce checkErrors(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + private void checkErrors() { List errors = new ArrayList<>(); if (myCurrentMethodRadioButton.isSelected() && myDeclareFinalCheckBox.isSelected() && !isInvokedInAlwaysInvokedConstructor) { errors.add(GroovyRefactoringBundle.message("final.field.cant.be.initialized.in.cur.method")); } - if (myDeclareFinalCheckBox.isSelected() && myReplaceAllOccurrencesCheckBox.isSelected() && myInvokedOnLocalVar != null && hasLHSUsages) { + if (myDeclareFinalCheckBox.isSelected() && + myReplaceAllOccurrencesCheckBox.isSelected() && + myInvokedOnLocalVar != null && + hasLHSUsages) { errors.add(GroovyRefactoringBundle.message("Field.cannot.be.final.because.replaced.variable.has.lhs.usages")); } if (!myCanBeInitializedOutsideBlock) { @@ -288,31 +521,6 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce return new GrFieldNameSuggester(myContext, new GroovyFieldValidator(myContext), false).suggestNames(); } - private void createUIComponents() { - final GrExpression expression = myContext.getExpression(); - final GrVariable var = myContext.getVar(); - final StringPartInfo stringPart = myContext.getStringPart(); - - List list = new ArrayList<>(); - if (var != null) { - list.add(var.getName()); - } - list.addAll(suggestNames()); - myNameField = new NameSuggestionsField(ArrayUtilRt.toStringArray(list), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE); - - if (expression != null) { - myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(expression); - } - else if (stringPart != null) { - myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral()); - } - else { - myTypeComboBox = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var); - } - - GrTypeComboBox.registerUpDownHint(myNameField, myTypeComboBox); - } - @Override public boolean declareFinal() { return myDeclareFinalCheckBox.isSelected(); @@ -451,7 +659,8 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce final String name = getName(); String message = RefactoringBundle.message("field.exists", name, clazz.getQualifiedName()); if (clazz.findFieldByName(name, true) != null && - Messages.showYesNoDialog(myContext.getProject(), message, IntroduceFieldHandler.getRefactoringNameText(), Messages.getWarningIcon()) != Messages.YES) { + Messages.showYesNoDialog(myContext.getProject(), message, IntroduceFieldHandler.getRefactoringNameText(), + Messages.getWarningIcon()) != Messages.YES) { return; } super.doOKAction(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.java index 283802458d97..9d5dcee10bba 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.java @@ -19,32 +19,107 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.PanelWithAnchor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyBundle; import org.jetbrains.plugins.groovy.GroovyFileType; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class GroovyRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { - private JPanel myMainPanel; + private final JPanel myMainPanel; - private LabeledComponentNoThrow myScriptPathComponent; - private CommonJavaParametersPanel myCommonJavaParametersPanel; + private final LabeledComponentNoThrow myScriptPathComponent; + private final CommonJavaParametersPanel myCommonJavaParametersPanel; - private LabeledComponentNoThrow myModulesComboBoxComponent; - private JrePathEditor myJrePathEditor; + private final LabeledComponentNoThrow myModulesComboBoxComponent; + private final JrePathEditor myJrePathEditor; - private JCheckBox myDebugCB; - private JCheckBox myAddClasspathCB; - private LabeledComponentNoThrow myShortenClasspathModeCombo; + private final JCheckBox myDebugCB; + private final JCheckBox myAddClasspathCB; + private final LabeledComponentNoThrow myShortenClasspathModeCombo; private JComponent myAnchor; public GroovyRunConfigurationEditor(@NotNull Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(10, 1, new Insets(0, 0, 0, 0), -1, -1)); + myScriptPathComponent = new LabeledComponentNoThrow(); + myScriptPathComponent.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton"); + myScriptPathComponent.setLabelLocation("West"); + myScriptPathComponent.setText(this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "run.configuration.script.path.label")); + myScriptPathComponent.setVerifyInputWhenFocusTarget(false); + myMainPanel.add(myScriptPathComponent, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myCommonJavaParametersPanel = new CommonJavaParametersPanel(); + myMainPanel.add(myCommonJavaParametersPanel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 10), null, 0, false)); + myModulesComboBoxComponent = new LabeledComponentNoThrow(); + myModulesComboBoxComponent.setComponentClass("com.intellij.application.options.ModulesComboBox"); + myModulesComboBoxComponent.setLabelLocation("West"); + myModulesComboBoxComponent.setText( + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "run.configuration.module.chooser.label")); + myMainPanel.add(myModulesComboBoxComponent, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myJrePathEditor = new JrePathEditor(); + myMainPanel.add(myJrePathEditor, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myShortenClasspathModeCombo = new LabeledComponentNoThrow(); + myShortenClasspathModeCombo.setLabelLocation("West"); + myShortenClasspathModeCombo.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.shorten.command.line.label")); + myMainPanel.add(myShortenClasspathModeCombo, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 10), null, 0, false)); + myDebugCB = new JCheckBox(); + myDebugCB.setSelected(false); + this.$$$loadButtonText$$$(myDebugCB, this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "debug.option")); + myMainPanel.add(myDebugCB, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddClasspathCB = new JCheckBox(); + myAddClasspathCB.setSelected(true); + this.$$$loadButtonText$$$(myAddClasspathCB, + this.$$$getMessageFromBundle$$$("messages/GroovyBundle", "run.configuration.module.classpath.checkbox")); + myMainPanel.add(myAddClasspathCB, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myMainPanel.add(spacer3, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } var scriptPath = myScriptPathComponent.getComponent(); scriptPath.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFileDescriptor(GroovyFileType.GROOVY_FILE_TYPE) .withTitle(GroovyBundle.message("script.runner.chooser.title")) @@ -72,8 +147,9 @@ public class GroovyRunConfigurationEditor extends SettingsEditor modulesComboBox.getSelectedModule(), - listener -> modulesComboBox.addActionListener(listener))); + myShortenClasspathModeCombo.setComponent( + new ShortenCommandLineModeCombo(project, myJrePathEditor, () -> modulesComboBox.getSelectedModule(), + listener -> modulesComboBox.addActionListener(listener))); myAnchor = UIUtil.mergeComponentsWithAnchor( myScriptPathComponent, myCommonJavaParametersPanel, @@ -83,6 +159,53 @@ public class GroovyRunConfigurationEditor extends SettingsEditor thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public void resetEditorFrom(@NotNull GroovyScriptRunConfiguration configuration) { myScriptPathComponent.getComponent().setText(configuration.getScriptPath()); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgCommonDialogWithChoices.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgCommonDialogWithChoices.java index bee4d9622c60..ddca4716cea3 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgCommonDialogWithChoices.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgCommonDialogWithChoices.java @@ -5,6 +5,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,6 +15,8 @@ import org.zmlx.hg4idea.HgBundle; import org.zmlx.hg4idea.repo.HgRepository; import org.zmlx.hg4idea.util.HgUtil; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -21,30 +26,134 @@ import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.Locale; +import java.util.ResourceBundle; import static org.zmlx.hg4idea.util.HgUtil.TIP_REFERENCE; public class HgCommonDialogWithChoices extends DialogWrapper { - private JPanel contentPanel; - private JRadioButton branchOption; - private JRadioButton revisionOption; - private JRadioButton tagOption; - private JRadioButton bookmarkOption; - private JTextField revisionTxt; - protected JCheckBox cleanCbx; - private JComboBox branchSelector; - private JComboBox tagSelector; - private JComboBox bookmarkSelector; - protected HgRepositorySelectorComponent hgRepositorySelectorComponent; - protected JPanel myBranchesBorderPanel; + private final JPanel contentPanel; + private final JRadioButton branchOption; + private final JRadioButton revisionOption; + private final JRadioButton tagOption; + private final JRadioButton bookmarkOption; + private final JTextField revisionTxt; + protected final JCheckBox cleanCbx; + private final JComboBox branchSelector; + private final JComboBox tagSelector; + private final JComboBox bookmarkSelector; + protected final HgRepositorySelectorComponent hgRepositorySelectorComponent; + protected final JPanel myBranchesBorderPanel; - public HgCommonDialogWithChoices(@NotNull Project project, @NotNull Collection repositories, @Nullable HgRepository selectedRepo) { + public HgCommonDialogWithChoices(@NotNull Project project, + @NotNull Collection repositories, + @Nullable HgRepository selectedRepo) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPanel = new JPanel(); + contentPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + contentPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPanel.add(spacer2, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + cleanCbx = new JCheckBox(); + cleanCbx.setEnabled(false); + this.$$$loadButtonText$$$(cleanCbx, this.$$$getMessageFromBundle$$$("messages/HgBundle", "overwrite.locally.modified")); + cleanCbx.putClientProperty("html.disable", Boolean.FALSE); + contentPanel.add(cleanCbx, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBranchesBorderPanel = new JPanel(); + myBranchesBorderPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myBranchesBorderPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + contentPanel.add(myBranchesBorderPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + branchOption = new JRadioButton(); + branchOption.setSelected(true); + this.$$$loadButtonText$$$(branchOption, this.$$$getMessageFromBundle$$$("messages/HgBundle", "branch")); + myBranchesBorderPanel.add(branchOption, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + branchSelector = new JComboBox(); + branchSelector.setEnabled(true); + Font branchSelectorFont = this.$$$getFont$$$("Monospaced", -1, -1, branchSelector.getFont()); + if (branchSelectorFont != null) branchSelector.setFont(branchSelectorFont); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + branchSelector.setModel(defaultComboBoxModel1); + myBranchesBorderPanel.add(branchSelector, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + revisionOption = new JRadioButton(); + revisionOption.setSelected(false); + this.$$$loadButtonText$$$(revisionOption, this.$$$getMessageFromBundle$$$("messages/HgBundle", "revision")); + myBranchesBorderPanel.add(revisionOption, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + revisionTxt = new JTextField(); + revisionTxt.setEnabled(false); + revisionTxt.setText(""); + myBranchesBorderPanel.add(revisionTxt, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(240, -1), null, 0, false)); + tagOption = new JRadioButton(); + this.$$$loadButtonText$$$(tagOption, this.$$$getMessageFromBundle$$$("messages/HgBundle", "action.hg4idea.tag.button")); + myBranchesBorderPanel.add(tagOption, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tagSelector = new JComboBox(); + Font tagSelectorFont = this.$$$getFont$$$("Monospaced", -1, -1, tagSelector.getFont()); + if (tagSelectorFont != null) tagSelector.setFont(tagSelectorFont); + myBranchesBorderPanel.add(tagSelector, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + bookmarkOption = new JRadioButton(); + this.$$$loadButtonText$$$(bookmarkOption, this.$$$getMessageFromBundle$$$("messages/HgBundle", "bookmark")); + myBranchesBorderPanel.add(bookmarkOption, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + bookmarkSelector = new JComboBox(); + Font bookmarkSelectorFont = this.$$$getFont$$$("Monospaced", -1, -1, bookmarkSelector.getFont()); + if (bookmarkSelectorFont != null) bookmarkSelector.setFont(bookmarkSelectorFont); + myBranchesBorderPanel.add(bookmarkSelector, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + hgRepositorySelectorComponent = new HgRepositorySelectorComponent(); + contentPanel.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(revisionOption); + buttonGroup.add(branchOption); + buttonGroup.add(tagOption); + buttonGroup.add(bookmarkOption); + } hgRepositorySelectorComponent.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -67,6 +176,77 @@ public class HgCommonDialogWithChoices extends DialogWrapper { init(); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPanel; } + public void setRoots(Collection repos, @Nullable HgRepository selectedRepo) { hgRepositorySelectorComponent.setRoots(repos); @@ -138,9 +318,6 @@ public class HgCommonDialogWithChoices extends DialogWrapper { return getClass().getName(); } - protected void createUIComponents() { - } - public @NonNls String getTargetValue() { return isBranchSelected() ? "branch(\"" + getBranch() + "\")" diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgGlobalStatusDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgGlobalStatusDialog.java index 5bfe23294c82..99ddac9dbd75 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgGlobalStatusDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgGlobalStatusDialog.java @@ -15,6 +15,9 @@ package org.zmlx.hg4idea.ui; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -22,16 +25,36 @@ import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextArea; +import java.awt.Dimension; +import java.awt.Insets; public class HgGlobalStatusDialog extends DialogWrapper { - private JPanel contentPanel; - private JTextArea outputTextArea; + private final JPanel contentPanel; + private final JTextArea outputTextArea; public HgGlobalStatusDialog(Project project) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPanel = new JPanel(); + contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + contentPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + new Dimension(300, 350), null, null, 0, false)); + outputTextArea = new JTextArea(); + outputTextArea.setEditable(false); + jBScrollPane1.setViewportView(outputTextArea); + } init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPanel; } + public void append(@Nls String text) { if (StringUtil.isEmpty(text)) { return; @@ -48,5 +71,4 @@ public class HgGlobalStatusDialog extends DialogWrapper { protected JComponent createCenterPanel() { return contentPanel; } - } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitAlreadyUnderHgDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitAlreadyUnderHgDialog.java index 40d5c34ab077..757df5b4835d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitAlreadyUnderHgDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitAlreadyUnderHgDialog.java @@ -18,13 +18,20 @@ package org.zmlx.hg4idea.ui; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TitlePanel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xml.util.XmlStringUtil; import org.zmlx.hg4idea.HgBundle; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * The dialog which appears, when user wants to create a Mercurial repository in the folder, @@ -32,10 +39,10 @@ import javax.swing.JRadioButton; * Provides several options to choose. */ public class HgInitAlreadyUnderHgDialog extends DialogWrapper { - private JPanel contentPane; - private JRadioButton myCreateNewRepoButton; - private JRadioButton myUseParentRepoButton; - private TitlePanel myTitlePanel; + private final JPanel contentPane; + private final JRadioButton myCreateNewRepoButton; + private final JRadioButton myUseParentRepoButton; + private final TitlePanel myTitlePanel; private final String myParentRoot; private final String mySelectedRoot; @@ -48,14 +55,100 @@ public class HgInitAlreadyUnderHgDialog extends DialogWrapper { super(project, false); mySelectedRoot = selectedRoot; myParentRoot = parentRoot; + { + myTitlePanel = new TitlePanel(HgBundle.message("hg4idea.init.already.under.hg.title"), + XmlStringUtil.wrapInHtml( + HgBundle.message("hg4idea.init.already.under.hg.description", mySelectedRoot, myParentRoot))); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCreateNewRepoButton = new JRadioButton(); + myCreateNewRepoButton.setSelected(true); + this.$$$loadButtonText$$$(myCreateNewRepoButton, this.$$$getMessageFromBundle$$$("messages/HgBundle", + "hg4idea.init.already.under.hg.option.create.repo.here")); + panel1.add(myCreateNewRepoButton, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myUseParentRepoButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUseParentRepoButton, + this.$$$getMessageFromBundle$$$("messages/HgBundle", "hg4idea.init.already.under.hg.option.use.parent")); + panel1.add(myUseParentRepoButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + panel1.add(myTitlePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + } setTitle(HgBundle.message("hg4idea.init.already.under.hg.dialog.title")); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + public Answer getAnswer() { if (myCreateNewRepoButton.isSelected()) { return Answer.CREATE_REPO_HERE; - } else { + } + else { return Answer.USE_PARENT_REPO; } } @@ -77,10 +170,4 @@ public class HgInitAlreadyUnderHgDialog extends DialogWrapper { protected String getHelpId() { return "reference.mercurial.directory.under.hg.control"; } - - private void createUIComponents() { - myTitlePanel = new TitlePanel(HgBundle.message("hg4idea.init.already.under.hg.title"), - XmlStringUtil.wrapInHtml(HgBundle.message("hg4idea.init.already.under.hg.description", mySelectedRoot, myParentRoot))); - } - } \ No newline at end of file diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java index a6a0863624ee..3f091ad44df3 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java @@ -8,35 +8,44 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgBundle; +import org.zmlx.hg4idea.action.HgInit; import org.zmlx.hg4idea.util.HgUtil; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * The HgInitDialog appears when user wants to create new Mercurial repository, in response to the - * {@link org.zmlx.hg4idea.action.HgInit} action. + * {@link HgInit} action. * It provides two options - create repository for the whole project or select a directory for the repository. * Also if the project directory already is a mercurial root, then no options are provided. * Instead a file chooser appears to select directory for the repository. * - * @see org.zmlx.hg4idea.action.HgInit * @author Kirill Likhodedov + * @see HgInit */ public class HgInitDialog extends DialogWrapper { - private JPanel contentPane; - private JRadioButton myCreateRepositoryForTheRadioButton; - private JRadioButton mySelectWhereToCreateRadioButton; - private TextFieldWithBrowseButton myTextFieldBrowser; + private final JPanel contentPane; + private final JRadioButton myCreateRepositoryForTheRadioButton; + private final JRadioButton mySelectWhereToCreateRadioButton; + private final TextFieldWithBrowseButton myTextFieldBrowser; private final @Nullable Project myProject; private final boolean myShowDialog; // basing on this field, show options or invoke file chooser at once @@ -46,8 +55,48 @@ public class HgInitDialog extends DialogWrapper { public HgInitDialog(@Nullable Project project) { super(project); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCreateRepositoryForTheRadioButton = new JRadioButton(); + myCreateRepositoryForTheRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myCreateRepositoryForTheRadioButton, this.$$$getMessageFromBundle$$$("messages/HgBundle", + "hg4idea.init.dialog.option.create.repository.for.whole.project")); + panel1.add(myCreateRepositoryForTheRadioButton, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySelectWhereToCreateRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(mySelectWhereToCreateRadioButton, + this.$$$getMessageFromBundle$$$("messages/HgBundle", "hg4idea.init.dialog.option.select.folder")); + panel1.add(mySelectWhereToCreateRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTextFieldBrowser = new TextFieldWithBrowseButton(); + myTextFieldBrowser.setEnabled(false); + panel1.add(myTextFieldBrowser, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(mySelectWhereToCreateRadioButton); + buttonGroup.add(myCreateRepositoryForTheRadioButton); + } // a file chooser instead of dialog will be shown immediately if there is no current project or if current project is already an hg root - myShowDialog = (myProject != null && (! myProject.isDefault()) && !HgUtil.isHgRoot(myProject.getBaseDir())); + myShowDialog = (myProject != null && (!myProject.isDefault()) && !HgUtil.isHgRoot(myProject.getBaseDir())); myFileDescriptor = new FileChooserDescriptor(false, true, false, false, false, false) { @Override @@ -65,11 +114,58 @@ public class HgInitDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + @Override protected void init() { super.init(); setTitle(HgBundle.message("hg4idea.init.dialog.title")); - if (myProject != null && (! myProject.isDefault())) { + if (myProject != null && (!myProject.isDefault())) { mySelectedDir = myProject.getBaseDir(); } @@ -136,7 +232,8 @@ public class HgInitDialog extends DialogWrapper { if (myShowDialog && myCreateRepositoryForTheRadioButton.isSelected()) { enableOKAction(); mySelectedDir = myProject.getBaseDir(); - } else { + } + else { final VirtualFile vf = VcsUtil.getVirtualFile(myTextFieldBrowser.getText()); if (vf == null) { disableOKAction(); @@ -147,7 +244,8 @@ public class HgInitDialog extends DialogWrapper { if (vf.exists() && vf.isValid() && vf.isDirectory()) { enableOKAction(); mySelectedDir = vf; - } else { + } + else { disableOKAction(); mySelectedDir = null; } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java index 69ea5a9fc2ea..0df67bdd0040 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java @@ -19,6 +19,9 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorComboBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgBundle; @@ -26,22 +29,70 @@ import org.zmlx.hg4idea.repo.HgRepository; import org.zmlx.hg4idea.util.HgUtil; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; public class HgPullDialog extends DialogWrapper { private final Project project; - private HgRepositorySelectorComponent hgRepositorySelector; - private JPanel mainPanel; - private EditorComboBox myRepositoryURL; + private final HgRepositorySelectorComponent hgRepositorySelector; + private final JPanel mainPanel; + private final EditorComboBox myRepositoryURL; private String myCurrentRepositoryUrl; public HgPullDialog(@NotNull Project project, @NotNull Collection repositories, final @Nullable HgRepository selectedRepo) { super(project, false); this.project = project; + { + myRepositoryURL = new EditorComboBox(""); + myRepositoryURL.addDocumentListener(new DocumentListener() { + @Override + public void documentChanged(@NotNull DocumentEvent e) { + onChangePullSource(); + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + hgRepositorySelector = new HgRepositorySelectorComponent(); + mainPanel.add(hgRepositorySelector.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/HgBundle", "action.hg4idea.pull.from")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myRepositoryURL.setEditable(true); + panel1.add(myRepositoryURL, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } hgRepositorySelector.setTitle(HgBundle.message("action.hg4idea.pull.select.repo")); hgRepositorySelector.addActionListener(new ActionListener() { @Override @@ -56,16 +107,53 @@ public class HgPullDialog extends DialogWrapper { setRoots(repositories, selectedRepo); } - public void createUIComponents() { - myRepositoryURL = new EditorComboBox(""); - myRepositoryURL.addDocumentListener(new DocumentListener() { - @Override - public void documentChanged(@NotNull DocumentEvent e) { - onChangePullSource(); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); } - }); + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + private void addPathsFromHgrc(@NotNull VirtualFile repo) { Collection paths = HgUtil.getRepositoryPaths(project, repo); for (String path : paths) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRepositorySelectorComponent.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRepositorySelectorComponent.java index 4c385c6d9300..77edea260f41 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRepositorySelectorComponent.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRepositorySelectorComponent.java @@ -14,19 +14,68 @@ package org.zmlx.hg4idea.ui; import com.intellij.openapi.util.NlsContexts; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.repo.HgRepository; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; public class HgRepositorySelectorComponent { - private JComboBox repositorySelector; - private JPanel mainPanel; + private final JComboBox repositorySelector; + private final JPanel mainPanel; + + public HgRepositorySelectorComponent() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + mainPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/HgBundle", + "select.repo"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + repositorySelector = new JComboBox(); + mainPanel.add(repositorySelector, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } public void setRoots(Collection roots) { DefaultComboBoxModel model = new DefaultComboBoxModel(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRunConflictResolverDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRunConflictResolverDialog.java index d20f549fc2a4..d322447f80e2 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRunConflictResolverDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgRunConflictResolverDialog.java @@ -17,6 +17,11 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBList; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgBundle; @@ -29,16 +34,21 @@ import javax.swing.DefaultListModel; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; import java.util.Map; +import java.util.ResourceBundle; public class HgRunConflictResolverDialog extends DialogWrapper { - private JPanel mainPanel; - private HgRepositorySelectorComponent repositorySelector; - private JList conflictsList; + private final JPanel mainPanel; + private final HgRepositorySelectorComponent repositorySelector; + private final JList conflictsList; private final Project project; @@ -47,6 +57,38 @@ public class HgRunConflictResolverDialog extends DialogWrapper { @Nullable HgRepository selectedRepo) { super(project, false); this.project = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + repositorySelector = new HgRepositorySelectorComponent(); + mainPanel.add(repositorySelector.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/HgBundle", + "action.hg4idea.run.conflict.resolver.conflicts"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + conflictsList = new JBList(); + panel1.add(conflictsList, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(150, 150), null, 0, false)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } repositorySelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -58,6 +100,28 @@ public class HgRunConflictResolverDialog extends DialogWrapper { setRoots(repositories, selectedRepo); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + public @NotNull HgRepository getRepository() { return repositorySelector.getRepository(); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgTagDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgTagDialog.java index a3654d88acf6..2b6afc9f10f3 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgTagDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgTagDialog.java @@ -16,6 +16,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgBundle; @@ -24,20 +27,59 @@ import org.zmlx.hg4idea.util.HgBranchReferenceValidator; import org.zmlx.hg4idea.util.HgReferenceValidator; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; public class HgTagDialog extends DialogWrapper { - private JPanel contentPanel; - private JTextField tagTxt; - private HgRepositorySelectorComponent hgRepositorySelectorComponent; + private final JPanel contentPanel; + private final JTextField tagTxt; + private final HgRepositorySelectorComponent hgRepositorySelectorComponent; public HgTagDialog(@NotNull Project project, @NotNull Collection repositories, @Nullable HgRepository selectedRepo) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPanel = new JPanel(); + contentPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + contentPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + hgRepositorySelectorComponent = new HgRepositorySelectorComponent(); + contentPanel.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/HgBundle", "action.hg4idea.tag.name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + tagTxt = new JTextField(); + panel1.add(tagTxt, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } hgRepositorySelectorComponent.setTitle(HgBundle.message("action.hg4idea.tag.select.repo")); DocumentListener documentListener = new DocumentAdapter() { @Override @@ -54,6 +96,53 @@ public class HgTagDialog extends DialogWrapper { setRoots(repositories, selectedRepo); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPanel; } + public String getTagName() { return tagTxt.getText(); } diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nizeQuickFixDialog.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nizeQuickFixDialog.java index 3fdc01562153..06f3efd5ebc4 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nizeQuickFixDialog.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nizeQuickFixDialog.java @@ -35,6 +35,10 @@ import com.intellij.psi.PsiExpressionCodeFragment; import com.intellij.psi.PsiFile; import com.intellij.ui.EditorComboBox; import com.intellij.ui.HyperlinkLabel; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.intellij.util.IncorrectOperationException; import com.intellij.util.concurrency.AppExecutorUtil; @@ -46,16 +50,23 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.ide.PooledThreadExecutor; import org.jetbrains.uast.UExpression; +import javax.swing.BorderFactory; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.io.IOException; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.concurrent.ExecutorService; public class JavaI18nizeQuickFixDialog extends I18nizeQuickFixDialog { @@ -323,11 +334,89 @@ public class JavaI18nizeQuickFixDialog extends I18nizeQui } static class JavaExtensibilityData { - private JPanel myPreviewPanel; - private JPanel myJavaCodeInfoPanel; - private JPanel myPanel; - private JPanel myHyperLinkPanel; - private MultiLineLabel myPreviewLabel; - private JPanel myResourceBundleSuggester; + private final JPanel myPreviewPanel; + private final JPanel myJavaCodeInfoPanel; + private final JPanel myPanel; + private final JPanel myHyperLinkPanel; + private final MultiLineLabel myPreviewLabel; + private final JPanel myResourceBundleSuggester; + + public JavaExtensibilityData() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setMinimumSize(new Dimension(400, 400)); + myPanel.setPreferredSize(new Dimension(400, 400)); + myPreviewPanel = new JPanel(); + myPreviewPanel.setLayout(new GridLayoutManager(2, 1, new Insets(5, 5, 5, 5), -1, -1)); + myPreviewPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanel.add(myPreviewPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(100, -1), null, null, 0, false)); + myPreviewPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/JavaI18nBundle", + "i18n.quickfix.preview.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myPreviewLabel = new MultiLineLabel(); + myPreviewLabel.setText("####"); + myPreviewPanel.add(myPreviewLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(75, -1), null, null, 0, + false)); + myHyperLinkPanel = new JPanel(); + myPreviewPanel.add(myHyperLinkPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(45, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myJavaCodeInfoPanel = new JPanel(); + myJavaCodeInfoPanel.setLayout(new GridLayoutManager(1, 1, new Insets(5, 5, 5, 5), 4, -1)); + myJavaCodeInfoPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanel.add(myJavaCodeInfoPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, + false)); + myJavaCodeInfoPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/JavaI18nBundle", + "i18n.quickfix.code.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myResourceBundleSuggester = new JPanel(); + myJavaCodeInfoPanel.add(myResourceBundleSuggester, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationIconsDialog.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationIconsDialog.java index 8ef717bf69f0..bc6cf0d55acf 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationIconsDialog.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationIconsDialog.java @@ -11,13 +11,20 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.JavaFXBundle; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class JavaFxApplicationIconsDialog extends DialogWrapper { private Panel myPanel; @@ -86,9 +93,103 @@ public final class JavaFxApplicationIconsDialog extends DialogWrapper { } protected static final class Panel { - JPanel myWholePanel; - private TextFieldWithBrowseButton myLinuxIconPath; - private TextFieldWithBrowseButton myMacIconPath; - private TextFieldWithBrowseButton myWindowsIconPath; + final JPanel myWholePanel; + private final TextFieldWithBrowseButton myLinuxIconPath; + private final TextFieldWithBrowseButton myMacIconPath; + private final TextFieldWithBrowseButton myWindowsIconPath; + + public Panel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.app.dialog.linux.icon")); + myWholePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLinuxIconPath = new TextFieldWithBrowseButton(); + myWholePanel.add(myLinuxIconPath, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.app.dialog.mac.icon")); + myWholePanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myMacIconPath = new TextFieldWithBrowseButton(); + myWholePanel.add(myMacIconPath, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.app.dialog.windows.icon")); + myWholePanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, + false)); + myWindowsIconPath = new TextFieldWithBrowseButton(); + myWholePanel.add(myWindowsIconPath, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, + null, null, 0, false)); + label1.setLabelFor(myLinuxIconPath); + label2.setLabelFor(myMacIconPath); + label3.setLabelFor(myWindowsIconPath); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java index 3e872b907cf1..e7610b673d6a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java @@ -13,6 +13,10 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.ui.ArtifactPropertiesEditor; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColumnInfo; @@ -20,54 +24,296 @@ import com.intellij.util.ui.ListTableModel; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.JavaFXBundle; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JEditorPane; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.text.JTextComponent; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Base64; import java.util.List; +import java.util.ResourceBundle; public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor { private final JavaFxArtifactProperties myProperties; - private JPanel myWholePanel; - private JTextField myTitleTF; - private JTextField myVendorTF; - private JEditorPane myDescriptionEditorPane; - private TextFieldWithBrowseButton myAppClass; - private JTextField myVersionTF; - private JTextField myWidthTF; - private JTextField myHeightTF; - private TextFieldWithBrowseButton myHtmlTemplate; - private JTextField myHtmlPlaceholderIdTF; - private TextFieldWithBrowseButton myHtmlParams; - private TextFieldWithBrowseButton myParams; - private JCheckBox myUpdateInBackgroundCB; - private JCheckBox myEnableSigningCB; - private JButton myEditSignCertificateButton; - private JCheckBox myConvertCssToBinCheckBox; + private final JPanel myWholePanel; + private final JTextField myTitleTF; + private final JTextField myVendorTF; + private final JEditorPane myDescriptionEditorPane; + private final TextFieldWithBrowseButton myAppClass; + private final JTextField myVersionTF; + private final JTextField myWidthTF; + private final JTextField myHeightTF; + private final TextFieldWithBrowseButton myHtmlTemplate; + private final JTextField myHtmlPlaceholderIdTF; + private final TextFieldWithBrowseButton myHtmlParams; + private final TextFieldWithBrowseButton myParams; + private final JCheckBox myUpdateInBackgroundCB; + private final JCheckBox myEnableSigningCB; + private final JButton myEditSignCertificateButton; + private final JCheckBox myConvertCssToBinCheckBox; private JComboBox myNativeBundleCB; - private JButton myEditAttributesButton; - private JButton myEditIconsButton; + private final JButton myEditAttributesButton; + private final JButton myEditIconsButton; private JavaFxEditCertificatesDialog myDialog; private List myCustomManifestAttributes; private JavaFxApplicationIcons myIcons; - private JComboBox myMsgOutputLevel; + private final JComboBox myMsgOutputLevel; public JavaFxArtifactPropertiesEditor(JavaFxArtifactProperties properties, final Project project, Artifact artifact) { super(); myProperties = properties; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(18, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.title")); + panel1.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTitleTF = new JTextField(); + panel1.add(myTitleTF, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.vendor")); + panel1.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myVendorTF = new JTextField(); + panel1.add(myVendorTF, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(-1, 100), null, 0, false)); + myDescriptionEditorPane = new JEditorPane(); + jBScrollPane1.setViewportView(myDescriptionEditorPane); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.description")); + panel1.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.application.class")); + panel1.add(label4, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAppClass = new TextFieldWithBrowseButton(); + panel1.add(myAppClass, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.width")); + panel1.add(label5, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWidthTF = new JTextField(); + panel1.add(myWidthTF, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.height")); + panel1.add(label6, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHeightTF = new JTextField(); + panel1.add(myHeightTF, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.html.template")); + panel1.add(label7, + new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHtmlTemplate = new TextFieldWithBrowseButton(); + panel1.add(myHtmlTemplate, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label8 = new JLabel(); + this.$$$loadLabelText$$$(label8, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.html.placeholder.id")); + panel1.add(label8, + new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHtmlPlaceholderIdTF = new JTextField(); + panel1.add(myHtmlPlaceholderIdTF, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label9 = new JLabel(); + this.$$$loadLabelText$$$(label9, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.html.parameters")); + panel1.add(label9, + new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHtmlParams = new TextFieldWithBrowseButton(); + panel1.add(myHtmlParams, new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label10 = new JLabel(); + this.$$$loadLabelText$$$(label10, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.application.parameters")); + panel1.add(label10, + new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myParams = new TextFieldWithBrowseButton(); + panel1.add(myParams, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myUpdateInBackgroundCB = new JCheckBox(); + this.$$$loadButtonText$$$(myUpdateInBackgroundCB, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.update.in.background.option")); + panel1.add(myUpdateInBackgroundCB, new GridConstraints(11, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEnableSigningCB = new JCheckBox(); + this.$$$loadButtonText$$$(myEnableSigningCB, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.signing.option")); + panel1.add(myEnableSigningCB, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(14, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myEditSignCertificateButton = new JButton(); + this.$$$loadButtonText$$$(myEditSignCertificateButton, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.edit.certificates.button")); + panel2.add(myEditSignCertificateButton, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myConvertCssToBinCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myConvertCssToBinCheckBox, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.convert.css.to.bin.option")); + panel1.add(myConvertCssToBinCheckBox, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + this.$$$loadLabelText$$$(label11, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.native.bundle")); + panel1.add(label11, + new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNativeBundleCB = new JComboBox(); + panel1.add(myNativeBundleCB, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label12 = new JLabel(); + this.$$$loadLabelText$$$(label12, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.custom.manifest.attributes")); + panel1.add(label12, + new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel3, new GridConstraints(15, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myEditAttributesButton = new JButton(); + this.$$$loadButtonText$$$(myEditAttributesButton, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.edit.attributes.button")); + panel3.add(myEditAttributesButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel4, new GridConstraints(16, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myEditIconsButton = new JButton(); + this.$$$loadButtonText$$$(myEditIconsButton, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.edit.icons.button")); + panel4.add(myEditIconsButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel4.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label13 = new JLabel(); + this.$$$loadLabelText$$$(label13, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.application.icon")); + panel1.add(label13, + new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label14 = new JLabel(); + this.$$$loadLabelText$$$(label14, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.artifact.properties.editor.version")); + panel1.add(label14, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myVersionTF = new JTextField(); + myVersionTF.setText(""); + panel1.add(myVersionTF, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label15 = new JLabel(); + this.$$$loadLabelText$$$(label15, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.artifact.properties.editor.build.output.level")); + panel1.add(label15, + new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMsgOutputLevel = new JComboBox(); + panel1.add(myMsgOutputLevel, new GridConstraints(17, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer4 = new Spacer(); + myWholePanel.add(spacer4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(myTitleTF); + label2.setLabelFor(myVendorTF); + label3.setLabelFor(myDescriptionEditorPane); + label4.setLabelFor(myAppClass); + label5.setLabelFor(myWidthTF); + label6.setLabelFor(myHeightTF); + label7.setLabelFor(myHtmlTemplate); + label8.setLabelFor(myHtmlPlaceholderIdTF); + label9.setLabelFor(myHtmlParams); + label10.setLabelFor(myParams); + label11.setLabelFor(myMsgOutputLevel); + label14.setLabelFor(myVersionTF); + } JavaFxApplicationClassBrowser.appClassBrowser(project, artifact).setField(myAppClass); myHtmlParams.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFileDescriptor("properties") - .withTitle(JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.standalone.title" )) + .withTitle(JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.standalone.title")) .withDescription(JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.standalone.description"))); myParams.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFileDescriptor("properties") .withTitle(JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.run.in.browser.title")) @@ -105,6 +351,78 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit myMsgOutputLevel.setModel(new DefaultComboBoxModel<>(ArrayUtilRt.toStringArray(outputLevels))); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override public String getTabName() { return JavaFXBundle.message("java.fx.artifacts.tab.name"); @@ -137,9 +455,15 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit if (isModified(myProperties.getAlias(), myDialog.myPanel.myAliasTF)) return true; if (isModified(myProperties.getKeystore(), myDialog.myPanel.myKeystore)) return true; final String keypass = myProperties.getKeypass(); - if (isModified(keypass != null ? new String(Base64.getDecoder().decode(keypass), StandardCharsets.UTF_8) : "", myDialog.myPanel.myKeypassTF)) return true; + if (isModified(keypass != null ? new String(Base64.getDecoder().decode(keypass), StandardCharsets.UTF_8) : "", + myDialog.myPanel.myKeypassTF)) { + return true; + } final String storepass = myProperties.getStorepass(); - if (isModified(storepass != null ? new String(Base64.getDecoder().decode(storepass), StandardCharsets.UTF_8) : "", myDialog.myPanel.myStorePassTF)) return true; + if (isModified(storepass != null ? new String(Base64.getDecoder().decode(storepass), StandardCharsets.UTF_8) : "", + myDialog.myPanel.myStorePassTF)) { + return true; + } if (myProperties.isSelfSigning() != myDialog.myPanel.mySelfSignedRadioButton.isSelected()) return true; } @@ -184,9 +508,11 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit myProperties.setAlias(myDialog.myPanel.myAliasTF.getText()); myProperties.setKeystore(myDialog.myPanel.myKeystore.getText()); final String keyPass = String.valueOf((myDialog.myPanel.myKeypassTF.getPassword())); - myProperties.setKeypass(!StringUtil.isEmptyOrSpaces(keyPass) ? Base64.getEncoder().encodeToString(keyPass.getBytes(StandardCharsets.UTF_8)) : null); + myProperties.setKeypass( + !StringUtil.isEmptyOrSpaces(keyPass) ? Base64.getEncoder().encodeToString(keyPass.getBytes(StandardCharsets.UTF_8)) : null); final String storePass = String.valueOf(myDialog.myPanel.myStorePassTF.getPassword()); - myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64.getEncoder().encodeToString(storePass.getBytes(StandardCharsets.UTF_8)) : null); + myProperties.setStorepass( + !StringUtil.isEmptyOrSpaces(storePass) ? Base64.getEncoder().encodeToString(storePass.getBytes(StandardCharsets.UTF_8)) : null); } myProperties.setCustomManifestAttributes(myCustomManifestAttributes); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxEditCertificatesDialog.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxEditCertificatesDialog.java index 5b5f548fbb8d..96caaf9492ba 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxEditCertificatesDialog.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxEditCertificatesDialog.java @@ -7,20 +7,30 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.JavaFXBundle; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JRadioButton; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.ResourceBundle; public final class JavaFxEditCertificatesDialog extends DialogWrapper { @@ -86,13 +96,168 @@ public final class JavaFxEditCertificatesDialog extends DialogWrapper { } protected static final class Panel { - JRadioButton mySelfSignedRadioButton; - JRadioButton mySignedByKeyRadioButton; - JPasswordField myStorePassTF; - JPasswordField myKeypassTF; - JTextField myAliasTF; - TextFieldWithBrowseButton myKeystore; - JPanel myWholePanel; - JPanel myKeysPanel; + final JRadioButton mySelfSignedRadioButton; + final JRadioButton mySignedByKeyRadioButton; + final JPasswordField myStorePassTF; + final JPasswordField myKeypassTF; + final JTextField myAliasTF; + final TextFieldWithBrowseButton myKeystore; + final JPanel myWholePanel; + final JPanel myKeysPanel; + + public Panel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + mySelfSignedRadioButton = new JRadioButton(); + mySelfSignedRadioButton.setSelected(true); + this.$$$loadButtonText$$$(mySelfSignedRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.edit.certificates.dialog.self.signed.radio")); + myWholePanel.add(mySelfSignedRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mySignedByKeyRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(mySignedByKeyRadioButton, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.edit.certificates.dialog.signed.by.key.radio")); + myWholePanel.add(mySignedByKeyRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myKeysPanel = new JPanel(); + myKeysPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 36, 0, 0), -1, -1)); + myWholePanel.add(myKeysPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.edit.certificates.dialog.keystore")); + myKeysPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer2 = new Spacer(); + myKeysPanel.add(spacer2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myKeystore = new TextFieldWithBrowseButton(); + myKeysPanel.add(myKeystore, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.edit.certificates.dialog.alias")); + myKeysPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.edit.certificates.dialog.signed.storepass")); + myKeysPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, + this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", "javafx.edit.certificates.dialog.keypass")); + myKeysPanel.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAliasTF = new JTextField(); + myKeysPanel.add(myAliasTF, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myStorePassTF = new JPasswordField(); + myKeysPanel.add(myStorePassTF, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myKeypassTF = new JPasswordField(); + myKeysPanel.add(myKeypassTF, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + label1.setLabelFor(myKeystore); + label2.setLabelFor(myAliasTF); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(mySelfSignedRadioButton); + buttonGroup.add(mySignedByKeyRadioButton); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/preloader/JavaFxPreloaderArtifactPropertiesEditor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/preloader/JavaFxPreloaderArtifactPropertiesEditor.java index f49712fae586..de56f879b185 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/preloader/JavaFxPreloaderArtifactPropertiesEditor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/preloader/JavaFxPreloaderArtifactPropertiesEditor.java @@ -6,24 +6,101 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Comparing; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.ui.ArtifactPropertiesEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.JavaFXBundle; import org.jetbrains.plugins.javaFX.packaging.JavaFxApplicationClassBrowser; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class JavaFxPreloaderArtifactPropertiesEditor extends ArtifactPropertiesEditor { private final JavaFxPreloaderArtifactProperties myProperties; - private JPanel myPanel; - private TextFieldWithBrowseButton myPreloaderTf; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myPreloaderTf; public JavaFxPreloaderArtifactPropertiesEditor(JavaFxPreloaderArtifactProperties properties, Project project, Artifact artifact) { super(); myProperties = properties; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JavaFXBundle", + "javafx.preloader.artifact.properties.editor.preloader.class")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myPreloaderTf = new TextFieldWithBrowseButton(); + myPanel.add(myPreloaderTf, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } JavaFxApplicationClassBrowser.preloaderClassBrowser(project, artifact).setField(myPreloaderTf); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public String getTabName() { return JavaFXBundle.message("javafx.preloader.tab.name"); diff --git a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java index 9f9375a8aa4a..34cfee7fb3de 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java +++ b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java @@ -59,6 +59,9 @@ import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.fields.ExpandableTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.intellij.util.concurrency.NonUrgentExecutor; import com.intellij.util.indexing.DumbModeAccessType; @@ -67,13 +70,16 @@ import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.JSeparator; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; @@ -81,11 +87,17 @@ import javax.swing.event.ChangeListener; import javax.swing.text.Document; import javax.swing.text.PlainDocument; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.function.Supplier; /** @@ -103,7 +115,7 @@ public class JUnitConfigurable extends SettingsEdi new IntArrayList(new int[]{1, 2}), new IntArrayList(new int[]{6}), new IntArrayList(new int[]{1, 2}) - ); + ); private static final String[] FORK_MODE_ALL = {JUnitConfiguration.FORK_NONE, JUnitConfiguration.FORK_METHOD, JUnitConfiguration.FORK_KLASS}; private static final String[] FORK_MODE = {JUnitConfiguration.FORK_NONE, JUnitConfiguration.FORK_METHOD}; @@ -112,39 +124,294 @@ public class JUnitConfigurable extends SettingsEdi private final LabeledComponent[] myTestLocations = new LabeledComponent[6]; private final JUnitConfigurationModel myModel; private final BrowseModuleValueActionListener[] myBrowsers; - private JComponent myPackagePanel; - private LabeledComponent myPackage; - private LabeledComponentNoThrow myDir; - private LabeledComponentNoThrow myPattern; - private LabeledComponent myClass; - private LabeledComponent myMethod; - private LabeledComponent myCategory; + private final JComponent myPackagePanel; + private final LabeledComponent myPackage; + private final LabeledComponentNoThrow myDir; + private final LabeledComponentNoThrow myPattern; + private final LabeledComponent myClass; + private final LabeledComponent myMethod; + private final LabeledComponent myCategory; // Fields - private JPanel myWholePanel; - private LabeledComponentNoThrow myModule; - private LabeledComponentNoThrow myUseModulePath; - private CommonJavaParametersPanel myCommonJavaParameters; - private JRadioButton myWholeProjectScope; - private JRadioButton mySingleModuleScope; - private JRadioButton myModuleWDScope; + private final JPanel myWholePanel; + private final LabeledComponentNoThrow myModule; + private final LabeledComponentNoThrow myUseModulePath; + private final CommonJavaParametersPanel myCommonJavaParameters; + private final JRadioButton myWholeProjectScope; + private final JRadioButton mySingleModuleScope; + private final JRadioButton myModuleWDScope; private final TextFieldWithBrowseButton myPatternTextField; - private JrePathEditor myJrePathEditor; - private LabeledComponent myShortenClasspathModeCombo; - private JComboBox myForkCb; - private JBLabel myTestLabel; - private JComboBox myTypeChooser; - private JBLabel mySearchForTestsLabel; - private JPanel myScopesPanel; - private JComboBox myRepeatCb; - private JTextField myRepeatCountField; - private LabeledComponentNoThrow> myChangeListLabeledComponent; - private LabeledComponentNoThrow myUniqueIdField; - private LabeledComponentNoThrow myTagsField; + private final JrePathEditor myJrePathEditor; + private final LabeledComponent myShortenClasspathModeCombo; + private final JComboBox myForkCb; + private final JBLabel myTestLabel; + private final JComboBox myTypeChooser; + private final JBLabel mySearchForTestsLabel; + private final JPanel myScopesPanel; + private final JComboBox myRepeatCb; + private final JTextField myRepeatCountField; + private final LabeledComponentNoThrow> myChangeListLabeledComponent; + private final LabeledComponentNoThrow myUniqueIdField; + private final LabeledComponentNoThrow myTagsField; private final Project myProject; private JComponent anchor; public JUnitConfigurable(final Project project) { myProject = project; + { + myPackage = new LabeledComponent<>(); + myPackage.setComponent(new EditorTextFieldWithBrowseButton(myProject, false)); + + myCategory = new LabeledComponent<>(); + myCategory.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() { + @Override + public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) { + if (declaration instanceof PsiClass) { + return Visibility.VISIBLE; + } + return Visibility.NOT_VISIBLE; + } + })); + + myMethod = new LabeledComponent<>(); + myMethod.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, + JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, + PlainTextLanguage.INSTANCE.getAssociatedFileType())); + + myShortenClasspathModeCombo = new LabeledComponent<>(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestLabel = new JBLabel(); + myTestLabel.setHorizontalAlignment(2); + myTestLabel.setHorizontalTextPosition(2); + myTestLabel.setIconTextGap(4); + this.$$$loadLabelText$$$(myTestLabel, this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", + "junit.configuration.configure.junit.test.kind.label")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + panel1.add(myTestLabel, gbc); + myTypeChooser = new JComboBox(); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(0, 10, 0, 0); + panel1.add(myTypeChooser, gbc); + final JPanel spacer1 = new JPanel(); + gbc = new GridBagConstraints(); + gbc.gridx = 2; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel1.add(spacer1, gbc); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel2, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myCommonJavaParameters = new CommonJavaParametersPanel(); + panel2.add(myCommonJavaParameters, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myModule = new LabeledComponentNoThrow(); + myModule.setComponentClass("com.intellij.application.options.ModuleDescriptionsComboBox"); + myModule.setEnabled(true); + myModule.setLabelLocation("West"); + myModule.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.use.classpath.and.jdk.of.module.label")); + panel2.add(myModule, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseModulePath = new LabeledComponentNoThrow(); + myUseModulePath.setComponentClass("javax.swing.JCheckBox"); + myUseModulePath.setEnabled(true); + myUseModulePath.setLabelLocation("West"); + myUseModulePath.setText(""); + panel2.add(myUseModulePath, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShortenClasspathModeCombo.setEnabled(true); + myShortenClasspathModeCombo.setLabelLocation("West"); + myShortenClasspathModeCombo.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.shorten.command.line.label")); + panel2.add(myShortenClasspathModeCombo, + new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel2.add(spacer3, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + myJrePathEditor = new JrePathEditor(); + panel2.add(myJrePathEditor, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel3.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "repeat.label")); + panel3.add(label1, + new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "fork.mode.label")); + panel3.add(jBLabel1, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myForkCb = new JComboBox(); + panel3.add(myForkCb, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myRepeatCountField = new JTextField(); + myRepeatCountField.setColumns(3); + panel3.add(myRepeatCountField, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myRepeatCb = new JComboBox(); + panel3.add(myRepeatCb, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JSeparator separator1 = new JSeparator(); + myWholePanel.add(separator1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(10, 1, new Insets(0, 0, 0, 0), -1, -1)); + myWholePanel.add(panel4, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myMethod.setEnabled(true); + myMethod.setLabelLocation("West"); + myMethod.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.method.label")); + panel4.add(myMethod, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPackagePanel = new JPanel(); + myPackagePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.add(myPackagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPackage.setEnabled(true); + myPackage.setLabelLocation("West"); + myPackage.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.package.label")); + myPackage.setVisible(true); + myPackagePanel.add(myPackage, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPattern = new LabeledComponentNoThrow(); + myPattern.setComponentClass("javax.swing.JPanel"); + myPattern.setLabelLocation("West"); + myPattern.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "pattern.label")); + myPattern.setVisible(true); + panel4.add(myPattern, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClass = new LabeledComponentNoThrow(); + myClass.setLabelLocation("West"); + myClass.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.class.label")); + panel4.add(myClass, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCategory.setLabelLocation("West"); + myCategory.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "category.label")); + panel4.add(myCategory, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUniqueIdField = new LabeledComponentNoThrow(); + myUniqueIdField.setComponentClass("com.intellij.ui.RawCommandLineEditor"); + myUniqueIdField.setLabelLocation("West"); + myUniqueIdField.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "uniqueid.label")); + panel4.add(myUniqueIdField, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDir = new LabeledComponentNoThrow(); + myDir.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton"); + myDir.setLabelLocation("West"); + myDir.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "directory.label")); + panel4.add(myDir, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myChangeListLabeledComponent = new LabeledComponentNoThrow(); + myChangeListLabeledComponent.setComponentClass("javax.swing.JComboBox"); + myChangeListLabeledComponent.setLabelLocation("West"); + myChangeListLabeledComponent.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "change.list.label")); + panel4.add(myChangeListLabeledComponent, + new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myScopesPanel = new JPanel(); + myScopesPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel4.add(myScopesPanel, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + mySearchForTestsLabel = new JBLabel(); + this.$$$loadLabelText$$$(mySearchForTestsLabel, + this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.search.for.tests.label")); + myScopesPanel.add(mySearchForTestsLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myWholeProjectScope = new JRadioButton(); + this.$$$loadButtonText$$$(myWholeProjectScope, + this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.in.whole.project.radio")); + myScopesPanel.add(myWholeProjectScope, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + myScopesPanel.add(spacer5, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mySingleModuleScope = new JRadioButton(); + this.$$$loadButtonText$$$(mySingleModuleScope, + this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "junit.configuration.in.single.module.radio")); + myScopesPanel.add(mySingleModuleScope, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myModuleWDScope = new JRadioButton(); + this.$$$loadButtonText$$$(myModuleWDScope, this.$$$getMessageFromBundle$$$("messages/JUnitBundle", + "junit.configuration.across.module.dependencies.radio")); + myScopesPanel.add(myModuleWDScope, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTagsField = new LabeledComponentNoThrow(); + myTagsField.setComponentClass("com.intellij.ui.RawCommandLineEditor"); + myTagsField.setLabelLocation("West"); + myTagsField.setText(this.$$$getMessageFromBundle$$$("messages/JUnitBundle", "tag.expression.label")); + panel4.add(myTagsField, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestLabel.setLabelFor(myTypeChooser); + label1.setLabelFor(myRepeatCb); + } myModel = new JUnitConfigurationModel(project); myModuleSelector = new ConfigurationModuleSelector(project, getModulesComponent()); myJrePathEditor.setDefaultJreSelector(DefaultJreSelector.fromModuleDependencies(getModulesComponent(), false)); @@ -198,19 +465,20 @@ public class JUnitConfigurable extends SettingsEdi FileChooserFactory.getInstance().installFileCompletion(textField, dirFileChooser, true, null); // Done - myBrowsers = createBrowsers(project, myModuleSelector, myPackage.getComponent(), myPatternTextField, myCategory.getComponent(), () -> getClassName()); + myBrowsers = createBrowsers(project, myModuleSelector, myPackage.getComponent(), myPatternTextField, myCategory.getComponent(), + () -> getClassName()); myModel.setListener((oldType, newType) -> onTypeChanged(newType)); myTypeChooser.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Integer item = (Integer)myTypeChooser.getSelectedItem(); - if (item != null) { - myModel.setType(item); - changePanel(); - } - } - } + @Override + public void actionPerformed(ActionEvent e) { + Integer item = (Integer)myTypeChooser.getSelectedItem(); + if (item != null) { + myModel.setType(item); + changePanel(); + } + } + } ); myModel.setType(JUnitConfigurationModel.CLASS); @@ -244,6 +512,78 @@ public class JUnitConfigurable extends SettingsEdi myUseModulePath.getComponent().setSelected(true); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + private void addListeners() { myRepeatCb.addActionListener(new ActionListener() { @Override @@ -397,15 +737,18 @@ public class JUnitConfigurable extends SettingsEdi myShortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine()); myUseModulePath.getComponent().setSelected(configuration.isUseModulePath()); if (!myProject.isDefault()) { - SwingUtilities.invokeLater(() -> - ReadAction.nonBlocking(() -> FilenameIndex.getFilesByName(myProject, PsiJavaModule.MODULE_INFO_FILE, GlobalSearchScope.projectScope(myProject)).length > 0) - .expireWith(this) - .finishOnUiThread(ModalityState.stateForComponent(myUseModulePath), visible -> myUseModulePath.setVisible(visible)) - .submit(NonUrgentExecutor.getInstance())); + SwingUtilities.invokeLater(() -> + ReadAction.nonBlocking(() -> FilenameIndex.getFilesByName(myProject, PsiJavaModule.MODULE_INFO_FILE, + GlobalSearchScope.projectScope( + myProject)).length > 0) + .expireWith(this) + .finishOnUiThread(ModalityState.stateForComponent(myUseModulePath), + visible -> myUseModulePath.setVisible(visible)) + .submit(NonUrgentExecutor.getInstance())); } } - private void changePanel () { + private void changePanel() { final Integer selectedType = (Integer)myTypeChooser.getSelectedItem(); if (selectedType == null) return; myPackagePanel.setVisible(selectedType == JUnitConfigurationModel.ALL_IN_PACKAGE); @@ -488,7 +831,6 @@ public class JUnitConfigurable extends SettingsEdi field = myPatternTextField; document = new PlainDocument(); ((TextFieldWithBrowseButton)field).getTextField().setDocument((Document)document); - } myBrowsers[i].setField(field); if (myBrowsers[i] instanceof MethodBrowser) { @@ -504,29 +846,6 @@ public class JUnitConfigurable extends SettingsEdi return myTestLocations[index]; } - private void createUIComponents() { - myPackage = new LabeledComponent<>(); - myPackage.setComponent(new EditorTextFieldWithBrowseButton(myProject, false)); - - myCategory = new LabeledComponent<>(); - myCategory.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() { - @Override - public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) { - if (declaration instanceof PsiClass) { - return Visibility.VISIBLE; - } - return Visibility.NOT_VISIBLE; - } - })); - - myMethod = new LabeledComponent<>(); - myMethod.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, - JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, - PlainTextLanguage.INSTANCE.getAssociatedFileType())); - - myShortenClasspathModeCombo = new LabeledComponent<>(); - } - public static @NotNull JavaCodeFragment.VisibilityChecker createClassVisibilityChecker(TestClassBrowser classBrowser) { return new JavaCodeFragment.VisibilityChecker() { @Override @@ -570,15 +889,17 @@ public class JUnitConfigurable extends SettingsEdi public void onTypeChanged(final int newType) { myTypeChooser.setSelectedItem(newType); final IntList enabledFields = ourEnabledFields.size() > newType ? ourEnabledFields.get(newType) : null; - for (int i = 0; i < myTestLocations.length; i++) + for (int i = 0; i < myTestLocations.length; i++) { getTestLocation(i).setEnabled(enabledFields != null && enabledFields.contains(i)); + } /*if (newType == JUnitConfigurationModel.PATTERN) { myModule.setEnabled(false); - } else */if (newType != JUnitConfigurationModel.ALL_IN_PACKAGE && - newType != JUnitConfigurationModel.PATTERN && - newType != JUnitConfigurationModel.CATEGORY && - newType != JUnitConfigurationModel.TAGS && - newType != JUnitConfigurationModel.UNIQUE_ID) { + } else */ + if (newType != JUnitConfigurationModel.ALL_IN_PACKAGE && + newType != JUnitConfigurationModel.PATTERN && + newType != JUnitConfigurationModel.CATEGORY && + newType != JUnitConfigurationModel.TAGS && + newType != JUnitConfigurationModel.UNIQUE_ID) { myModule.setEnabled(true); } else { @@ -692,7 +1013,8 @@ public class JUnitConfigurable extends SettingsEdi } final ClassFilter.ClassFilterWithScope classFilter; try { - final JUnitConfiguration configurationCopy = new JUnitConfiguration(JUnitBundle.message("default.junit.configuration.name"), getProject()); + final JUnitConfiguration configurationCopy = + new JUnitConfiguration(JUnitBundle.message("default.junit.configuration.name"), getProject()); myModuleSelector.applyTo(configurationCopy); SourceScope sourceScope = SourceScope.modulesWithDependencies(configurationCopy.getModules()); GlobalSearchScope globalSearchScope = sourceScope.getGlobalSearchScope(); @@ -705,7 +1027,7 @@ public class JUnitConfigurable extends SettingsEdi @Override public boolean isAccepted(PsiClass aClass) { - return JUnitUtil.isTestClass(aClass,true, true); + return JUnitUtil.isTestClass(aClass, true, true); } }; } diff --git a/plugins/kotlin/base/compiler-configuration-ui/src/org/jetbrains/kotlin/idea/base/compilerPreferences/configuration/KotlinCompilerConfigurableTab.java b/plugins/kotlin/base/compiler-configuration-ui/src/org/jetbrains/kotlin/idea/base/compilerPreferences/configuration/KotlinCompilerConfigurableTab.java index 4cd5d9b0db47..5a8f0f939dc1 100644 --- a/plugins/kotlin/base/compiler-configuration-ui/src/org/jetbrains/kotlin/idea/base/compilerPreferences/configuration/KotlinCompilerConfigurableTab.java +++ b/plugins/kotlin/base/compiler-configuration-ui/src/org/jetbrains/kotlin/idea/base/compilerPreferences/configuration/KotlinCompilerConfigurableTab.java @@ -22,10 +22,14 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.MutableCollectionComboBoxModel; import com.intellij.ui.PopupMenuListenerAdapter; import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.VersionComparatorUtil; import com.intellij.util.ui.ThreeStateCheckBox; @@ -76,13 +80,20 @@ import org.jetbrains.kotlin.platform.impl.JsIdePlatformUtil; import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind; import org.jetbrains.kotlin.platform.jvm.JdkPlatform; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.PopupMenuEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -90,6 +101,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.ResourceBundle; import java.util.SortedSet; import java.util.TreeSet; import java.util.function.Consumer; @@ -101,891 +113,1197 @@ import static com.intellij.openapi.options.Configurable.isFieldModified; import static org.jetbrains.kotlin.idea.base.compilerPreferences.facet.DescriptionListCellRendererKt.createDescriptionAwareRenderer; public class KotlinCompilerConfigurableTab implements SearchableConfigurable { - private static final Logger LOG = Logger.getInstance(KotlinCompilerConfigurableTab.class); - private static final Map moduleKindDescriptions = new LinkedHashMap<>(); - private static final Map sourceMapSourceEmbeddingDescriptions = new LinkedHashMap<>(); - private static final int MAX_WARNING_SIZE = 75; + private static final Logger LOG = Logger.getInstance(KotlinCompilerConfigurableTab.class); + private static final Map moduleKindDescriptions = new LinkedHashMap<>(); + private static final Map sourceMapSourceEmbeddingDescriptions = new LinkedHashMap<>(); + private static final int MAX_WARNING_SIZE = 75; - static { - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, - KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.plain.put.to.global.scope")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_AMD, KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.amd")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_COMMONJS, KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.commonjs")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, KotlinBaseCompilerConfigurationUiBundle.message( - "configuration.description.umd.detect.amd.or.commonjs.if.available.fallback.to.plain")); + static { + moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.plain.put.to.global.scope")); + moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_AMD, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.amd")); + moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_COMMONJS, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.commonjs")); + moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, KotlinBaseCompilerConfigurationUiBundle.message( + "configuration.description.umd.detect.amd.or.commonjs.if.available.fallback.to.plain")); - sourceMapSourceEmbeddingDescriptions - .put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.never")); - sourceMapSourceEmbeddingDescriptions - .put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.always")); - sourceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, KotlinBaseCompilerConfigurationUiBundle.message( - "configuration.description.when.inlining.a.function.from.other.module.with.embedded.sources")); - } + sourceMapSourceEmbeddingDescriptions + .put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.never")); + sourceMapSourceEmbeddingDescriptions + .put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.description.always")); + sourceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, + KotlinBaseCompilerConfigurationUiBundle.message( + "configuration.description.when.inlining.a.function.from.other.module.with.embedded.sources")); + } - private final @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings; - private final Project project; - private final boolean isProjectSettings; - private CommonCompilerArguments commonCompilerArguments; - private K2JSCompilerArguments k2jsCompilerArguments; - private K2JVMCompilerArguments k2jvmCompilerArguments; - private CompilerSettings compilerSettings; - private final @Nullable JpsPluginSettings jpsPluginSettings; - private JPanel contentPane; - private ThreeStateCheckBox reportWarningsCheckBox; - private RawCommandLineEditor additionalArgsOptionsField; - private JLabel additionalArgsLabel; - private ThreeStateCheckBox generateSourceMapsCheckBox; - private JLabel labelForOutputDirectory; - private TextFieldWithBrowseButton outputDirectory; - private ThreeStateCheckBox copyRuntimeFilesCheckBox; - private ThreeStateCheckBox keepAliveCheckBox; - private JCheckBox enableIncrementalCompilationForJvmCheckBox; - private JCheckBox enableIncrementalCompilationForJsCheckBox; - private JComboBox moduleKindComboBox; - private JPanel k2jvmPanel; - private JPanel k2jsPanel; - private JComboBox jvmVersionComboBox; - private JPanel kotlinJpsPluginVersionPanel; - private JComboBox kotlinJpsPluginVersionComboBox; - private ComboBoxModelWithPossiblyDisabledItems jpsPluginComboBoxModel; - private JpsVersionItem defaultJpsVersionItem; - private JComboBox languageVersionComboBox; - private JComboBox apiVersionComboBox; - private JLabel warningLabel; - private JTextField sourceMapPrefix; - private JComboBox sourceMapEmbedSources; - private boolean isEnabled = true; + private final @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings; + private final Project project; + private final boolean isProjectSettings; + private CommonCompilerArguments commonCompilerArguments; + private K2JSCompilerArguments k2jsCompilerArguments; + private K2JVMCompilerArguments k2jvmCompilerArguments; + private CompilerSettings compilerSettings; + private final @Nullable JpsPluginSettings jpsPluginSettings; + private final JPanel contentPane; + private final ThreeStateCheckBox reportWarningsCheckBox; + private final RawCommandLineEditor additionalArgsOptionsField; + private final JLabel additionalArgsLabel; + private final ThreeStateCheckBox generateSourceMapsCheckBox; + private final JLabel labelForOutputDirectory; + private final TextFieldWithBrowseButton outputDirectory; + private final ThreeStateCheckBox copyRuntimeFilesCheckBox; + private final ThreeStateCheckBox keepAliveCheckBox; + private final JCheckBox enableIncrementalCompilationForJvmCheckBox; + private final JCheckBox enableIncrementalCompilationForJsCheckBox; + private final JComboBox moduleKindComboBox; + private final JPanel k2jvmPanel; + private final JPanel k2jsPanel; + private final JComboBox jvmVersionComboBox; + private final JPanel kotlinJpsPluginVersionPanel; + private final JComboBox kotlinJpsPluginVersionComboBox; + private ComboBoxModelWithPossiblyDisabledItems jpsPluginComboBoxModel; + private JpsVersionItem defaultJpsVersionItem; + private final JComboBox languageVersionComboBox; + private final JComboBox apiVersionComboBox; + private final JLabel warningLabel; + private final JTextField sourceMapPrefix; + private final JComboBox sourceMapEmbedSources; + private boolean isEnabled = true; - private @Nullable Disposable validatorsDisposable = null; + private @Nullable Disposable validatorsDisposable = null; - public KotlinCompilerConfigurableTab( - Project project, - @NotNull CommonCompilerArguments commonCompilerArguments, - @NotNull K2JSCompilerArguments k2jsCompilerArguments, - @NotNull K2JVMCompilerArguments k2jvmCompilerArguments, - @NotNull CompilerSettings compilerSettings, - @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings, - boolean isProjectSettings, - boolean isMultiEditor - ) { - this.project = project; - this.commonCompilerArguments = commonCompilerArguments; - this.k2jsCompilerArguments = k2jsCompilerArguments; - this.compilerSettings = compilerSettings; - this.jpsPluginSettings = Optional.ofNullable(isProjectSettings ? KotlinJpsPluginSettings.getInstance(project) : null) - .map(KotlinJpsPluginSettings::getSettings) - .map(FreezableKt::unfrozen) - .orElse(null); - this.compilerWorkspaceSettings = compilerWorkspaceSettings; - this.k2jvmCompilerArguments = k2jvmCompilerArguments; - this.isProjectSettings = isProjectSettings; + public KotlinCompilerConfigurableTab( + Project project, + @NotNull CommonCompilerArguments commonCompilerArguments, + @NotNull K2JSCompilerArguments k2jsCompilerArguments, + @NotNull K2JVMCompilerArguments k2jvmCompilerArguments, + @NotNull CompilerSettings compilerSettings, + @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings, + boolean isProjectSettings, + boolean isMultiEditor + ) { + this.project = project; + this.commonCompilerArguments = commonCompilerArguments; + this.k2jsCompilerArguments = k2jsCompilerArguments; + this.compilerSettings = compilerSettings; + { + // Explicit use of MutableCollectionComboBoxModel guarantees that setSelectedItem() can make safe cast. + languageVersionComboBox = new ComboBox<>(new MutableCollectionComboBoxModel<>()); + jpsPluginComboBoxModel = new ComboBoxModelWithPossiblyDisabledItems(); + kotlinJpsPluginVersionComboBox = new ComboBox<>(jpsPluginComboBoxModel); + apiVersionComboBox = new ComboBox<>(new MutableCollectionComboBoxModel<>()); - warningLabel.setIcon(AllIcons.General.WarningDialog); - - additionalArgsOptionsField.attachLabel(additionalArgsLabel); - if (isJpsCompilerVisible()) { - kotlinJpsPluginVersionComboBox.addActionListener( - e -> onLanguageLevelChanged(getSelectedKotlinJpsPluginVersionView())); + // Workaround: ThreeStateCheckBox doesn't send suitable notification on state change + // TODO: replace with PropertyChangerListener after fix is available in IDEA + copyRuntimeFilesCheckBox = new ThreeStateCheckBox() { + @Override + public void setState(State state) { + super.setState(state); + updateOutputDirEnabled(); } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(12, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, new GridConstraints(11, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + k2jsPanel = new JPanel(); + k2jsPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + k2jsPanel.setVisible(true); + k2jsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + contentPane.add(k2jsPanel, new GridConstraints(9, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, true)); + k2jsPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.js.option.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + labelForOutputDirectory = new JLabel(); + this.$$$loadLabelText$$$(labelForOutputDirectory, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "destination.directory")); + k2jsPanel.add(labelForOutputDirectory, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 2, false)); + outputDirectory = new TextFieldWithBrowseButton(); + outputDirectory.setText(this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "kotlin.compiler.lib")); + k2jsPanel.add(outputDirectory, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + copyRuntimeFilesCheckBox.setState(ThreeStateCheckBox.State.NOT_SELECTED); + this.$$$loadButtonText$$$(copyRuntimeFilesCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.js.option.output.copy.files")); + k2jsPanel.add(copyRuntimeFilesCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "module.kind")); + k2jsPanel.add(label1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + moduleKindComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + moduleKindComboBox.setModel(defaultComboBoxModel1); + k2jsPanel.add(moduleKindComboBox, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + generateSourceMapsCheckBox = new ThreeStateCheckBox(); + generateSourceMapsCheckBox.setState(ThreeStateCheckBox.State.NOT_SELECTED); + this.$$$loadButtonText$$$(generateSourceMapsCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.js.option.generate.sourcemaps")); + k2jsPanel.add(generateSourceMapsCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + sourceMapPrefix = new JTextField(); + k2jsPanel.add(sourceMapPrefix, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "embed.source.code.into.source.map")); + k2jsPanel.add(label2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + sourceMapEmbedSources = new JComboBox(); + k2jsPanel.add(sourceMapEmbedSources, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + enableIncrementalCompilationForJsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(enableIncrementalCompilationForJsCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "enable.incremental.compilation")); + k2jsPanel.add(enableIncrementalCompilationForJsCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + warningLabel = new JLabel(); + warningLabel.setFocusable(false); + warningLabel.setInheritsPopupMenu(false); + warningLabel.setText(""); + warningLabel.setVisible(false); + panel1.add(warningLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + k2jvmPanel = new JPanel(); + k2jvmPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + k2jvmPanel.setVisible(true); + k2jvmPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + contentPane.add(k2jvmPanel, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, true)); + k2jvmPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.jvm.option.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "target.jvm.version")); + k2jvmPanel.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + enableIncrementalCompilationForJvmCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(enableIncrementalCompilationForJvmCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "enable.incremental.compilation")); + k2jvmPanel.add(enableIncrementalCompilationForJvmCheckBox, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jvmVersionComboBox = new JComboBox(); + k2jvmPanel.add(jvmVersionComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, true)); + reportWarningsCheckBox = new ThreeStateCheckBox(); + reportWarningsCheckBox.setSelected(false); + reportWarningsCheckBox.setState(ThreeStateCheckBox.State.NOT_SELECTED); + this.$$$loadButtonText$$$(reportWarningsCheckBox, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.option.generate.no.warnings")); + panel2.add(reportWarningsCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + kotlinJpsPluginVersionPanel = new JPanel(); + kotlinJpsPluginVersionPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(kotlinJpsPluginVersionPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, true)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.version")); + kotlinJpsPluginVersionPanel.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + kotlinJpsPluginVersionPanel.add(kotlinJpsPluginVersionComboBox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, true)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "language.version")); + panel3.add(label5, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel3.add(languageVersionComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel4, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, true)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "api.version")); + panel4.add(label6, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel4.add(apiVersionComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + additionalArgsLabel = new JLabel(); + this.$$$loadLabelText$$$(additionalArgsLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "kotlin.compiler.option.additional.command.line.parameters")); + contentPane.add(additionalArgsLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + additionalArgsOptionsField = new RawCommandLineEditor(); + additionalArgsOptionsField.setDialogCaption( + this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", "additional.command.line.parameters")); + contentPane.add(additionalArgsOptionsField, + new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + keepAliveCheckBox = new ThreeStateCheckBox(); + keepAliveCheckBox.setState(ThreeStateCheckBox.State.NOT_SELECTED); + this.$$$loadButtonText$$$(keepAliveCheckBox, this.$$$getMessageFromBundle$$$("messages/KotlinBaseCompilerConfigurationUiBundle", + "keep.compiler.process.alive.between.invocations")); + contentPane.add(keepAliveCheckBox, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(moduleKindComboBox); + } + this.jpsPluginSettings = Optional.ofNullable(isProjectSettings ? KotlinJpsPluginSettings.getInstance(project) : null) + .map(KotlinJpsPluginSettings::getSettings) + .map(FreezableKt::unfrozen) + .orElse(null); + this.compilerWorkspaceSettings = compilerWorkspaceSettings; + this.k2jvmCompilerArguments = k2jvmCompilerArguments; + this.isProjectSettings = isProjectSettings; - fillVersions(); + warningLabel.setIcon(AllIcons.General.WarningDialog); - if (KotlinPlatformUtils.isCidr()) { - keepAliveCheckBox.setVisible(false); - k2jvmPanel.setVisible(false); - k2jsPanel.setVisible(false); - } else { - initializeNonCidrSettings(isMultiEditor); + additionalArgsOptionsField.attachLabel(additionalArgsLabel); + if (isJpsCompilerVisible()) { + kotlinJpsPluginVersionComboBox.addActionListener( + e -> onLanguageLevelChanged(getSelectedKotlinJpsPluginVersionView())); + } + + fillVersions(); + + if (KotlinPlatformUtils.isCidr()) { + keepAliveCheckBox.setVisible(false); + k2jvmPanel.setVisible(false); + k2jsPanel.setVisible(false); + } + else { + initializeNonCidrSettings(isMultiEditor); + } + + reportWarningsCheckBox.setThirdStateEnabled(isMultiEditor); + + if (isProjectSettings) { + List modulesOverridingProjectSettings = ArraysKt.mapNotNull( + ModuleManager.getInstance(project).getModules(), + module -> { + KotlinFacet facet = KotlinFacet.Companion.get(module); + if (facet == null) return null; + IKotlinFacetSettings facetSettings = facet.getConfiguration().getSettings(); + if (facetSettings.getUseProjectSettings()) return null; + return module.getName(); } + ); + CollectionsKt.sort(modulesOverridingProjectSettings); + if (!modulesOverridingProjectSettings.isEmpty()) { + warningLabel.setVisible(true); + warningLabel.setText(buildOverridingModulesWarning(modulesOverridingProjectSettings)); + } + } + } - reportWarningsCheckBox.setThirdStateEnabled(isMultiEditor); + @SuppressWarnings("unused") // Empty constructor fixes 'Extension should not have constructor with parameters (except Project)' + public KotlinCompilerConfigurableTab(Project project) { + this(project, + FreezableKt.unfrozen(KotlinCommonCompilerArgumentsHolder.getInstance(project).getSettings()), + FreezableKt.unfrozen(Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings()), + FreezableKt.unfrozen(Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings()), + FreezableKt.unfrozen(KotlinCompilerSettings.getInstance(project).getSettings()), + KotlinCompilerWorkspaceSettings.getInstance(project), + true, + false); + } - if (isProjectSettings) { - List modulesOverridingProjectSettings = ArraysKt.mapNotNull( - ModuleManager.getInstance(project).getModules(), - module -> { - KotlinFacet facet = KotlinFacet.Companion.get(module); - if (facet == null) return null; - IKotlinFacetSettings facetSettings = facet.getConfiguration().getSettings(); - if (facetSettings.getUseProjectSettings()) return null; - return module.getName(); - } - ); - CollectionsKt.sort(modulesOverridingProjectSettings); - if (!modulesOverridingProjectSettings.isEmpty()) { - warningLabel.setVisible(true); - warningLabel.setText(buildOverridingModulesWarning(modulesOverridingProjectSettings)); - } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } + } + result.append(text.charAt(i)); } - - @SuppressWarnings("unused") // Empty constructor fixes 'Extension should not have constructor with parameters (except Project)' - public KotlinCompilerConfigurableTab(Project project) { - this(project, - FreezableKt.unfrozen(KotlinCommonCompilerArgumentsHolder.getInstance(project).getSettings()), - FreezableKt.unfrozen(Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings()), - FreezableKt.unfrozen(Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings()), - FreezableKt.unfrozen(KotlinCompilerSettings.getInstance(project).getSettings()), - KotlinCompilerWorkspaceSettings.getInstance(project), - true, - false); + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - private void initializeNonCidrSettings(boolean isMultiEditor) { - setupFileChooser(labelForOutputDirectory, outputDirectory, - KotlinBaseCompilerConfigurationUiBundle.message("configuration.title.choose.output.directory"), - false); - - fillModuleKindList(); - fillSourceMapSourceEmbeddingList(); - fillJvmVersionList(); - - generateSourceMapsCheckBox.setThirdStateEnabled(isMultiEditor); - generateSourceMapsCheckBox.addActionListener(event -> sourceMapPrefix.setEnabled(generateSourceMapsCheckBox.isSelected())); - - copyRuntimeFilesCheckBox.setThirdStateEnabled(isMultiEditor); - keepAliveCheckBox.setThirdStateEnabled(isMultiEditor); - - if (compilerWorkspaceSettings == null) { - keepAliveCheckBox.setVisible(false); - k2jvmPanel.setVisible(false); - enableIncrementalCompilationForJsCheckBox.setVisible(false); + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } - updateOutputDirEnabled(); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + + private void initializeNonCidrSettings(boolean isMultiEditor) { + setupFileChooser(labelForOutputDirectory, outputDirectory, + KotlinBaseCompilerConfigurationUiBundle.message("configuration.title.choose.output.directory"), + false); + + fillModuleKindList(); + fillSourceMapSourceEmbeddingList(); + fillJvmVersionList(); + + generateSourceMapsCheckBox.setThirdStateEnabled(isMultiEditor); + generateSourceMapsCheckBox.addActionListener(event -> sourceMapPrefix.setEnabled(generateSourceMapsCheckBox.isSelected())); + + copyRuntimeFilesCheckBox.setThirdStateEnabled(isMultiEditor); + keepAliveCheckBox.setThirdStateEnabled(isMultiEditor); + + if (compilerWorkspaceSettings == null) { + keepAliveCheckBox.setVisible(false); + k2jvmPanel.setVisible(false); + enableIncrementalCompilationForJsCheckBox.setVisible(false); } - private static int calculateNameCountToShowInWarning(List allNames) { - int lengthSoFar = 0; - int size = allNames.size(); - for (int i = 0; i < size; i++) { - lengthSoFar = (i > 0 ? lengthSoFar + 2 : 0) + allNames.get(i).length(); - if (lengthSoFar > MAX_WARNING_SIZE) return i; + updateOutputDirEnabled(); + } + + private static int calculateNameCountToShowInWarning(List allNames) { + int lengthSoFar = 0; + int size = allNames.size(); + for (int i = 0; i < size; i++) { + lengthSoFar = (i > 0 ? lengthSoFar + 2 : 0) + allNames.get(i).length(); + if (lengthSoFar > MAX_WARNING_SIZE) return i; + } + return size; + } + + private static @NotNull @NlsSafe String buildOverridingModulesWarning(List modulesOverridingProjectSettings) { + int nameCountToShow = calculateNameCountToShowInWarning(modulesOverridingProjectSettings); + int allNamesCount = modulesOverridingProjectSettings.size(); + if (nameCountToShow == 0) { + return KotlinBaseCompilerConfigurationUiBundle.message("configuration.warning.text.modules.override.project.settings", + String.valueOf(allNamesCount)); + } + + StringBuilder builder = new StringBuilder(); + builder.append(""); + builder.append( + KotlinBaseCompilerConfigurationUiBundle.message("configuration.warning.text.following.modules.override.project.settings")) + .append(" "); + CollectionsKt.joinTo( + modulesOverridingProjectSettings.subList(0, nameCountToShow), + builder, + ", ", + "", + "", + -1, + "", + new Function1<>() { + @Override + public CharSequence invoke(String s) { + return "" + s + ""; } - return size; + } + ); + if (nameCountToShow < allNamesCount) { + builder.append(" ").append(KotlinBaseCompilerConfigurationUiBundle.message("configuration.text.and")).append(" ") + .append(allNamesCount - nameCountToShow) + .append(" ").append(KotlinBaseCompilerConfigurationUiBundle.message("configuration.text.other.s")); + } + return builder.toString(); + } + + @Nls + private static @NotNull + String getModuleKindDescription(@Nullable String moduleKind) { + if (moduleKind == null) return ""; + String result = moduleKindDescriptions.get(moduleKind); + assert result != null : "Module kind " + moduleKind + " was not added to combobox, therefore it should not be here"; + return result; + } + + @Nls + private static @NotNull + String getSourceMapSourceEmbeddingDescription(@Nullable String sourceMapSourceEmbeddingId) { + if (sourceMapSourceEmbeddingId == null) return ""; + String result = sourceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId); + assert result != null : "Source map source embedding mode " + sourceMapSourceEmbeddingId + + " was not added to combobox, therefore it should not be here"; + return result; + } + + private static @NotNull @NlsSafe String getModuleKindOrDefault(@Nullable String moduleKindId) { + if (moduleKindId == null) { + moduleKindId = K2JsArgumentConstants.MODULE_PLAIN; + } + return moduleKindId; + } + + private static @NotNull @NlsSafe String getSourceMapSourceEmbeddingOrDefault(@Nullable String sourceMapSourceEmbeddingId) { + if (sourceMapSourceEmbeddingId == null) { + sourceMapSourceEmbeddingId = K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING; + } + return sourceMapSourceEmbeddingId; + } + + private static @NlsSafe String getJvmVersionOrDefault(@Nullable String jvmVersion) { + return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription(); + } + + private static void setupFileChooser( + @NotNull JLabel label, + @NotNull TextFieldWithBrowseButton fileChooser, + @NotNull @NlsContexts.DialogTitle String title, + boolean forFiles + ) { + label.setLabelFor(fileChooser); + var descriptor = new FileChooserDescriptor(forFiles, !forFiles, false, false, false, false).withTitle(title); + fileChooser.addBrowseFolderListener(null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); + } + + private static boolean isBrowseFieldModified(@NotNull TextFieldWithBrowseButton chooser, @NotNull String currentValue) { + return !StringUtil.equals(chooser.getText(), currentValue); + } + + private void updateOutputDirEnabled() { + if (isEnabled && copyRuntimeFilesCheckBox != null) { + outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); + labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); + } + } + + private static boolean isLessOrEqual(LanguageOrApiVersion version, LanguageOrApiVersion upperBound) { + return VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0; + } + + public void onLanguageLevelChanged(@Nullable VersionView languageLevel) { + if (languageLevel == null) return; + restrictAPIVersions(languageLevel); + } + + private void restrictAPIVersions(VersionView upperBoundView) { + VersionView selectedAPIView = getSelectedAPIVersionView(); + LanguageOrApiVersion selectedAPIVersion = selectedAPIView.getVersion(); + LanguageOrApiVersion upperBound = upperBoundView.getVersion(); + EnumEntries languageVersions = LanguageVersion.getEntries(); + List permittedAPIVersions = new ArrayList<>(languageVersions.size()); + + final VersionView latestStable = getLatestStableVersion(); + + int index = 0; + int latestStableIndex = languageVersions.size(); + for (LanguageVersion version : languageVersions) { + if (index > latestStableIndex) { + break; + } + ApiVersion apiVersion = ApiVersion.createByLanguageVersion(version); + if (!isLessOrEqual(apiVersion, upperBound) && (index < latestStableIndex)) { + latestStableIndex = index; + } + if (!apiVersion.isUnsupported()) { + permittedAPIVersions.add(new VersionView.Specific(version)); + } + index++; } - private static @NotNull @NlsSafe String buildOverridingModulesWarning(List modulesOverridingProjectSettings) { - int nameCountToShow = calculateNameCountToShowInWarning(modulesOverridingProjectSettings); - int allNamesCount = modulesOverridingProjectSettings.size(); - if (nameCountToShow == 0) { - return KotlinBaseCompilerConfigurationUiBundle.message("configuration.warning.text.modules.override.project.settings", String.valueOf(allNamesCount)); - } - - StringBuilder builder = new StringBuilder(); - builder.append(""); - builder.append(KotlinBaseCompilerConfigurationUiBundle.message("configuration.warning.text.following.modules.override.project.settings")).append(" "); - CollectionsKt.joinTo( - modulesOverridingProjectSettings.subList(0, nameCountToShow), - builder, - ", ", - "", - "", - -1, - "", - new Function1<>() { - @Override - public CharSequence invoke(String s) { - return "" + s + ""; - } - } - ); - if (nameCountToShow < allNamesCount) { - builder.append(" ").append(KotlinBaseCompilerConfigurationUiBundle.message("configuration.text.and")).append(" ").append(allNamesCount - nameCountToShow) - .append(" ").append(KotlinBaseCompilerConfigurationUiBundle.message("configuration.text.other.s")); - } - return builder.toString(); + if (isLessOrEqual(latestStable.getVersion(), upperBound) && !permittedAPIVersions.contains(latestStable)) { + permittedAPIVersions.add(latestStable); } - @Nls - private static @NotNull - String getModuleKindDescription(@Nullable String moduleKind) { - if (moduleKind == null) return ""; - String result = moduleKindDescriptions.get(moduleKind); - assert result != null : "Module kind " + moduleKind + " was not added to combobox, therefore it should not be here"; - return result; + apiVersionComboBox.setModel(new MutableCollectionComboBoxModel<>(permittedAPIVersions)); + languageVersionComboBox.setModel(new MutableCollectionComboBoxModel<>(permittedAPIVersions)); + + VersionView selectedItem = + VersionComparatorUtil.compare(selectedAPIVersion.getVersionString(), upperBound.getVersionString()) <= 0 + ? selectedAPIView + : upperBoundView; + apiVersionComboBox.setSelectedItem(selectedItem); + if (isJpsCompilerVisible()) { + languageVersionComboBox.setSelectedItem(selectedItem); } - - @Nls - private static @NotNull - String getSourceMapSourceEmbeddingDescription(@Nullable String sourceMapSourceEmbeddingId) { - if (sourceMapSourceEmbeddingId == null) return ""; - String result = sourceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId); - assert result != null : "Source map source embedding mode " + sourceMapSourceEmbeddingId + - " was not added to combobox, therefore it should not be here"; - return result; - } - - private static @NotNull @NlsSafe String getModuleKindOrDefault(@Nullable String moduleKindId) { - if (moduleKindId == null) { - moduleKindId = K2JsArgumentConstants.MODULE_PLAIN; - } - return moduleKindId; - } - - private static @NotNull @NlsSafe String getSourceMapSourceEmbeddingOrDefault(@Nullable String sourceMapSourceEmbeddingId) { - if (sourceMapSourceEmbeddingId == null) { - sourceMapSourceEmbeddingId = K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING; - } - return sourceMapSourceEmbeddingId; - } - - private static @NlsSafe String getJvmVersionOrDefault(@Nullable String jvmVersion) { - return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription(); - } - - private static void setupFileChooser( - @NotNull JLabel label, - @NotNull TextFieldWithBrowseButton fileChooser, - @NotNull @NlsContexts.DialogTitle String title, - boolean forFiles - ) { - label.setLabelFor(fileChooser); - var descriptor = new FileChooserDescriptor(forFiles, !forFiles, false, false, false, false).withTitle(title); - fileChooser.addBrowseFolderListener(null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); - } - - private static boolean isBrowseFieldModified(@NotNull TextFieldWithBrowseButton chooser, @NotNull String currentValue) { - return !StringUtil.equals(chooser.getText(), currentValue); - } - - private void updateOutputDirEnabled() { - if (isEnabled && copyRuntimeFilesCheckBox != null) { - outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); - labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); - } - } - - private static boolean isLessOrEqual(LanguageOrApiVersion version, LanguageOrApiVersion upperBound) { - return VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0; - } - - public void onLanguageLevelChanged(@Nullable VersionView languageLevel) { - if (languageLevel == null) return; - restrictAPIVersions(languageLevel); - } - - private void restrictAPIVersions(VersionView upperBoundView) { - VersionView selectedAPIView = getSelectedAPIVersionView(); - LanguageOrApiVersion selectedAPIVersion = selectedAPIView.getVersion(); - LanguageOrApiVersion upperBound = upperBoundView.getVersion(); - EnumEntries languageVersions = LanguageVersion.getEntries(); - List permittedAPIVersions = new ArrayList<>(languageVersions.size()); - - final VersionView latestStable = getLatestStableVersion(); - - int index = 0; - int latestStableIndex = languageVersions.size(); - for (LanguageVersion version : languageVersions) { - if (index > latestStableIndex) { - break; - } - ApiVersion apiVersion = ApiVersion.createByLanguageVersion(version); - if (!isLessOrEqual(apiVersion, upperBound) && (index < latestStableIndex)) { - latestStableIndex = index; - } - if (!apiVersion.isUnsupported()) { - permittedAPIVersions.add(new VersionView.Specific(version)); - } - index++; - } - - if (isLessOrEqual(latestStable.getVersion(), upperBound) && !permittedAPIVersions.contains(latestStable)) { - permittedAPIVersions.add(latestStable); - } - - apiVersionComboBox.setModel(new MutableCollectionComboBoxModel<>(permittedAPIVersions)); - languageVersionComboBox.setModel(new MutableCollectionComboBoxModel<>(permittedAPIVersions)); - - VersionView selectedItem = - VersionComparatorUtil.compare(selectedAPIVersion.getVersionString(), upperBound.getVersionString()) <= 0 - ? selectedAPIView - : upperBoundView; - apiVersionComboBox.setSelectedItem(selectedItem); - if (isJpsCompilerVisible()) { - languageVersionComboBox.setSelectedItem(selectedItem); - } - } - - private void fillJvmVersionList() { - for (TargetPlatform jvm : JvmIdePlatformKind.INSTANCE.getPlatforms()) { - JvmTarget jvmTarget = PlatformUtilKt.subplatformsOfType(jvm, JdkPlatform.class).get(0).getTargetVersion(); - @NlsSafe String description = jvmTarget.getDescription(); - if (jvmTarget == JvmTarget.JVM_1_6) { - description += " " + KotlinBaseCompilerConfigurationUiBundle.message("deprecated.jvm.version"); - } - - jvmVersionComboBox.addItem(description); - } - } - - private void fetchAvailableJpsCompilersAsync(Consumer> onFinish) { - JarRepositoryManager.getAvailableVersions(project, RepositoryLibraryDescription.findDescription( - KotlinArtifactConstants.KOTLIN_MAVEN_GROUP_ID, KotlinArtifactConstants.KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID)) - .onProcessed(distVersions -> { - if (distVersions == null) { - onFinish.accept(null); - return; - } - JarRepositoryManager.getAvailableVersions(project, RepositoryLibraryDescription.findDescription( - KotlinArtifactConstants.KOTLIN_MAVEN_GROUP_ID, - KotlinArtifactConstants.KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID)) - .onProcessed(jpsClassPathVersions -> { - if (jpsClassPathVersions == null) { - onFinish.accept(null); - return; - } - - KotlinVersion min = KotlinJpsPluginSettings.getJpsMinimumSupportedVersion(); - KotlinVersion max = KotlinJpsPluginSettings.getJpsMaximumSupportedVersion(); - HashSet ideKotlinVersions = new HashSet<>(); - for (String version : distVersions) { - if (!jpsClassPathVersions.contains(version)) continue; - - IdeKotlinVersion parsedVersion = IdeKotlinVersion.opt(version); - if (parsedVersion != null) { - KotlinVersion parsedKotlinVersion = parsedVersion.getKotlinVersion(); - if (parsedKotlinVersion.compareTo(min) >= 0 && parsedKotlinVersion.compareTo(max) <= 0) { - ideKotlinVersions.add(parsedVersion); - } - } - } - - onFinish.accept(ideKotlinVersions); - }); - }); - } - - private boolean isJpsCompilerVisible() { - return isProjectSettings && jpsPluginSettings != null; - } - - private void fillVersions() { - if (isJpsCompilerVisible()) { - defaultJpsVersionItem = JpsVersionItem.createFromRawVersion( - KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings) - ); - - kotlinJpsPluginVersionComboBox.addItem(defaultJpsVersionItem); - - IdeKotlinVersion bundledVersion = KotlinJpsPluginSettings.getBundledVersion(); - IdeKotlinVersion defaultVersion = defaultJpsVersionItem.getVersion(); - Integer compare = defaultVersion != null ? defaultVersion.compareTo(bundledVersion) : null; - if (compare == null || compare > 0) { - jpsPluginComboBoxModel.add(new JpsVersionItem(bundledVersion)); - } else if (compare < 0) { - jpsPluginComboBoxModel.add(0, new JpsVersionItem(bundledVersion)); - } - - JpsVersionItem loadingItem = JpsVersionItem.createLabel(KotlinBaseCompilerConfigurationUiBundle.message("loading.available.versions.from.maven")); - kotlinJpsPluginVersionComboBox.addItem(loadingItem); - PopupMenuListenerAdapter popupListener = new PopupMenuListenerAdapter() { - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - kotlinJpsPluginVersionComboBox.removePopupMenuListener(this); - fetchAvailableJpsCompilersAsync( - availableVersions -> { - kotlinJpsPluginVersionComboBox.removeItem(loadingItem); - if (availableVersions == null) { - kotlinJpsPluginVersionComboBox.addItem( - JpsVersionItem.createLabel( - KotlinBaseCompilerConfigurationUiBundle.message("failed.fetching.all.available.versions.from.maven") - ) - ); - } else { - SortedSet newItems = new TreeSet<>(availableVersions); - for (JpsVersionItem item : jpsPluginComboBoxModel.getItems()) { - IdeKotlinVersion ideKotlinVersion = item.getVersion(); - if (ideKotlinVersion != null) { - newItems.add(ideKotlinVersion); - } - } - - Object selectedItem = jpsPluginComboBoxModel.getSelectedItem(); - jpsPluginComboBoxModel.update( - ContainerUtil.reverse(ContainerUtil.map(newItems, it -> new JpsVersionItem(it)))); - kotlinJpsPluginVersionComboBox.setSelectedItem(selectedItem); - } - - if (kotlinJpsPluginVersionComboBox.isPopupVisible()) { - kotlinJpsPluginVersionComboBox.hidePopup(); - kotlinJpsPluginVersionComboBox.showPopup(); - } - }); - } - }; - - kotlinJpsPluginVersionComboBox.addPopupMenuListener(popupListener); - } else { - kotlinJpsPluginVersionPanel.setVisible(false); - } - - VersionView latestStable = getLatestStableVersion(); - int index = 0; - EnumEntries languageVersions = LanguageVersion.getEntries(); - int latestStableIndex = languageVersions.size(); - for (LanguageVersion languageVersion : languageVersions) { - if (index > latestStableIndex) break; - if (!isLessOrEqual(languageVersion, latestStable.getVersion()) && (index < latestStableIndex)) { - latestStableIndex = index; - } - - if (!languageVersion.isStable()) { - continue; - } - - ApiVersion apiVersion = ApiVersion.createByLanguageVersion(languageVersion); - - if (!apiVersion.isUnsupported()) { - apiVersionComboBox.addItem(new VersionView.Specific(languageVersion)); - } - if (!languageVersion.isUnsupported()) { - languageVersionComboBox.addItem(new VersionView.Specific(languageVersion)); - } - index++; - } - - languageVersionComboBox.setRenderer(createDescriptionAwareRenderer()); - kotlinJpsPluginVersionComboBox.setRenderer(createDescriptionAwareRenderer()); - apiVersionComboBox.setRenderer(createDescriptionAwareRenderer()); - } - - private static VersionView latestStableVersion = null; - - private static VersionView getLatestStableVersion() { - VersionView latestStable = latestStableVersion; - if (latestStable != null) { - return latestStable; - } - - LanguageVersion bundledLanguageVersion = KotlinJpsPluginSettings.getBundledVersion().getLanguageVersion(); - latestStable = VersionView.LatestStable.INSTANCE; - - // workaround to avoid cases when Kotlin plugin bundles the latest compiler with effectively NOT STABLE version. - // Actually, the latest stable version is bundled in jps - for (LanguageVersion languageVersion : LanguageVersion.getEntries()) { - if (languageVersion.compareTo(bundledLanguageVersion) <= 0) { - latestStable = VersionView.Companion.deserialize(languageVersion.getVersionString(), false); - } else { - break; - } - } - - latestStableVersion = latestStable; - return latestStable; - } - - public void setTargetPlatform(@Nullable IdePlatformKind targetPlatform) { - k2jsPanel.setVisible(JsIdePlatformUtil.isJavaScript(targetPlatform)); - } - - private void fillModuleKindList() { - for (@Nls String moduleKind : moduleKindDescriptions.keySet()) { - moduleKindComboBox.addItem(moduleKind); - } - - moduleKindComboBox.setRenderer(BuilderKt.textListCellRenderer("", o -> getModuleKindDescription(o))); - } - - private void fillSourceMapSourceEmbeddingList() { - for (@Nls String moduleKind : sourceMapSourceEmbeddingDescriptions.keySet()) { - sourceMapEmbedSources.addItem(moduleKind); - } - - sourceMapEmbedSources.setRenderer(BuilderKt.textListCellRenderer("", o -> getSourceMapSourceEmbeddingDescription(o))); - } - - @Override - public @NotNull String getId() { - return "project.kotlinCompiler"; - } - - @Override - public @Nullable JComponent createComponent() { - if (validatorsDisposable != null) { - LOG.error(new IllegalStateException("validatorsDisposable is not null. Disposing and rewriting it.")); - Disposer.dispose(validatorsDisposable); - } - validatorsDisposable = Disposer.newDisposable(); - createVersionValidator(languageVersionComboBox, "configuration.warning.text.language.version.unsupported", validatorsDisposable); - createVersionValidator(apiVersionComboBox, "configuration.warning.text.api.version.unsupported", validatorsDisposable); - - return contentPane; - } - - @Override - public boolean isModified() { - return isCheckboxModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) || - !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || - !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || - jpsPluginSettings != null && - !getSelectedKotlinJpsPluginVersion().equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings)) || - !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()) || - isCheckboxModified(copyRuntimeFilesCheckBox, compilerSettings.getCopyJsLibraryFiles()) || - isBrowseFieldModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) || - - (compilerWorkspaceSettings != null && - (isCheckboxModified(enableIncrementalCompilationForJvmCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) || - isCheckboxModified(enableIncrementalCompilationForJsCheckBox, compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()) || - isCheckboxModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || - - isCheckboxModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || - !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())) || - isFieldModified(sourceMapPrefix, StringUtil.notNullize(k2jsCompilerArguments.getSourceMapPrefix())) || - !getSelectedSourceMapSourceEmbedding().equals( - getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())) || - !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); - } - - private @NotNull String getSelectedModuleKind() { - return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem()); - } - - private String getSelectedSourceMapSourceEmbedding() { - return getSourceMapSourceEmbeddingOrDefault((String) sourceMapEmbedSources.getSelectedItem()); - } - - public @NotNull String getSelectedJvmVersion() { - return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem()); - } - - public @NotNull VersionView getSelectedLanguageVersionView() { - Object item = languageVersionComboBox.getSelectedItem(); - return item != null ? (VersionView) item : getLatestStableVersion(); - } - - private @NotNull VersionView getSelectedAPIVersionView() { - Object item = apiVersionComboBox.getSelectedItem(); - return item != null ? (VersionView) item : getLatestStableVersion(); - } - - public VersionView getSelectedKotlinJpsPluginVersionView() { - JpsVersionItem selectedItem = (JpsVersionItem) kotlinJpsPluginVersionComboBox.getSelectedItem(); - IdeKotlinVersion version = selectedItem != null ? selectedItem.getVersion() : null; - LanguageVersion languageVersion = version != null ? LanguageVersion.fromFullVersionString(version.toString()) : null; - VersionView versionView; - if (languageVersion != null) { - versionView = new VersionView.Specific(languageVersion); - } else { - String compilerVersionFromSettings = KotlinJpsPluginSettings.getInstance(project).getSettings().getVersion(); - versionView = VersionView.Companion.deserialize(compilerVersionFromSettings, /*isAutoAdvance =*/ false); - } - return versionView; - } - - private @NotNull String getSelectedKotlinJpsPluginVersion() { - JpsVersionItem item = (JpsVersionItem) kotlinJpsPluginVersionComboBox.getSelectedItem(); - return normalizeKotlinJpsPluginVersion(item != null ? item.getRawVersion() : null); - } - - private static @NlsSafe @NotNull String normalizeKotlinJpsPluginVersion(@Nullable String version) { - if (version != null && !version.isEmpty()) { - return version; - } - - return KotlinJpsPluginSettings.getRawBundledVersion(); - } - - public void applyTo( - CommonCompilerArguments commonCompilerArguments, - K2JVMCompilerArguments k2jvmCompilerArguments, - K2JSCompilerArguments k2jsCompilerArguments, - CompilerSettings compilerSettings - ) throws ConfigurationException { - if (isProjectSettings) { - boolean shouldInvalidateCaches = - !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || - !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || - jpsPluginSettings != null && - !getSelectedKotlinJpsPluginVersion().equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings)) || - !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()); - - if (!project.isDefault() && shouldInvalidateCaches) { - ApplicationUtilsKt.runWriteAction( - new Function0<>() { - @Override - public Object invoke() { - ProjectStructureUtils.invalidateProjectRoots(project, RootsChangeRescanningInfo.NO_RESCAN_NEEDED); - return null; - } - } - ); - } - } - - commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected()); - KotlinFacetSettingsKt.setLanguageVersionView(commonCompilerArguments, getSelectedLanguageVersionView()); - KotlinFacetSettingsKt.setApiVersionView(commonCompilerArguments, getSelectedAPIVersionView()); - - compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); - compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected()); - compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText()); - - if (compilerWorkspaceSettings != null) { - compilerWorkspaceSettings.setPreciseIncrementalEnabled(enableIncrementalCompilationForJvmCheckBox.isSelected()); - compilerWorkspaceSettings.setIncrementalCompilationForJsEnabled(enableIncrementalCompilationForJsCheckBox.isSelected()); - compilerWorkspaceSettings.setDaemonVmOptions(extractDaemonVmOptions()); - - boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); - compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); - if (keepAliveCheckBox.isSelected() != oldEnableDaemon) { - PluginStartupApplicationService.getInstance().resetAliveFlag(); - } - } - - k2jsCompilerArguments.setSourceMap(generateSourceMapsCheckBox.isSelected()); - k2jsCompilerArguments.setModuleKind(getSelectedModuleKind()); - - k2jsCompilerArguments.setSourceMapPrefix(sourceMapPrefix.getText()); - k2jsCompilerArguments - .setSourceMapEmbedSources(generateSourceMapsCheckBox.isSelected() ? getSelectedSourceMapSourceEmbedding() : null); - - k2jvmCompilerArguments.setJvmTarget(getSelectedJvmVersion()); - - if (isProjectSettings) { - if (jpsPluginSettings != null) { - String jpsPluginVersion = getSelectedKotlinJpsPluginVersion(); - if (!jpsPluginSettings.getVersion().isEmpty() || - !jpsPluginVersion.equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings))) { - defaultJpsVersionItem = (JpsVersionItem) kotlinJpsPluginVersionComboBox.getSelectedItem(); - jpsPluginSettings.setVersion(jpsPluginVersion); - KotlinJpsPluginSettings.getInstance(project).setSettings(jpsPluginSettings); - } - } - - KotlinCommonCompilerArgumentsHolder.getInstance(project).setSettings(commonCompilerArguments); - Kotlin2JvmCompilerArgumentsHolder.getInstance(project).setSettings(k2jvmCompilerArguments); - Kotlin2JsCompilerArgumentsHolder.getInstance(project).setSettings(k2jsCompilerArguments); - KotlinCompilerSettings.getInstance(project).setSettings(compilerSettings); - } - - if (!project.isDefault()) { - BuildManager.getInstance().clearState(project); - } - } - - @Override - public void apply() throws ConfigurationException { - applyTo(commonCompilerArguments, k2jvmCompilerArguments, k2jsCompilerArguments, compilerSettings); - } - - @Override - public void reset() { - reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings()); - if (jpsPluginSettings != null) { - setSelectedItem(kotlinJpsPluginVersionComboBox, defaultJpsVersionItem); - } - // This call adds the correct values to the language/apiVersion dropdown based on the compiler version. - // It also selects some values of the dropdown, but we want to choose the values reflecting the current settings afterward. - onLanguageLevelChanged(getSelectedKotlinJpsPluginVersionView()); // getSelectedLanguageVersionView() replaces null - - if (!commonCompilerArguments.getAutoAdvanceLanguageVersion()) { - setSelectedItem(languageVersionComboBox, KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)); - } else { - setSelectedItem(languageVersionComboBox, getLatestStableVersion()); - } - if (!commonCompilerArguments.getAutoAdvanceApiVersion()) { - setSelectedItem(apiVersionComboBox, KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)); - } else { - setSelectedItem(apiVersionComboBox, getLatestStableVersion()); - } - additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments()); - copyRuntimeFilesCheckBox.setSelected(compilerSettings.getCopyJsLibraryFiles()); - outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles()); - - if (compilerWorkspaceSettings != null) { - enableIncrementalCompilationForJvmCheckBox.setSelected(compilerWorkspaceSettings.getPreciseIncrementalEnabled()); - enableIncrementalCompilationForJsCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()); - keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon()); - } - - generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.getSourceMap()); - - moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())); - sourceMapPrefix.setText(k2jsCompilerArguments.getSourceMapPrefix()); - sourceMapPrefix.setEnabled(k2jsCompilerArguments.getSourceMap()); - sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())); - - jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); - } - - private static void setSelectedItem(JComboBox comboBox, T versionView) { - // Imported projects might have outdated language/api versions - we display them as well (see createVersionValidator() for details) - int index = ((MutableCollectionComboBoxModel) comboBox.getModel()).getElementIndex(versionView); - if (index == -1) { - comboBox.addItem(versionView); - } - - comboBox.setSelectedItem(versionView); - } - - @Override - public void disposeUIResources() { - if (validatorsDisposable == null) { - LOG.error(new IllegalStateException("validatorsDisposable is null")); - return; + } + + private void fillJvmVersionList() { + for (TargetPlatform jvm : JvmIdePlatformKind.INSTANCE.getPlatforms()) { + JvmTarget jvmTarget = PlatformUtilKt.subplatformsOfType(jvm, JdkPlatform.class).get(0).getTargetVersion(); + @NlsSafe String description = jvmTarget.getDescription(); + if (jvmTarget == JvmTarget.JVM_1_6) { + description += " " + KotlinBaseCompilerConfigurationUiBundle.message("deprecated.jvm.version"); } - Disposer.dispose(validatorsDisposable); - validatorsDisposable = null; + jvmVersionComboBox.addItem(description); } + } - @Nls - @Override - public String getDisplayName() { - return KotlinBaseCompilerConfigurationUiBundle.message("configuration.name.kotlin.compiler"); - } - - @Override - public @Nullable String getHelpTopic() { - return "reference.compiler.kotlin"; - } - - public JPanel getContentPane() { - return contentPane; - } - - public ThreeStateCheckBox getReportWarningsCheckBox() { - return reportWarningsCheckBox; - } - - public RawCommandLineEditor getAdditionalArgsOptionsField() { - return additionalArgsOptionsField; - } - - public ThreeStateCheckBox getGenerateSourceMapsCheckBox() { - return generateSourceMapsCheckBox; - } - - public TextFieldWithBrowseButton getOutputDirectory() { - return outputDirectory; - } - - public ThreeStateCheckBox getCopyRuntimeFilesCheckBox() { - return copyRuntimeFilesCheckBox; - } - - public ThreeStateCheckBox getKeepAliveCheckBox() { - return keepAliveCheckBox; - } - - public JComboBox getModuleKindComboBox() { - return moduleKindComboBox; - } - - public JComboBox getLanguageVersionComboBox() { - return languageVersionComboBox; - } - - public JComboBox getApiVersionComboBox() { - return apiVersionComboBox; - } - - public void setEnabled(boolean value) { - isEnabled = value; - UIUtil.setEnabled(getContentPane(), value, true); - } - - public CommonCompilerArguments getCommonCompilerArguments() { - return commonCompilerArguments; - } - - public void setCommonCompilerArguments(CommonCompilerArguments commonCompilerArguments) { - this.commonCompilerArguments = commonCompilerArguments; - } - - public K2JSCompilerArguments getK2jsCompilerArguments() { - return k2jsCompilerArguments; - } - - public void setK2jsCompilerArguments(K2JSCompilerArguments k2jsCompilerArguments) { - this.k2jsCompilerArguments = k2jsCompilerArguments; - } - - public K2JVMCompilerArguments getK2jvmCompilerArguments() { - return k2jvmCompilerArguments; - } - - public void setK2jvmCompilerArguments(K2JVMCompilerArguments k2jvmCompilerArguments) { - this.k2jvmCompilerArguments = k2jvmCompilerArguments; - } - - public CompilerSettings getCompilerSettings() { - return compilerSettings; - } - - public void setCompilerSettings(CompilerSettings compilerSettings) { - this.compilerSettings = compilerSettings; - } - - private static class ComboBoxModelWithPossiblyDisabledItems extends MutableCollectionComboBoxModel { - @Override - public void setSelectedItem(@Nullable Object item) { - if (item == null) return; - - if (!(item instanceof JpsVersionItem)) { - throw new IllegalStateException(item + "is supposed to be JpsVersionItem"); - } - - if (!((JpsVersionItem) item).myEnabled) { - return; - } - super.setSelectedItem(item); + private void fetchAvailableJpsCompilersAsync(Consumer> onFinish) { + JarRepositoryManager.getAvailableVersions(project, RepositoryLibraryDescription.findDescription( + KotlinArtifactConstants.KOTLIN_MAVEN_GROUP_ID, KotlinArtifactConstants.KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID)) + .onProcessed(distVersions -> { + if (distVersions == null) { + onFinish.accept(null); + return; } - } - - private void createUIComponents() { - // Explicit use of MutableCollectionComboBoxModel guarantees that setSelectedItem() can make safe cast. - languageVersionComboBox = new ComboBox<>(new MutableCollectionComboBoxModel<>()); - jpsPluginComboBoxModel = new ComboBoxModelWithPossiblyDisabledItems(); - kotlinJpsPluginVersionComboBox = new ComboBox<>(jpsPluginComboBoxModel); - apiVersionComboBox = new ComboBox<>(new MutableCollectionComboBoxModel<>()); - - // Workaround: ThreeStateCheckBox doesn't send suitable notification on state change - // TODO: replace with PropertyChangerListener after fix is available in IDEA - copyRuntimeFilesCheckBox = new ThreeStateCheckBox() { - @Override - public void setState(State state) { - super.setState(state); - updateOutputDirEnabled(); + JarRepositoryManager.getAvailableVersions(project, RepositoryLibraryDescription.findDescription( + KotlinArtifactConstants.KOTLIN_MAVEN_GROUP_ID, + KotlinArtifactConstants.KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID)) + .onProcessed(jpsClassPathVersions -> { + if (jpsClassPathVersions == null) { + onFinish.accept(null); + return; } - }; - } - private static void createVersionValidator(JComboBox component, String messageKey, Disposable parentDisposable) { - new ComponentValidator(parentDisposable) - .withValidator(() -> { - VersionView selectedItem = (VersionView) component.getSelectedItem(); - if (selectedItem == null) return null; + KotlinVersion min = KotlinJpsPluginSettings.getJpsMinimumSupportedVersion(); + KotlinVersion max = KotlinJpsPluginSettings.getJpsMaximumSupportedVersion(); + HashSet ideKotlinVersions = new HashSet<>(); + for (String version : distVersions) { + if (!jpsClassPathVersions.contains(version)) continue; - LanguageOrApiVersion version = selectedItem.getVersion(); - if (version.isUnsupported()) { - return new ValidationInfo(KotlinBaseCompilerConfigurationUiBundle.message(messageKey, version.getVersionString()), component); - } - - return null; - }).installOn(component); - component.addActionListener(e -> ComponentValidator.getInstance(component).ifPresent(ComponentValidator::revalidate)); - } - - // Expected format is - // -XdaemonVmOptions=-Xmx6000m for one argument - // and - // -XdaemonVmOptions=\"-Xmx6000m -XX:HeapDumpPath=kotlin-build-process-heap-dump.hprof -XX:+HeapDumpOnOutOfMemoryError\" - // for multiple - private @NotNull String extractDaemonVmOptions() { - String additionalOptions = getAdditionalArgsOptionsField().getText(); - if (additionalOptions.contains("-XdaemonVmOptions")) { - Pattern pattern = Pattern.compile("-XdaemonVmOptions=(?:\"([^\"]*)\"|([^\\s]*))"); - Matcher matcher = pattern.matcher(additionalOptions); - - if (matcher.find()) { - String daemonArguments = matcher.group(1) != null ? matcher.group(1) : matcher.group(2); - if (daemonArguments != null) { - return daemonArguments; + IdeKotlinVersion parsedVersion = IdeKotlinVersion.opt(version); + if (parsedVersion != null) { + KotlinVersion parsedKotlinVersion = parsedVersion.getKotlinVersion(); + if (parsedKotlinVersion.compareTo(min) >= 0 && parsedKotlinVersion.compareTo(max) <= 0) { + ideKotlinVersions.add(parsedVersion); } + } } + + onFinish.accept(ideKotlinVersions); + }); + }); + } + + private boolean isJpsCompilerVisible() { + return isProjectSettings && jpsPluginSettings != null; + } + + private void fillVersions() { + if (isJpsCompilerVisible()) { + defaultJpsVersionItem = JpsVersionItem.createFromRawVersion( + KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings) + ); + + kotlinJpsPluginVersionComboBox.addItem(defaultJpsVersionItem); + + IdeKotlinVersion bundledVersion = KotlinJpsPluginSettings.getBundledVersion(); + IdeKotlinVersion defaultVersion = defaultJpsVersionItem.getVersion(); + Integer compare = defaultVersion != null ? defaultVersion.compareTo(bundledVersion) : null; + if (compare == null || compare > 0) { + jpsPluginComboBoxModel.add(new JpsVersionItem(bundledVersion)); + } + else if (compare < 0) { + jpsPluginComboBoxModel.add(0, new JpsVersionItem(bundledVersion)); + } + + JpsVersionItem loadingItem = + JpsVersionItem.createLabel(KotlinBaseCompilerConfigurationUiBundle.message("loading.available.versions.from.maven")); + kotlinJpsPluginVersionComboBox.addItem(loadingItem); + PopupMenuListenerAdapter popupListener = new PopupMenuListenerAdapter() { + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + kotlinJpsPluginVersionComboBox.removePopupMenuListener(this); + fetchAvailableJpsCompilersAsync( + availableVersions -> { + kotlinJpsPluginVersionComboBox.removeItem(loadingItem); + if (availableVersions == null) { + kotlinJpsPluginVersionComboBox.addItem( + JpsVersionItem.createLabel( + KotlinBaseCompilerConfigurationUiBundle.message("failed.fetching.all.available.versions.from.maven") + ) + ); + } + else { + SortedSet newItems = new TreeSet<>(availableVersions); + for (JpsVersionItem item : jpsPluginComboBoxModel.getItems()) { + IdeKotlinVersion ideKotlinVersion = item.getVersion(); + if (ideKotlinVersion != null) { + newItems.add(ideKotlinVersion); + } + } + + Object selectedItem = jpsPluginComboBoxModel.getSelectedItem(); + jpsPluginComboBoxModel.update( + ContainerUtil.reverse(ContainerUtil.map(newItems, it -> new JpsVersionItem(it)))); + kotlinJpsPluginVersionComboBox.setSelectedItem(selectedItem); + } + + if (kotlinJpsPluginVersionComboBox.isPopupVisible()) { + kotlinJpsPluginVersionComboBox.hidePopup(); + kotlinJpsPluginVersionComboBox.showPopup(); + } + }); } - return ""; + }; + + kotlinJpsPluginVersionComboBox.addPopupMenuListener(popupListener); } + else { + kotlinJpsPluginVersionPanel.setVisible(false); + } + + VersionView latestStable = getLatestStableVersion(); + int index = 0; + EnumEntries languageVersions = LanguageVersion.getEntries(); + int latestStableIndex = languageVersions.size(); + for (LanguageVersion languageVersion : languageVersions) { + if (index > latestStableIndex) break; + if (!isLessOrEqual(languageVersion, latestStable.getVersion()) && (index < latestStableIndex)) { + latestStableIndex = index; + } + + if (!languageVersion.isStable()) { + continue; + } + + ApiVersion apiVersion = ApiVersion.createByLanguageVersion(languageVersion); + + if (!apiVersion.isUnsupported()) { + apiVersionComboBox.addItem(new VersionView.Specific(languageVersion)); + } + if (!languageVersion.isUnsupported()) { + languageVersionComboBox.addItem(new VersionView.Specific(languageVersion)); + } + index++; + } + + languageVersionComboBox.setRenderer(createDescriptionAwareRenderer()); + kotlinJpsPluginVersionComboBox.setRenderer(createDescriptionAwareRenderer()); + apiVersionComboBox.setRenderer(createDescriptionAwareRenderer()); + } + + private static VersionView latestStableVersion = null; + + private static VersionView getLatestStableVersion() { + VersionView latestStable = latestStableVersion; + if (latestStable != null) { + return latestStable; + } + + LanguageVersion bundledLanguageVersion = KotlinJpsPluginSettings.getBundledVersion().getLanguageVersion(); + latestStable = VersionView.LatestStable.INSTANCE; + + // workaround to avoid cases when Kotlin plugin bundles the latest compiler with effectively NOT STABLE version. + // Actually, the latest stable version is bundled in jps + for (LanguageVersion languageVersion : LanguageVersion.getEntries()) { + if (languageVersion.compareTo(bundledLanguageVersion) <= 0) { + latestStable = VersionView.Companion.deserialize(languageVersion.getVersionString(), false); + } + else { + break; + } + } + + latestStableVersion = latestStable; + return latestStable; + } + + public void setTargetPlatform(@Nullable IdePlatformKind targetPlatform) { + k2jsPanel.setVisible(JsIdePlatformUtil.isJavaScript(targetPlatform)); + } + + private void fillModuleKindList() { + for (@Nls String moduleKind : moduleKindDescriptions.keySet()) { + moduleKindComboBox.addItem(moduleKind); + } + + moduleKindComboBox.setRenderer(BuilderKt.textListCellRenderer("", o -> getModuleKindDescription(o))); + } + + private void fillSourceMapSourceEmbeddingList() { + for (@Nls String moduleKind : sourceMapSourceEmbeddingDescriptions.keySet()) { + sourceMapEmbedSources.addItem(moduleKind); + } + + sourceMapEmbedSources.setRenderer(BuilderKt.textListCellRenderer("", o -> getSourceMapSourceEmbeddingDescription(o))); + } + + @Override + public @NotNull String getId() { + return "project.kotlinCompiler"; + } + + @Override + public @Nullable JComponent createComponent() { + if (validatorsDisposable != null) { + LOG.error(new IllegalStateException("validatorsDisposable is not null. Disposing and rewriting it.")); + Disposer.dispose(validatorsDisposable); + } + validatorsDisposable = Disposer.newDisposable(); + createVersionValidator(languageVersionComboBox, "configuration.warning.text.language.version.unsupported", validatorsDisposable); + createVersionValidator(apiVersionComboBox, "configuration.warning.text.api.version.unsupported", validatorsDisposable); + + return contentPane; + } + + @Override + public boolean isModified() { + return isCheckboxModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) || + !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || + !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || + jpsPluginSettings != null && + !getSelectedKotlinJpsPluginVersion().equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings)) || + !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()) || + isCheckboxModified(copyRuntimeFilesCheckBox, compilerSettings.getCopyJsLibraryFiles()) || + isBrowseFieldModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) || + + (compilerWorkspaceSettings != null && + (isCheckboxModified(enableIncrementalCompilationForJvmCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) || + isCheckboxModified(enableIncrementalCompilationForJsCheckBox, + compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()) || + isCheckboxModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || + + isCheckboxModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || + !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())) || + isFieldModified(sourceMapPrefix, StringUtil.notNullize(k2jsCompilerArguments.getSourceMapPrefix())) || + !getSelectedSourceMapSourceEmbedding().equals( + getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())) || + !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); + } + + private @NotNull String getSelectedModuleKind() { + return getModuleKindOrDefault((String)moduleKindComboBox.getSelectedItem()); + } + + private String getSelectedSourceMapSourceEmbedding() { + return getSourceMapSourceEmbeddingOrDefault((String)sourceMapEmbedSources.getSelectedItem()); + } + + public @NotNull String getSelectedJvmVersion() { + return getJvmVersionOrDefault((String)jvmVersionComboBox.getSelectedItem()); + } + + public @NotNull VersionView getSelectedLanguageVersionView() { + Object item = languageVersionComboBox.getSelectedItem(); + return item != null ? (VersionView)item : getLatestStableVersion(); + } + + private @NotNull VersionView getSelectedAPIVersionView() { + Object item = apiVersionComboBox.getSelectedItem(); + return item != null ? (VersionView)item : getLatestStableVersion(); + } + + public VersionView getSelectedKotlinJpsPluginVersionView() { + JpsVersionItem selectedItem = (JpsVersionItem)kotlinJpsPluginVersionComboBox.getSelectedItem(); + IdeKotlinVersion version = selectedItem != null ? selectedItem.getVersion() : null; + LanguageVersion languageVersion = version != null ? LanguageVersion.fromFullVersionString(version.toString()) : null; + VersionView versionView; + if (languageVersion != null) { + versionView = new VersionView.Specific(languageVersion); + } + else { + String compilerVersionFromSettings = KotlinJpsPluginSettings.getInstance(project).getSettings().getVersion(); + versionView = VersionView.Companion.deserialize(compilerVersionFromSettings, /*isAutoAdvance =*/ false); + } + return versionView; + } + + private @NotNull String getSelectedKotlinJpsPluginVersion() { + JpsVersionItem item = (JpsVersionItem)kotlinJpsPluginVersionComboBox.getSelectedItem(); + return normalizeKotlinJpsPluginVersion(item != null ? item.getRawVersion() : null); + } + + private static @NlsSafe @NotNull String normalizeKotlinJpsPluginVersion(@Nullable String version) { + if (version != null && !version.isEmpty()) { + return version; + } + + return KotlinJpsPluginSettings.getRawBundledVersion(); + } + + public void applyTo( + CommonCompilerArguments commonCompilerArguments, + K2JVMCompilerArguments k2jvmCompilerArguments, + K2JSCompilerArguments k2jsCompilerArguments, + CompilerSettings compilerSettings + ) throws ConfigurationException { + if (isProjectSettings) { + boolean shouldInvalidateCaches = + !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || + !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || + jpsPluginSettings != null && + !getSelectedKotlinJpsPluginVersion().equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings)) || + !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()); + + if (!project.isDefault() && shouldInvalidateCaches) { + ApplicationUtilsKt.runWriteAction( + new Function0<>() { + @Override + public Object invoke() { + ProjectStructureUtils.invalidateProjectRoots(project, RootsChangeRescanningInfo.NO_RESCAN_NEEDED); + return null; + } + } + ); + } + } + + commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected()); + KotlinFacetSettingsKt.setLanguageVersionView(commonCompilerArguments, getSelectedLanguageVersionView()); + KotlinFacetSettingsKt.setApiVersionView(commonCompilerArguments, getSelectedAPIVersionView()); + + compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); + compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected()); + compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText()); + + if (compilerWorkspaceSettings != null) { + compilerWorkspaceSettings.setPreciseIncrementalEnabled(enableIncrementalCompilationForJvmCheckBox.isSelected()); + compilerWorkspaceSettings.setIncrementalCompilationForJsEnabled(enableIncrementalCompilationForJsCheckBox.isSelected()); + compilerWorkspaceSettings.setDaemonVmOptions(extractDaemonVmOptions()); + + boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); + compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); + if (keepAliveCheckBox.isSelected() != oldEnableDaemon) { + PluginStartupApplicationService.getInstance().resetAliveFlag(); + } + } + + k2jsCompilerArguments.setSourceMap(generateSourceMapsCheckBox.isSelected()); + k2jsCompilerArguments.setModuleKind(getSelectedModuleKind()); + + k2jsCompilerArguments.setSourceMapPrefix(sourceMapPrefix.getText()); + k2jsCompilerArguments + .setSourceMapEmbedSources(generateSourceMapsCheckBox.isSelected() ? getSelectedSourceMapSourceEmbedding() : null); + + k2jvmCompilerArguments.setJvmTarget(getSelectedJvmVersion()); + + if (isProjectSettings) { + if (jpsPluginSettings != null) { + String jpsPluginVersion = getSelectedKotlinJpsPluginVersion(); + if (!jpsPluginSettings.getVersion().isEmpty() || + !jpsPluginVersion.equals(KotlinJpsPluginSettingsKt.getVersionWithFallback(jpsPluginSettings))) { + defaultJpsVersionItem = (JpsVersionItem)kotlinJpsPluginVersionComboBox.getSelectedItem(); + jpsPluginSettings.setVersion(jpsPluginVersion); + KotlinJpsPluginSettings.getInstance(project).setSettings(jpsPluginSettings); + } + } + + KotlinCommonCompilerArgumentsHolder.getInstance(project).setSettings(commonCompilerArguments); + Kotlin2JvmCompilerArgumentsHolder.getInstance(project).setSettings(k2jvmCompilerArguments); + Kotlin2JsCompilerArgumentsHolder.getInstance(project).setSettings(k2jsCompilerArguments); + KotlinCompilerSettings.getInstance(project).setSettings(compilerSettings); + } + + if (!project.isDefault()) { + BuildManager.getInstance().clearState(project); + } + } + + @Override + public void apply() throws ConfigurationException { + applyTo(commonCompilerArguments, k2jvmCompilerArguments, k2jsCompilerArguments, compilerSettings); + } + + @Override + public void reset() { + reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings()); + if (jpsPluginSettings != null) { + setSelectedItem(kotlinJpsPluginVersionComboBox, defaultJpsVersionItem); + } + // This call adds the correct values to the language/apiVersion dropdown based on the compiler version. + // It also selects some values of the dropdown, but we want to choose the values reflecting the current settings afterward. + onLanguageLevelChanged(getSelectedKotlinJpsPluginVersionView()); // getSelectedLanguageVersionView() replaces null + + if (!commonCompilerArguments.getAutoAdvanceLanguageVersion()) { + setSelectedItem(languageVersionComboBox, KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)); + } + else { + setSelectedItem(languageVersionComboBox, getLatestStableVersion()); + } + if (!commonCompilerArguments.getAutoAdvanceApiVersion()) { + setSelectedItem(apiVersionComboBox, KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)); + } + else { + setSelectedItem(apiVersionComboBox, getLatestStableVersion()); + } + additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments()); + copyRuntimeFilesCheckBox.setSelected(compilerSettings.getCopyJsLibraryFiles()); + outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles()); + + if (compilerWorkspaceSettings != null) { + enableIncrementalCompilationForJvmCheckBox.setSelected(compilerWorkspaceSettings.getPreciseIncrementalEnabled()); + enableIncrementalCompilationForJsCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()); + keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon()); + } + + generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.getSourceMap()); + + moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())); + sourceMapPrefix.setText(k2jsCompilerArguments.getSourceMapPrefix()); + sourceMapPrefix.setEnabled(k2jsCompilerArguments.getSourceMap()); + sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())); + + jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); + } + + private static void setSelectedItem(JComboBox comboBox, T versionView) { + // Imported projects might have outdated language/api versions - we display them as well (see createVersionValidator() for details) + int index = ((MutableCollectionComboBoxModel)comboBox.getModel()).getElementIndex(versionView); + if (index == -1) { + comboBox.addItem(versionView); + } + + comboBox.setSelectedItem(versionView); + } + + @Override + public void disposeUIResources() { + if (validatorsDisposable == null) { + LOG.error(new IllegalStateException("validatorsDisposable is null")); + return; + } + + Disposer.dispose(validatorsDisposable); + validatorsDisposable = null; + } + + @Nls + @Override + public String getDisplayName() { + return KotlinBaseCompilerConfigurationUiBundle.message("configuration.name.kotlin.compiler"); + } + + @Override + public @Nullable String getHelpTopic() { + return "reference.compiler.kotlin"; + } + + public JPanel getContentPane() { + return contentPane; + } + + public ThreeStateCheckBox getReportWarningsCheckBox() { + return reportWarningsCheckBox; + } + + public RawCommandLineEditor getAdditionalArgsOptionsField() { + return additionalArgsOptionsField; + } + + public ThreeStateCheckBox getGenerateSourceMapsCheckBox() { + return generateSourceMapsCheckBox; + } + + public TextFieldWithBrowseButton getOutputDirectory() { + return outputDirectory; + } + + public ThreeStateCheckBox getCopyRuntimeFilesCheckBox() { + return copyRuntimeFilesCheckBox; + } + + public ThreeStateCheckBox getKeepAliveCheckBox() { + return keepAliveCheckBox; + } + + public JComboBox getModuleKindComboBox() { + return moduleKindComboBox; + } + + public JComboBox getLanguageVersionComboBox() { + return languageVersionComboBox; + } + + public JComboBox getApiVersionComboBox() { + return apiVersionComboBox; + } + + public void setEnabled(boolean value) { + isEnabled = value; + UIUtil.setEnabled(getContentPane(), value, true); + } + + public CommonCompilerArguments getCommonCompilerArguments() { + return commonCompilerArguments; + } + + public void setCommonCompilerArguments(CommonCompilerArguments commonCompilerArguments) { + this.commonCompilerArguments = commonCompilerArguments; + } + + public K2JSCompilerArguments getK2jsCompilerArguments() { + return k2jsCompilerArguments; + } + + public void setK2jsCompilerArguments(K2JSCompilerArguments k2jsCompilerArguments) { + this.k2jsCompilerArguments = k2jsCompilerArguments; + } + + public K2JVMCompilerArguments getK2jvmCompilerArguments() { + return k2jvmCompilerArguments; + } + + public void setK2jvmCompilerArguments(K2JVMCompilerArguments k2jvmCompilerArguments) { + this.k2jvmCompilerArguments = k2jvmCompilerArguments; + } + + public CompilerSettings getCompilerSettings() { + return compilerSettings; + } + + public void setCompilerSettings(CompilerSettings compilerSettings) { + this.compilerSettings = compilerSettings; + } + + private static class ComboBoxModelWithPossiblyDisabledItems extends MutableCollectionComboBoxModel { + @Override + public void setSelectedItem(@Nullable Object item) { + if (item == null) return; + + if (!(item instanceof JpsVersionItem)) { + throw new IllegalStateException(item + "is supposed to be JpsVersionItem"); + } + + if (!((JpsVersionItem)item).myEnabled) { + return; + } + super.setSelectedItem(item); + } + } + + private static void createVersionValidator(JComboBox component, String messageKey, Disposable parentDisposable) { + new ComponentValidator(parentDisposable) + .withValidator(() -> { + VersionView selectedItem = (VersionView)component.getSelectedItem(); + if (selectedItem == null) return null; + + LanguageOrApiVersion version = selectedItem.getVersion(); + if (version.isUnsupported()) { + return new ValidationInfo(KotlinBaseCompilerConfigurationUiBundle.message(messageKey, version.getVersionString()), component); + } + + return null; + }).installOn(component); + component.addActionListener(e -> ComponentValidator.getInstance(component).ifPresent(ComponentValidator::revalidate)); + } + + // Expected format is + // -XdaemonVmOptions=-Xmx6000m for one argument + // and + // -XdaemonVmOptions=\"-Xmx6000m -XX:HeapDumpPath=kotlin-build-process-heap-dump.hprof -XX:+HeapDumpOnOutOfMemoryError\" + // for multiple + private @NotNull String extractDaemonVmOptions() { + String additionalOptions = getAdditionalArgsOptionsField().getText(); + if (additionalOptions.contains("-XdaemonVmOptions")) { + Pattern pattern = Pattern.compile("-XdaemonVmOptions=(?:\"([^\"]*)\"|([^\\s]*))"); + Matcher matcher = pattern.matcher(additionalOptions); + + if (matcher.find()) { + String daemonArguments = matcher.group(1) != null ? matcher.group(1) : matcher.group(2); + if (daemonArguments != null) { + return daemonArguments; + } + } + } + return ""; + } } diff --git a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/configuration/KotlinScriptingSettingsConfigurable.java b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/configuration/KotlinScriptingSettingsConfigurable.java index a2e8acf83e91..411b4a38cd47 100644 --- a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/configuration/KotlinScriptingSettingsConfigurable.java +++ b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/configuration/KotlinScriptingSettingsConfigurable.java @@ -8,6 +8,8 @@ import com.intellij.ui.TitledSeparator; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.ui.table.TableView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -23,95 +25,120 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; + import static kotlin.streams.jdk8.StreamsKt.asStream; public class KotlinScriptingSettingsConfigurable implements SearchableConfigurable { - private JPanel root; - private JPanel panelScriptDefinitionsChooser; - private JPanel additionalSettingsPanel; + private final JPanel root; + private final JPanel panelScriptDefinitionsChooser; + private final JPanel additionalSettingsPanel; - private final KotlinScriptDefinitionsModel model; - private final ScriptDefinitionsManager manager; - private final KotlinScriptingSettingsImpl settings; + private final KotlinScriptDefinitionsModel model; + private final ScriptDefinitionsManager manager; + private final KotlinScriptingSettingsImpl settings; - public KotlinScriptingSettingsConfigurable(Project project) { - manager = ScriptDefinitionsManager.Companion.getInstance(project); - settings = KotlinScriptingSettingsImpl.Companion.getInstance(project); - model = KotlinScriptDefinitionsModel.Companion.createModel( - asStream(ScriptDefinitionProvider.Companion.getInstance(project).getCurrentDefinitions()).toList(), settings); + public KotlinScriptingSettingsConfigurable(Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + root = new JPanel(); + root.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panelScriptDefinitionsChooser = new JPanel(); + panelScriptDefinitionsChooser.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + root.add(panelScriptDefinitionsChooser, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + additionalSettingsPanel = new JPanel(); + additionalSettingsPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + root.add(additionalSettingsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); } + manager = ScriptDefinitionsManager.Companion.getInstance(project); + settings = KotlinScriptingSettingsImpl.Companion.getInstance(project); + model = KotlinScriptDefinitionsModel.Companion.createModel( + asStream(ScriptDefinitionProvider.Companion.getInstance(project).getCurrentDefinitions()).toList(), settings); + } - @Override - public @Nullable JComponent createComponent() { - panelScriptDefinitionsChooser.setLayout(new VerticalLayout(0)); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return root; } - panelScriptDefinitionsChooser.add(new TitledSeparator(KotlinBundle.message("kotlin.script.definitions.title"))); + @Override + public @Nullable JComponent createComponent() { + panelScriptDefinitionsChooser.setLayout(new VerticalLayout(0)); - JLabel commentLabel = new JLabel(KotlinBundle.message("kotlin.script.definitions.model.name.autoReloadScriptDependencies.description")); - commentLabel.setForeground(UIUtil.getContextHelpForeground()); - panelScriptDefinitionsChooser.add(commentLabel); + panelScriptDefinitionsChooser.add(new TitledSeparator(KotlinBundle.message("kotlin.script.definitions.title"))); - TableView table = new TableView<>(model); - panelScriptDefinitionsChooser.add( - ToolbarDecorator.createDecorator(table) - .disableAddAction() - .disableRemoveAction() - .createPanel() - ); - table.setVisibleRowCount(12); + JLabel commentLabel = new JLabel(KotlinBundle.message("kotlin.script.definitions.model.name.autoReloadScriptDependencies.description")); + commentLabel.setForeground(UIUtil.getContextHelpForeground()); + panelScriptDefinitionsChooser.add(commentLabel); - additionalSettingsPanel.setLayout(new VerticalLayout(0)); - return root; + TableView table = new TableView<>(model); + panelScriptDefinitionsChooser.add( + ToolbarDecorator.createDecorator(table) + .disableAddAction() + .disableRemoveAction() + .createPanel() + ); + table.setVisibleRowCount(12); + + additionalSettingsPanel.setLayout(new VerticalLayout(0)); + return root; + } + + @Override + public boolean isModified() { + return isScriptDefinitionsChanged(); + } + + @Override + public void apply() throws ConfigurationException { + if (isScriptDefinitionsChanged()) { + for (ModelDescriptor item : model.getItems()) { + ScriptDefinition definition = item.getDefinition(); + int order = model.getItems().indexOf(item); + settings.setOrder(definition, order); + settings.setEnabled(definition, item.isEnabled()); + settings.setAutoReloadConfigurations(definition, item.getAutoReloadConfigurations()); + } + + manager.reorderDefinitions(); } + } - @Override - public boolean isModified() { - return isScriptDefinitionsChanged(); - } - - @Override - public void apply() throws ConfigurationException { - if (isScriptDefinitionsChanged()) { - for (ModelDescriptor item : model.getItems()) { - ScriptDefinition definition = item.getDefinition(); - int order = model.getItems().indexOf(item); - settings.setOrder(definition, order); - settings.setEnabled(definition, item.isEnabled()); - settings.setAutoReloadConfigurations(definition, item.getAutoReloadConfigurations()); - } - - manager.reorderDefinitions(); - } - } - - @Override - public void reset() { - model.setDefinitions(asStream(manager.getCurrentDefinitions()).toList(), settings); - } - - private boolean isScriptDefinitionsChanged() { - for (ModelDescriptor item : model.getItems()) { - if (settings.isScriptDefinitionEnabled(item.getDefinition()) != item.isEnabled()) { - return true; - } - if (settings.autoReloadConfigurations(item.getDefinition()) != item.getAutoReloadConfigurations()) { - return true; - } - } - return !model.getDefinitions().equals(asStream(manager.getCurrentDefinitions()).toList()); + @Override + public void reset() { + model.setDefinitions(asStream(manager.getCurrentDefinitions()).toList(), settings); + } + + private boolean isScriptDefinitionsChanged() { + for (ModelDescriptor item : model.getItems()) { + if (settings.isScriptDefinitionEnabled(item.getDefinition()) != item.isEnabled()) { + return true; + } + if (settings.autoReloadConfigurations(item.getDefinition()) != item.getAutoReloadConfigurations()) { + return true; + } } + return !model.getDefinitions().equals(asStream(manager.getCurrentDefinitions()).toList()); + } - @Override - @Nls - public String getDisplayName() { - return KotlinBundle.message("script.name.kotlin.scripting"); - } + @Override + @Nls + public String getDisplayName() { + return KotlinBundle.message("script.name.kotlin.scripting"); + } - @Override - public @NotNull String getId() { - return KotlinScriptingSetttingsIdKt.KOTLIN_SCRIPTING_SETTINGS_ID; - } + @Override + public @NotNull String getId() { + return KotlinScriptingSetttingsIdKt.KOTLIN_SCRIPTING_SETTINGS_ID; + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java index da697ef4b1f7..f26d66a48b6f 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java @@ -7,7 +7,11 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.psi.PsiElement; import com.intellij.refactoring.ui.NameSuggestionsField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TitledSeparator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.MultiMap; import kotlin.Unit; @@ -34,6 +38,7 @@ import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import org.jetbrains.kotlin.types.KotlinType; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; @@ -41,265 +46,422 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import static org.jetbrains.kotlin.idea.refactoring.KotlinCommonRefactoringUtilKt.checkConflictsInteractively; import static org.jetbrains.kotlin.idea.util.NonblockingKt.nonBlocking; public class KotlinExtractFunctionDialog extends DialogWrapper { - private JPanel contentPane; - private TitledSeparator inputParametersPanel; - private JComboBox visibilityBox; - private KotlinSignatureComponent signaturePreviewField; - private JPanel functionNamePanel; - private NameSuggestionsField functionNameField; - private JLabel functionNameLabel; - private JComboBox returnTypeBox; - private JPanel returnTypePanel; - private ExtractFunctionParameterTablePanel parameterTablePanel; + private final JPanel contentPane; + private final TitledSeparator inputParametersPanel; + private final JComboBox visibilityBox; + private final KotlinSignatureComponent signaturePreviewField; + private final JPanel functionNamePanel; + private NameSuggestionsField functionNameField; + private final JLabel functionNameLabel; + private final JComboBox returnTypeBox; + private final JPanel returnTypePanel; + private ExtractFunctionParameterTablePanel parameterTablePanel; - private final Project project; + private final Project project; - private final ExtractableCodeDescriptorWithConflicts originalDescriptor; - private ExtractableCodeDescriptor currentDescriptor; + private final ExtractableCodeDescriptorWithConflicts originalDescriptor; + private ExtractableCodeDescriptor currentDescriptor; - private final Function1 onAccept; + private final Function1 onAccept; - public KotlinExtractFunctionDialog( - @NotNull Project project, - @NotNull ExtractableCodeDescriptorWithConflicts originalDescriptor, - @NotNull Function1 onAccept) { - super(project, true); + public KotlinExtractFunctionDialog( + @NotNull Project project, + @NotNull ExtractableCodeDescriptorWithConflicts originalDescriptor, + @NotNull Function1 onAccept) { + super(project, true); - this.project = project; - this.originalDescriptor = originalDescriptor; - this.currentDescriptor = originalDescriptor.getDescriptor(); - this.onAccept = onAccept; - - setModal(true); - setTitle(KotlinBundle.message("extract.function")); - init(); - update(); + this.project = project; + this.originalDescriptor = originalDescriptor; + { + this.signaturePreviewField = new KotlinSignatureComponent("", project); } - - private void createUIComponents() { - this.signaturePreviewField = new KotlinSignatureComponent("", project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + inputParametersPanel = new TitledSeparator(); + inputParametersPanel.setLayout(new BorderLayout(0, 0)); + inputParametersPanel.setText(""); + inputParametersPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(inputParametersPanel, BorderLayout.CENTER); + inputParametersPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/KotlinBundle", "title.parameters"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 200), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", + "signature.preview"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + signaturePreviewField.setText(""); + panel4.add(signaturePreviewField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(500, 100), new Dimension(500, 100), null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.setEnabled(true); + panel5.setVisible(true); + contentPane.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + functionNameLabel = new JLabel(); + this.$$$loadLabelText$$$(functionNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "name")); + panel5.add(functionNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "visibility")); + label1.setVisible(true); + panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(114, 16), null, 0, false)); + functionNamePanel = new JPanel(); + functionNamePanel.setLayout(new BorderLayout(0, 0)); + panel5.add(functionNamePanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + visibilityBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("private"); + defaultComboBoxModel1.addElement("protected"); + defaultComboBoxModel1.addElement("internal"); + defaultComboBoxModel1.addElement("public"); + visibilityBox.setModel(defaultComboBoxModel1); + visibilityBox.setVisible(true); + panel5.add(visibilityBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(114, 26), null, 0, false)); + returnTypePanel = new JPanel(); + returnTypePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.add(returnTypePanel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "return.type")); + returnTypePanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + returnTypePanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + returnTypeBox = new JComboBox(); + returnTypePanel.add(returnTypeBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPane.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(visibilityBox); + label2.setLabelFor(returnTypeBox); } + this.currentDescriptor = originalDescriptor.getDescriptor(); + this.onAccept = onAccept; - private boolean isVisibilitySectionAvailable() { - return ExtractUtilKt.isVisibilityApplicable(originalDescriptor.getDescriptor().getExtractionData()); + setModal(true); + setTitle(KotlinBundle.message("extract.function")); + init(); + update(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - private String getFunctionName() { - return KtPsiUtilKt.quoteIfNeeded(functionNameField.getEnteredName()); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - private @Nullable KtModifierKeywordToken getVisibility() { - if (!isVisibilitySectionAvailable()) return null; - - KtModifierKeywordToken value = (KtModifierKeywordToken) visibilityBox.getSelectedItem(); - return KtTokens.DEFAULT_VISIBILITY_KEYWORD.equals(value) ? null : value; - } - - private boolean checkNames() { - if (!KtPsiUtilKt.isIdentifier(getFunctionName())) return false; - for (ExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : parameterTablePanel.getSelectedParameterInfos()) { - if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - return true; + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + + private boolean isVisibilitySectionAvailable() { + return ExtractUtilKt.isVisibilityApplicable(originalDescriptor.getDescriptor().getExtractionData()); + } + + private String getFunctionName() { + return KtPsiUtilKt.quoteIfNeeded(functionNameField.getEnteredName()); + } + + private @Nullable KtModifierKeywordToken getVisibility() { + if (!isVisibilitySectionAvailable()) return null; + + KtModifierKeywordToken value = (KtModifierKeywordToken)visibilityBox.getSelectedItem(); + return KtTokens.DEFAULT_VISIBILITY_KEYWORD.equals(value) ? null : value; + } + + private boolean checkNames() { + if (!KtPsiUtilKt.isIdentifier(getFunctionName())) return false; + for (ExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : parameterTablePanel.getSelectedParameterInfos()) { + if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + } + return true; + } + + private void update() { + this.currentDescriptor = createDescriptor(); + + setOKActionEnabled(checkNames()); + signaturePreviewField.setText( + ExtractorUtilKt.getSignaturePreview(getCurrentConfiguration()) + ); + } + + @Override + protected void init() { + super.init(); + + ExtractableCodeDescriptor extractableCodeDescriptor = originalDescriptor.getDescriptor(); + + functionNameField = new NameSuggestionsField( + ArrayUtil.toStringArray(extractableCodeDescriptor.getSuggestedNames()), + project, + KotlinFileType.INSTANCE + ); + functionNameField.addDataChangedListener(() -> update()); + functionNamePanel.add(functionNameField, BorderLayout.CENTER); + functionNameLabel.setLabelFor(functionNameField); + + List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); + if (possibleReturnTypes.size() > 1) { + DefaultComboBoxModel returnTypeBoxModel = new DefaultComboBoxModel<>(possibleReturnTypes.toArray(new KotlinType[0])); + returnTypeBox.setModel(returnTypeBoxModel); + returnTypeBox.setRenderer( + new DefaultListCellRenderer() { + @Override + public @NotNull Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + @NlsSafe + String text = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType((KotlinType)value); + setText(text); + return this; + } + } + ); + returnTypeBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); + } + } + ); + } + else { + returnTypePanel.getParent().remove(returnTypePanel); } - private void update() { - this.currentDescriptor = createDescriptor(); + visibilityBox.setModel(new DefaultComboBoxModel(KtTokens.VISIBILITY_MODIFIERS.getTypes())); - setOKActionEnabled(checkNames()); - signaturePreviewField.setText( - ExtractorUtilKt.getSignaturePreview(getCurrentConfiguration()) - ); + boolean enableVisibility = isVisibilitySectionAvailable(); + visibilityBox.setEnabled(enableVisibility); + if (enableVisibility) { + KtModifierKeywordToken defaultVisibility = extractableCodeDescriptor.getVisibility(); + visibilityBox.setSelectedItem(defaultVisibility); } - - @Override - protected void init() { - super.init(); - - ExtractableCodeDescriptor extractableCodeDescriptor = originalDescriptor.getDescriptor(); - - functionNameField = new NameSuggestionsField( - ArrayUtil.toStringArray(extractableCodeDescriptor.getSuggestedNames()), - project, - KotlinFileType.INSTANCE - ); - functionNameField.addDataChangedListener(() -> update()); - functionNamePanel.add(functionNameField, BorderLayout.CENTER); - functionNameLabel.setLabelFor(functionNameField); - - List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); - if (possibleReturnTypes.size() > 1) { - DefaultComboBoxModel returnTypeBoxModel = new DefaultComboBoxModel<>(possibleReturnTypes.toArray(new KotlinType[0])); - returnTypeBox.setModel(returnTypeBoxModel); - returnTypeBox.setRenderer( - new DefaultListCellRenderer() { - @Override - public @NotNull Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus - ) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - @NlsSafe - String text = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType((KotlinType) value); - setText(text); - return this; - } - } - ); - returnTypeBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); + visibilityBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); } - else { - returnTypePanel.getParent().remove(returnTypePanel); + } + ); + + parameterTablePanel = new ExtractFunctionParameterTablePanel() { + @Override + protected void updateSignature() { + KotlinExtractFunctionDialog.this.update(); + } + + @Override + protected void onEnterAction() { + doOKAction(); + } + + @Override + protected void onCancelAction() { + doCancelAction(); + } + }; + parameterTablePanel.init(extractableCodeDescriptor.getReceiverParameter(), extractableCodeDescriptor.getParameters()); + + inputParametersPanel.setText(KotlinBundle.message("text.parameters")); + inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); + inputParametersPanel.add(parameterTablePanel); + } + + @Override + protected void doOKAction() { + nonBlocking( + project, + () -> { + try { + return ExtractableAnalysisUtilKt.validate(currentDescriptor); } - - visibilityBox.setModel(new DefaultComboBoxModel(KtTokens.VISIBILITY_MODIFIERS.getTypes())); - - boolean enableVisibility = isVisibilitySectionAvailable(); - visibilityBox.setEnabled(enableVisibility); - if (enableVisibility) { - KtModifierKeywordToken defaultVisibility = extractableCodeDescriptor.getVisibility(); - visibilityBox.setSelectedItem(defaultVisibility); + catch (RuntimeException e) { + return new ExtractableCodeDescriptorWithException(e); } - visibilityBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); + }, + result -> { + if (result instanceof ExtractableCodeDescriptorWithException) { + throw ((ExtractableCodeDescriptorWithException)result).getException(); + } + MultiMap conflicts = ((ExtractableCodeDescriptorWithConflicts)result).getConflicts(); + conflicts.values().removeAll(originalDescriptor.getConflicts().values()); - parameterTablePanel = new ExtractFunctionParameterTablePanel() { + checkConflictsInteractively( + project, + conflicts, + new Function0<>() { @Override - protected void updateSignature() { - KotlinExtractFunctionDialog.this.update(); + public Unit invoke() { + close(OK_EXIT_CODE); + return Unit.INSTANCE; } - + }, + new Function0<>() { @Override - protected void onEnterAction() { - doOKAction(); + public Unit invoke() { + KotlinExtractFunctionDialog.super.doOKAction(); + return onAccept.invoke(KotlinExtractFunctionDialog.this); } + } + ); + return Unit.INSTANCE; + }); + } - @Override - protected void onCancelAction() { - doCancelAction(); - } - }; - parameterTablePanel.init(extractableCodeDescriptor.getReceiverParameter(), extractableCodeDescriptor.getParameters()); + @Override + public JComponent getPreferredFocusedComponent() { + return functionNameField.getFocusableComponent(); + } - inputParametersPanel.setText(KotlinBundle.message("text.parameters")); - inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); - inputParametersPanel.add(parameterTablePanel); + @Override + protected JComponent createCenterPanel() { + return contentPane; + } + + @Override + protected @NotNull JComponent createContentPane() { + return contentPane; + } + + private @NotNull ExtractableCodeDescriptor createDescriptor() { + return createNewDescriptor(originalDescriptor.getDescriptor(), + getFunctionName(), + getVisibility(), + parameterTablePanel.getSelectedReceiverInfo(), + parameterTablePanel.getSelectedParameterInfos(), + (KotlinType)returnTypeBox.getSelectedItem()); + } + + public @NotNull ExtractionGeneratorConfiguration getCurrentConfiguration() { + return new ExtractionGeneratorConfiguration(currentDescriptor, ExtractionGeneratorOptions.DEFAULT); + } + + public static ExtractableCodeDescriptor createNewDescriptor( + @NotNull ExtractableCodeDescriptor originalDescriptor, + @NotNull String newName, + @Nullable KtModifierKeywordToken newVisibility, + @Nullable ExtractFunctionParameterTablePanel.ParameterInfo newReceiverInfo, + @NotNull List newParameterInfos, + @Nullable KotlinType returnType + ) { + Map oldToNewParameters = new LinkedHashMap<>(); + for (ExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) { + oldToNewParameters.put(parameterInfo.getOriginalParameter(), parameterInfo.toParameter()); + } + Parameter originalReceiver = originalDescriptor.getReceiverParameter(); + Parameter newReceiver = newReceiverInfo != null ? newReceiverInfo.toParameter() : null; + if (originalReceiver != null && newReceiver != null) { + oldToNewParameters.put(originalReceiver, newReceiver); } - @Override - protected void doOKAction() { - nonBlocking( - project, - () -> { - try { - return ExtractableAnalysisUtilKt.validate(currentDescriptor); - } catch (RuntimeException e) { - return new ExtractableCodeDescriptorWithException(e); - } - }, - result -> { - if (result instanceof ExtractableCodeDescriptorWithException) { - throw ((ExtractableCodeDescriptorWithException) result).getException(); - } - MultiMap conflicts = ((ExtractableCodeDescriptorWithConflicts) result).getConflicts(); - conflicts.values().removeAll(originalDescriptor.getConflicts().values()); - - checkConflictsInteractively( - project, - conflicts, - new Function0<>() { - @Override - public Unit invoke() { - close(OK_EXIT_CODE); - return Unit.INSTANCE; - } - }, - new Function0<>() { - @Override - public Unit invoke() { - KotlinExtractFunctionDialog.super.doOKAction(); - return onAccept.invoke(KotlinExtractFunctionDialog.this); - } - } - ); - return Unit.INSTANCE; - }); - } - - @Override - public JComponent getPreferredFocusedComponent() { - return functionNameField.getFocusableComponent(); - } - - @Override - protected JComponent createCenterPanel() { - return contentPane; - } - - @Override - protected @NotNull JComponent createContentPane() { - return contentPane; - } - - private @NotNull ExtractableCodeDescriptor createDescriptor() { - return createNewDescriptor(originalDescriptor.getDescriptor(), - getFunctionName(), - getVisibility(), - parameterTablePanel.getSelectedReceiverInfo(), - parameterTablePanel.getSelectedParameterInfos(), - (KotlinType) returnTypeBox.getSelectedItem()); - } - - public @NotNull ExtractionGeneratorConfiguration getCurrentConfiguration() { - return new ExtractionGeneratorConfiguration(currentDescriptor, ExtractionGeneratorOptions.DEFAULT); - } - - public static ExtractableCodeDescriptor createNewDescriptor( - @NotNull ExtractableCodeDescriptor originalDescriptor, - @NotNull String newName, - @Nullable KtModifierKeywordToken newVisibility, - @Nullable ExtractFunctionParameterTablePanel.ParameterInfo newReceiverInfo, - @NotNull List newParameterInfos, - @Nullable KotlinType returnType - ) { - Map oldToNewParameters = new LinkedHashMap<>(); - for (ExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) { - oldToNewParameters.put(parameterInfo.getOriginalParameter(), parameterInfo.toParameter()); - } - Parameter originalReceiver = originalDescriptor.getReceiverParameter(); - Parameter newReceiver = newReceiverInfo != null ? newReceiverInfo.toParameter() : null; - if (originalReceiver != null && newReceiver != null) { - oldToNewParameters.put(originalReceiver, newReceiver); - } - - return ExtractableCodeDescriptorKt.copy(originalDescriptor, newName, newVisibility, oldToNewParameters, newReceiver, returnType); - } + return ExtractableCodeDescriptorKt.copy(originalDescriptor, newName, newVisibility, oldToNewParameters, newReceiver, returnType); + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java index b0a434c9d1e6..421e10a1a388 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java @@ -7,7 +7,11 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.psi.PsiElement; import com.intellij.refactoring.ui.NameSuggestionsField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TitledSeparator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.MultiMap; import kotlin.Unit; import kotlin.jvm.functions.Function0; @@ -24,6 +28,7 @@ import org.jetbrains.kotlin.lexer.KtModifierKeywordToken; import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; @@ -31,207 +36,338 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; import static org.jetbrains.kotlin.idea.refactoring.KotlinCommonRefactoringUtilKt.checkConflictsInteractively; public class KotlinIntroduceTypeAliasDialog extends DialogWrapper { - private JPanel contentPane; - private TitledSeparator inputParametersPanel; - private JComboBox visibilityBox; - private KotlinSignatureComponent signaturePreviewField; - private JPanel aliasNamePanel; - private NameSuggestionsField aliasNameField; - private JLabel aliasNameLabel; - private IntroduceTypeAliasParameterTablePanel parameterTablePanel; + private final JPanel contentPane; + private final TitledSeparator inputParametersPanel; + private final JComboBox visibilityBox; + private final KotlinSignatureComponent signaturePreviewField; + private final JPanel aliasNamePanel; + private NameSuggestionsField aliasNameField; + private final JLabel aliasNameLabel; + private IntroduceTypeAliasParameterTablePanel parameterTablePanel; - private final Project project; + private final Project project; - private final IntroduceTypeAliasDescriptor originalDescriptor; - private IntroduceTypeAliasDescriptor currentDescriptor; + private final IntroduceTypeAliasDescriptor originalDescriptor; + private IntroduceTypeAliasDescriptor currentDescriptor; - private final Function1 onAccept; + private final Function1 onAccept; - public KotlinIntroduceTypeAliasDialog( - @NotNull Project project, - @NotNull IntroduceTypeAliasDescriptor originalDescriptor, - @NotNull Function1 onAccept) { - super(project, true); + public KotlinIntroduceTypeAliasDialog( + @NotNull Project project, + @NotNull IntroduceTypeAliasDescriptor originalDescriptor, + @NotNull Function1 onAccept) { + super(project, true); - this.project = project; - this.originalDescriptor = originalDescriptor; - this.currentDescriptor = originalDescriptor; - this.onAccept = onAccept; - - setModal(true); - setTitle(KotlinIntroduceTypeAliasHandler.getREFACTORING_NAME()); - init(); - update(); + this.project = project; + this.originalDescriptor = originalDescriptor; + this.currentDescriptor = originalDescriptor; + this.onAccept = onAccept; + { + this.signaturePreviewField = new KotlinSignatureComponent("", project); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + inputParametersPanel = new TitledSeparator(); + inputParametersPanel.setLayout(new BorderLayout(0, 0)); + inputParametersPanel.setText(""); + inputParametersPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(inputParametersPanel, BorderLayout.CENTER); + inputParametersPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/KotlinBundle", "title.parameters"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 200), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", + "signature.preview"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + signaturePreviewField.setText(""); + panel4.add(signaturePreviewField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(500, 100), new Dimension(500, 100), null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.setEnabled(true); + panel5.setVisible(true); + contentPane.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + aliasNameLabel = new JLabel(); + this.$$$loadLabelText$$$(aliasNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "name")); + panel5.add(aliasNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "visibility")); + label1.setVisible(true); + panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(114, 16), null, 0, false)); + aliasNamePanel = new JPanel(); + aliasNamePanel.setLayout(new BorderLayout(0, 0)); + panel5.add(aliasNamePanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + visibilityBox = new JComboBox(); + visibilityBox.setVisible(true); + panel5.add(visibilityBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(114, 26), null, 0, false)); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(visibilityBox); } - private void createUIComponents() { - this.signaturePreviewField = new KotlinSignatureComponent("", project); - } + setModal(true); + setTitle(KotlinIntroduceTypeAliasHandler.getREFACTORING_NAME()); + init(); + update(); + } - private boolean isVisibilitySectionAvailable() { - return !getApplicableVisibilities().isEmpty(); - } + private static Method $$$cachedGetBundleMethod$$$ = null; - private @NotNull List getApplicableVisibilities() { - return IntroduceTypeAliasImplKt.getApplicableVisibilities(originalDescriptor.getOriginalData()); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - private String getAliasName() { - return KtPsiUtilKt.quoteIfNeeded(aliasNameField.getEnteredName()); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - private @Nullable KtModifierKeywordToken getVisibility() { - if (!isVisibilitySectionAvailable()) return null; - return (KtModifierKeywordToken) visibilityBox.getSelectedItem(); - } - - private boolean checkNames() { - if (!KtPsiUtilKt.isIdentifier(getAliasName())) return false; - if (parameterTablePanel != null) { - for (IntroduceTypeAliasParameterTablePanel.TypeParameterInfo parameterInfo : parameterTablePanel.getSelectedTypeParameterInfos()) { - if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; - } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - return true; + } + result.append(text.charAt(i)); } - - private void update() { - this.currentDescriptor = createDescriptor(); - - setOKActionEnabled(checkNames()); - signaturePreviewField.setText(IntroduceTypeAliasImplKt.generateTypeAlias(currentDescriptor, true).getText()); + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - @Override - protected void init() { - super.init(); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } - visibilityBox.setModel(new DefaultComboBoxModel<>(getApplicableVisibilities().toArray(new KtModifierKeywordToken[0]))); - visibilityBox.setRenderer( - new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus - ) { - @NlsSafe String tokenValue = value != null ? ((KtModifierKeywordToken) value).getValue() : null; - return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus); - } - } - ); + private boolean isVisibilitySectionAvailable() { + return !getApplicableVisibilities().isEmpty(); + } - aliasNameField = new NameSuggestionsField(new String[]{originalDescriptor.getName()}, project, KotlinFileType.INSTANCE); - aliasNameField.addDataChangedListener(() -> update()); - aliasNamePanel.add(aliasNameField, BorderLayout.CENTER); - aliasNameLabel.setLabelFor(aliasNameField); + private @NotNull List getApplicableVisibilities() { + return IntroduceTypeAliasImplKt.getApplicableVisibilities(originalDescriptor.getOriginalData()); + } - boolean enableVisibility = isVisibilitySectionAvailable(); - visibilityBox.setEnabled(enableVisibility); - if (enableVisibility) { - KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility(); - if (defaultVisibility == null) { - defaultVisibility = KtTokens.PUBLIC_KEYWORD; - } - visibilityBox.setSelectedItem(defaultVisibility); + private String getAliasName() { + return KtPsiUtilKt.quoteIfNeeded(aliasNameField.getEnteredName()); + } + + private @Nullable KtModifierKeywordToken getVisibility() { + if (!isVisibilitySectionAvailable()) return null; + return (KtModifierKeywordToken)visibilityBox.getSelectedItem(); + } + + private boolean checkNames() { + if (!KtPsiUtilKt.isIdentifier(getAliasName())) return false; + if (parameterTablePanel != null) { + for (IntroduceTypeAliasParameterTablePanel.TypeParameterInfo parameterInfo : parameterTablePanel.getSelectedTypeParameterInfos()) { + if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + } + } + return true; + } + + private void update() { + this.currentDescriptor = createDescriptor(); + + setOKActionEnabled(checkNames()); + signaturePreviewField.setText(IntroduceTypeAliasImplKt.generateTypeAlias(currentDescriptor, true).getText()); + } + + @Override + protected void init() { + super.init(); + + visibilityBox.setModel(new DefaultComboBoxModel<>(getApplicableVisibilities().toArray(new KtModifierKeywordToken[0]))); + visibilityBox.setRenderer( + new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + @NlsSafe String tokenValue = value != null ? ((KtModifierKeywordToken)value).getValue() : null; + return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus); } - visibilityBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); + } + ); - if (!originalDescriptor.getTypeParameters().isEmpty()) { - parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() { - @Override - protected void updateSignature() { - KotlinIntroduceTypeAliasDialog.this.update(); - } + aliasNameField = new NameSuggestionsField(new String[]{originalDescriptor.getName()}, project, KotlinFileType.INSTANCE); + aliasNameField.addDataChangedListener(() -> update()); + aliasNamePanel.add(aliasNameField, BorderLayout.CENTER); + aliasNameLabel.setLabelFor(aliasNameField); - @Override - protected void onEnterAction() { - doOKAction(); - } - - @Override - protected void onCancelAction() { - doCancelAction(); - } - }; - parameterTablePanel.init(originalDescriptor.getTypeParameters()); - - inputParametersPanel.setText(KotlinBundle.message("text.type.parameters")); - inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); - inputParametersPanel.add(parameterTablePanel); + boolean enableVisibility = isVisibilitySectionAvailable(); + visibilityBox.setEnabled(enableVisibility); + if (enableVisibility) { + KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility(); + if (defaultVisibility == null) { + defaultVisibility = KtTokens.PUBLIC_KEYWORD; + } + visibilityBox.setSelectedItem(defaultVisibility); + } + visibilityBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); } - else { - inputParametersPanel.setVisible(false); + } + ); + + if (!originalDescriptor.getTypeParameters().isEmpty()) { + parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() { + @Override + protected void updateSignature() { + KotlinIntroduceTypeAliasDialog.this.update(); } - } - @Override - protected void doOKAction() { - MultiMap conflicts = IntroduceTypeAliasImplKt.validate(currentDescriptor).getConflicts(); - checkConflictsInteractively( - project, - conflicts, - new Function0<>() { - @Override - public Unit invoke() { - close(OK_EXIT_CODE); - return Unit.INSTANCE; - } - }, - new Function0<>() { - @Override - public Unit invoke() { - KotlinIntroduceTypeAliasDialog.super.doOKAction(); - return onAccept.invoke(KotlinIntroduceTypeAliasDialog.this); - } - } - ); - } + @Override + protected void onEnterAction() { + doOKAction(); + } - @Override - public JComponent getPreferredFocusedComponent() { - return aliasNameField; - } + @Override + protected void onCancelAction() { + doCancelAction(); + } + }; + parameterTablePanel.init(originalDescriptor.getTypeParameters()); - @Override - protected JComponent createCenterPanel() { - return contentPane; + inputParametersPanel.setText(KotlinBundle.message("text.type.parameters")); + inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); + inputParametersPanel.add(parameterTablePanel); } + else { + inputParametersPanel.setVisible(false); + } + } - @Override - protected @NotNull JComponent createContentPane() { - return contentPane; - } + @Override + protected void doOKAction() { + MultiMap conflicts = IntroduceTypeAliasImplKt.validate(currentDescriptor).getConflicts(); + checkConflictsInteractively( + project, + conflicts, + new Function0<>() { + @Override + public Unit invoke() { + close(OK_EXIT_CODE); + return Unit.INSTANCE; + } + }, + new Function0<>() { + @Override + public Unit invoke() { + KotlinIntroduceTypeAliasDialog.super.doOKAction(); + return onAccept.invoke(KotlinIntroduceTypeAliasDialog.this); + } + } + ); + } - private @NotNull IntroduceTypeAliasDescriptor createDescriptor() { - return originalDescriptor.copy( - originalDescriptor.getOriginalData(), - getAliasName(), - getVisibility(), - parameterTablePanel != null ? parameterTablePanel.getSelectedTypeParameters() : Collections.emptyList() - ); - } + @Override + public JComponent getPreferredFocusedComponent() { + return aliasNameField; + } - public IntroduceTypeAliasDescriptor getCurrentDescriptor() { - return currentDescriptor; - } + @Override + protected JComponent createCenterPanel() { + return contentPane; + } + + @Override + protected @NotNull JComponent createContentPane() { + return contentPane; + } + + private @NotNull IntroduceTypeAliasDescriptor createDescriptor() { + return originalDescriptor.copy( + originalDescriptor.getOriginalData(), + getAliasName(), + getVisibility(), + parameterTablePanel != null ? parameterTablePanel.getSelectedTypeParameters() : Collections.emptyList() + ); + } + + public IntroduceTypeAliasDescriptor getCurrentDescriptor() { + return currentDescriptor; + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesDialog.java index eb68456f0e91..e999f1e79391 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesDialog.java @@ -23,6 +23,9 @@ import com.intellij.refactoring.classMembers.MemberInfoChange; import com.intellij.refactoring.move.MoveCallback; import com.intellij.refactoring.move.MoveHandler; import com.intellij.refactoring.ui.RefactoringDialog; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import kotlin.collections.CollectionsKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,246 +45,393 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration; import org.jetbrains.kotlin.psi.KtObjectDeclaration; import org.jetbrains.kotlin.psi.KtTypeCodeFragment; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public class MoveKotlinNestedClassesDialog extends RefactoringDialog { - private static final String RECENTS_KEY = MoveKotlinNestedClassesDialog.class.getName() + ".RECENTS_KEY"; - private final KtClassOrObject originalClass; - private final MoveCallback moveCallback; - private JPanel mainPanel; - private JTextField originalClassField; - private JPanel membersInfoPanel; - private KotlinTypeReferenceEditorComboWithBrowseButton targetClassChooser; - private JCheckBox openInEditorCheckBox; - private JPanel targetClassChooserPanel; - private KotlinMemberSelectionTable memberTable; - private PsiElement targetClass; + private static final String RECENTS_KEY = MoveKotlinNestedClassesDialog.class.getName() + ".RECENTS_KEY"; + private final KtClassOrObject originalClass; + private final MoveCallback moveCallback; + private final JPanel mainPanel; + private final JTextField originalClassField; + private final JPanel membersInfoPanel; + private KotlinTypeReferenceEditorComboWithBrowseButton targetClassChooser; + private final JCheckBox openInEditorCheckBox; + private final JPanel targetClassChooserPanel; + private KotlinMemberSelectionTable memberTable; + private PsiElement targetClass; - private @Nullable PsiDirectory targetDirectory; - private GlobalSearchScope searchScope; + private @Nullable PsiDirectory targetDirectory; + private GlobalSearchScope searchScope; - public MoveKotlinNestedClassesDialog( - @NotNull Project project, - @NotNull List elementsToMove, - @NotNull KtClassOrObject originalClass, - @NotNull KtClassOrObject targetClass, - @Nullable PsiDirectory targetDirectory, - @Nullable MoveCallback moveCallback - ) { - super(project, true); + public MoveKotlinNestedClassesDialog( + @NotNull Project project, + @NotNull List elementsToMove, + @NotNull KtClassOrObject originalClass, + @NotNull KtClassOrObject targetClass, + @Nullable PsiDirectory targetDirectory, + @Nullable MoveCallback moveCallback + ) { + super(project, true); - this.originalClass = originalClass; - this.targetClass = targetClass; - this.moveCallback = moveCallback; - this.targetDirectory = targetDirectory; - this.searchScope = GlobalSearchScope.projectScope(project); - if (targetDirectory != null) { - Module module = ModuleUtilCore.findModuleForPsiElement(targetDirectory); - if (module != null) - this.searchScope = module.getModuleScope(); + this.originalClass = originalClass; + this.targetClass = targetClass; + this.moveCallback = moveCallback; + this.targetDirectory = targetDirectory; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(5, 5, 5, 5), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "move.members.from")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + originalClassField = new JTextField(); + originalClassField.setEditable(false); + panel1.add(originalClassField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "to.fully.qualified.name")); + panel2.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + targetClassChooserPanel = new JPanel(); + targetClassChooserPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(targetClassChooserPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel3, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + openInEditorCheckBox = new JCheckBox(); + openInEditorCheckBox.setSelected(true); + this.$$$loadButtonText$$$(openInEditorCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "open.moved.members.in.editor")); + panel3.add(openInEditorCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + membersInfoPanel = new JPanel(); + membersInfoPanel.setLayout(new BorderLayout(0, 0)); + mainPanel.add(membersInfoPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + label1.setLabelFor(originalClassField); + } + this.searchScope = GlobalSearchScope.projectScope(project); + if (targetDirectory != null) { + Module module = ModuleUtilCore.findModuleForPsiElement(targetDirectory); + if (module != null) { + this.searchScope = module.getModuleScope(); + } + } + + init(); + + setTitle(MoveHandler.getRefactoringName()); + + initClassChooser(targetClass); + + initMemberInfo(elementsToMove); + + validateButtons(); + + myHelpAction.setEnabled(false); + + initializedCheckBoxesState = getCheckboxesState(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + + private final int initializedCheckBoxesState; + + private int getCheckboxesState() { + return openInEditorCheckBox.isSelected() ? 1 : 0; + } + + private void initClassChooser(@NotNull KtClassOrObject initialTargetClass) { + //noinspection ConstantConditions + originalClassField.setText(originalClass.getFqName().asString()); + + //noinspection ConstantConditions + targetClassChooser = new KotlinTypeReferenceEditorComboWithBrowseButton( + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + TreeClassChooser chooser = new TreeJavaClassChooserDialog( + RefactoringBundle.message("choose.destination.class"), + myProject, + searchScope, + MoveKotlinNestedClassesDialog.this::classMatchesFilter, + null, + null, + true + ); + chooser.selectDirectory( + (targetClass != null ? targetClass : originalClass).getContainingFile().getContainingDirectory()); + chooser.showDialog(); + + PsiClass aClass = chooser.getSelected(); + if (aClass instanceof KtLightClassForSourceDeclaration) { + targetClass = ((KtLightClassForSourceDeclaration)aClass).getKotlinOrigin(); + targetClassChooser.setText(Objects.requireNonNull(aClass.getQualifiedName())); + } + else { + targetClass = aClass; + } + } + }, + initialTargetClass.getFqName().asString(), + originalClass, + RECENTS_KEY); + KtTypeCodeFragment codeFragment = targetClassChooser.getCodeFragment(); + if (codeFragment != null) { + CompletionUtilsKt.setExtraCompletionFilter( + codeFragment, + lookupElement -> { + Object lookupObject = lookupElement.getObject(); + if (!(lookupObject instanceof DescriptorBasedDeclarationLookupObject)) return false; + PsiElement psiElement = ((DescriptorBasedDeclarationLookupObject)lookupObject).getPsiElement(); + if (lookupObject instanceof PackageLookupObject) return true; + return (psiElement instanceof KtClassOrObject) && KotlinCommonRefactoringUtilKt.canRefactorElement(psiElement); + } + ); + } + targetClassChooser.getChildComponent().getDocument().addDocumentListener( + new DocumentListener() { + @Override + public void documentChanged(@NotNull DocumentEvent e) { + PsiClass aClass = JavaPsiFacade + .getInstance(myProject) + .findClass(targetClassChooser.getText(), searchScope); + targetClass = aClass instanceof KtLightClassForSourceDeclaration + ? ((KtLightClassForSourceDeclaration)aClass).getKotlinOrigin() + : aClass; + validateButtons(); + } + } + ); + targetClassChooserPanel.add(targetClassChooser); + } + + private boolean classMatchesFilter(PsiClass aClass) { + if (!searchScope.accept(aClass.getContainingFile().getVirtualFile())) { + return false; + } + + if (targetDirectory != null) { + PsiPackage targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory); + if (targetPackage != null) { + PsiDirectory directory = aClass.getContainingFile().getContainingDirectory(); + PsiPackage classPackage = JavaDirectoryService.getInstance().getPackage(directory); + if (classPackage != null + && !targetPackage.getQualifiedName().equals(classPackage.getQualifiedName())) { + return false; + } + } + } + + if (!(aClass instanceof KtLightClassForSourceDeclaration)) return false; + KtClassOrObject classOrObject = ((KtLightClassForSourceDeclaration)aClass).getKotlinOrigin(); + + if (classOrObject instanceof KtObjectDeclaration) { + return !((KtObjectDeclaration)classOrObject).isObjectLiteral(); + } + + if (classOrObject instanceof KtClass ktClass) { + return !(ktClass.isInner() || ktClass.isAnnotation()); + } + + return false; + } + + private void initMemberInfo(@NotNull List elementsToMove) { + List memberInfos = CollectionsKt.mapNotNull( + originalClass.getDeclarations(), + declaration -> { + if (!(declaration instanceof KtClassOrObject classOrObject)) return null; + + if (classOrObject instanceof KtClass && ((KtClass)classOrObject).isInner()) return null; + if (classOrObject instanceof KtObjectDeclaration && ((KtObjectDeclaration)classOrObject).isCompanion()) { + return null; } - init(); + KotlinMemberInfo memberInfo = new KotlinMemberInfo(classOrObject, false); + memberInfo.setChecked(elementsToMove.contains(declaration)); + return memberInfo; + } + ); + KotlinMemberSelectionPanel selectionPanel = new KotlinMemberSelectionPanel(getTitle(), memberInfos, null); + memberTable = selectionPanel.getTable(); + MemberInfoModelImpl memberInfoModel = new MemberInfoModelImpl(); + memberInfoModel.memberInfoChanged(new MemberInfoChange<>(memberInfos)); + selectionPanel.getTable().setMemberInfoModel(memberInfoModel); + selectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel); + membersInfoPanel.add(selectionPanel, BorderLayout.CENTER); + } - setTitle(MoveHandler.getRefactoringName()); + private List getSelectedElementsToMove() { + return CollectionsKt.map( + memberTable.getSelectedMemberInfos(), + info -> (KtClassOrObject)info.getMember() + ); + } - initClassChooser(targetClass); + @Override + protected JComponent createCenterPanel() { + return mainPanel; + } - initMemberInfo(elementsToMove); + @Override + protected String getDimensionServiceKey() { + return "#" + getClass().getName(); + } - validateButtons(); + private Model getModel() { + return new MoveKotlinNestedClassesModel( + myProject, + openInEditorCheckBox.isSelected(), + getSelectedElementsToMove(), + originalClass, + targetClass, + moveCallback); + } - myHelpAction.setEnabled(false); + @Override + protected void doAction() { - initializedCheckBoxesState = getCheckboxesState(); + ModelResultWithFUSData modelResult; + try { + modelResult = getModel().computeModelResult(); + } + catch (ConfigurationException e) { + setErrorHtml(e.getMessageHtml()); + return; } - private final int initializedCheckBoxesState; - private int getCheckboxesState() { - return openInEditorCheckBox.isSelected() ? 1 : 0; - } + MoveUtilKt.logFusForMoveRefactoring( + modelResult.getElementsCount(), + modelResult.getEntityToMove(), + modelResult.getDestination(), + getCheckboxesState() == initializedCheckBoxesState, + () -> invokeRefactoring(modelResult.getProcessor()) + ); + } - private void initClassChooser(@NotNull KtClassOrObject initialTargetClass) { - //noinspection ConstantConditions - originalClassField.setText(originalClass.getFqName().asString()); + @Override + public JComponent getPreferredFocusedComponent() { + return targetClassChooser.getChildComponent(); + } - //noinspection ConstantConditions - targetClassChooser = new KotlinTypeReferenceEditorComboWithBrowseButton( - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - TreeClassChooser chooser = new TreeJavaClassChooserDialog( - RefactoringBundle.message("choose.destination.class"), - myProject, - searchScope, - MoveKotlinNestedClassesDialog.this::classMatchesFilter, - null, - null, - true - ); - chooser.selectDirectory( - (targetClass != null ? targetClass : originalClass).getContainingFile().getContainingDirectory()); - chooser.showDialog(); - - PsiClass aClass = chooser.getSelected(); - if (aClass instanceof KtLightClassForSourceDeclaration) { - targetClass = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin(); - targetClassChooser.setText(Objects.requireNonNull(aClass.getQualifiedName())); - } - else { - targetClass = aClass; - } - } - }, - initialTargetClass.getFqName().asString(), - originalClass, - RECENTS_KEY); - KtTypeCodeFragment codeFragment = targetClassChooser.getCodeFragment(); - if (codeFragment != null) { - CompletionUtilsKt.setExtraCompletionFilter( - codeFragment, - lookupElement -> { - Object lookupObject = lookupElement.getObject(); - if (!(lookupObject instanceof DescriptorBasedDeclarationLookupObject)) return false; - PsiElement psiElement = ((DescriptorBasedDeclarationLookupObject) lookupObject).getPsiElement(); - if (lookupObject instanceof PackageLookupObject) return true; - return (psiElement instanceof KtClassOrObject) && KotlinCommonRefactoringUtilKt.canRefactorElement(psiElement); - } - ); - } - targetClassChooser.getChildComponent().getDocument().addDocumentListener( - new DocumentListener() { - @Override - public void documentChanged(@NotNull DocumentEvent e) { - PsiClass aClass = JavaPsiFacade - .getInstance(myProject) - .findClass(targetClassChooser.getText(), searchScope); - targetClass = aClass instanceof KtLightClassForSourceDeclaration - ? ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin() - : aClass; - validateButtons(); - } - } - ); - targetClassChooserPanel.add(targetClassChooser); - } - - private boolean classMatchesFilter(PsiClass aClass) { - if (!searchScope.accept(aClass.getContainingFile().getVirtualFile())) - return false; - - if (targetDirectory != null) { - PsiPackage targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory); - if (targetPackage != null) { - PsiDirectory directory = aClass.getContainingFile().getContainingDirectory(); - PsiPackage classPackage = JavaDirectoryService.getInstance().getPackage(directory); - if (classPackage != null - && !targetPackage.getQualifiedName().equals(classPackage.getQualifiedName())) - { - return false; - } - } - } - - if (!(aClass instanceof KtLightClassForSourceDeclaration)) return false; - KtClassOrObject classOrObject = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin(); - - if (classOrObject instanceof KtObjectDeclaration) { - return !((KtObjectDeclaration) classOrObject).isObjectLiteral(); - } - - if (classOrObject instanceof KtClass ktClass) { - return !(ktClass.isInner() || ktClass.isAnnotation()); - } - - return false; - } - - private void initMemberInfo(@NotNull List elementsToMove) { - List memberInfos = CollectionsKt.mapNotNull( - originalClass.getDeclarations(), - declaration -> { - if (!(declaration instanceof KtClassOrObject classOrObject)) return null; - - if (classOrObject instanceof KtClass && ((KtClass) classOrObject).isInner()) return null; - if (classOrObject instanceof KtObjectDeclaration && ((KtObjectDeclaration) classOrObject).isCompanion()) { - return null; - } - - KotlinMemberInfo memberInfo = new KotlinMemberInfo(classOrObject, false); - memberInfo.setChecked(elementsToMove.contains(declaration)); - return memberInfo; - } - ); - KotlinMemberSelectionPanel selectionPanel = new KotlinMemberSelectionPanel(getTitle(), memberInfos, null); - memberTable = selectionPanel.getTable(); - MemberInfoModelImpl memberInfoModel = new MemberInfoModelImpl(); - memberInfoModel.memberInfoChanged(new MemberInfoChange<>(memberInfos)); - selectionPanel.getTable().setMemberInfoModel(memberInfoModel); - selectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel); - membersInfoPanel.add(selectionPanel, BorderLayout.CENTER); - } - - private List getSelectedElementsToMove() { - return CollectionsKt.map( - memberTable.getSelectedMemberInfos(), - info -> (KtClassOrObject) info.getMember() - ); - } - - @Override - protected JComponent createCenterPanel() { - return mainPanel; - } - - @Override - protected String getDimensionServiceKey() { - return "#" + getClass().getName(); - } - - private Model getModel() { - return new MoveKotlinNestedClassesModel( - myProject, - openInEditorCheckBox.isSelected(), - getSelectedElementsToMove(), - originalClass, - targetClass, - moveCallback); - } - - @Override - protected void doAction() { - - ModelResultWithFUSData modelResult; - try { - modelResult = getModel().computeModelResult(); - } - catch (ConfigurationException e) { - setErrorHtml(e.getMessageHtml()); - return; - } - - MoveUtilKt.logFusForMoveRefactoring( - modelResult.getElementsCount(), - modelResult.getEntityToMove(), - modelResult.getDestination(), - getCheckboxesState() == initializedCheckBoxesState, - () -> invokeRefactoring(modelResult.getProcessor()) - ); - } - - @Override - public JComponent getPreferredFocusedComponent() { - return targetClassChooser.getChildComponent(); - } - - private static class MemberInfoModelImpl extends AbstractMemberInfoModel { } + private static class MemberInfoModelImpl extends AbstractMemberInfoModel { + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java index bee3f3dbad71..25ddc798c9d3 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java @@ -15,6 +15,10 @@ import com.intellij.refactoring.ui.NameSuggestionsField; import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo; import com.intellij.refactoring.util.CommonMoveClassesOrPackagesUtil; import com.intellij.ui.EditorTextField; +import com.intellij.ui.NonFocusableCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NonNls; @@ -36,254 +40,399 @@ import org.jetbrains.kotlin.psi.KtClassOrObject; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.types.KotlinType; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.BitSet; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase { - private static final @NonNls String RECENTS_KEY = MoveKotlinNestedClassesToUpperLevelDialog.class.getName() + ".RECENTS_KEY"; + private static final @NonNls String RECENTS_KEY = MoveKotlinNestedClassesToUpperLevelDialog.class.getName() + ".RECENTS_KEY"; - private final Project project; - private final KtClassOrObject innerClass; - private final ClassDescriptor innerClassDescriptor; + private final Project project; + private final KtClassOrObject innerClass; + private final ClassDescriptor innerClassDescriptor; - private final PsiElement targetContainer; - private EditorTextField classNameField; - private NameSuggestionsField parameterField; - private JCheckBox passOuterClassCheckBox; - private JPanel panel; - private JCheckBox searchInCommentsCheckBox; - private JCheckBox searchForTextOccurrencesCheckBox; - private PackageNameReferenceEditorCombo packageNameField; - private JLabel packageNameLabel; - private JLabel classNameLabel; - private JLabel parameterNameLabel; - private JPanel openInEditorPanel; + private final PsiElement targetContainer; + private final EditorTextField classNameField; + private final NameSuggestionsField parameterField; + private final JCheckBox passOuterClassCheckBox; + private final JPanel panel; + private final JCheckBox searchInCommentsCheckBox; + private final JCheckBox searchForTextOccurrencesCheckBox; + private final PackageNameReferenceEditorCombo packageNameField; + private final JLabel packageNameLabel; + private final JLabel classNameLabel; + private final JLabel parameterNameLabel; + private final JPanel openInEditorPanel; - public MoveKotlinNestedClassesToUpperLevelDialog( - @NotNull Project project, - @NotNull KtClassOrObject innerClass, - @NotNull PsiElement targetContainer + public MoveKotlinNestedClassesToUpperLevelDialog( + @NotNull Project project, + @NotNull KtClassOrObject innerClass, + @NotNull PsiElement targetContainer + ) { + super(project, true); + this.project = project; + this.innerClass = innerClass; + this.targetContainer = targetContainer; + { + parameterField = new NameSuggestionsField(project); + packageNameField = new PackageNameReferenceEditorCombo("", project, RECENTS_KEY, + RefactoringBundle.message("choose.destination.package")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(10, 2, new Insets(0, 0, 0, 0), -1, -1)); + classNameLabel = new JLabel(); + this.$$$loadLabelText$$$(classNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "class.name.prompt")); + panel.add(classNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel.add(spacer2, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + classNameField = new EditorTextField(); + panel.add(classNameField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + passOuterClassCheckBox = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(passOuterClassCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "pass.outer.class.instance.as.parameter")); + panel.add(passOuterClassCheckBox, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + parameterNameLabel = new JLabel(); + this.$$$loadLabelText$$$(parameterNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "parameter.name.prompt")); + panel.add(parameterNameLabel, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + panel.add(parameterField, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 1, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); + panel.add(panel1, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + searchInCommentsCheckBox = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(searchInCommentsCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "search.in.comments.and.strings")); + panel1.add(searchInCommentsCheckBox); + searchForTextOccurrencesCheckBox = new NonFocusableCheckBox(); + this.$$$loadButtonText$$$(searchForTextOccurrencesCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "search.for.text.occurrences")); + panel1.add(searchForTextOccurrencesCheckBox); + packageNameLabel = new JLabel(); + this.$$$loadLabelText$$$(packageNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.package.name")); + panel.add(packageNameLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel.add(packageNameField, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + openInEditorPanel = new JPanel(); + openInEditorPanel.setLayout(new BorderLayout(0, 0)); + panel.add(openInEditorPanel, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } + this.innerClassDescriptor = (ClassDescriptor)ResolutionUtils.unsafeResolveToDescriptor(innerClass, BodyResolveMode.FULL); + setTitle(KotlinBundle.message("title.move.nested.classes.to.upper.level")); + init(); + packageNameLabel.setLabelFor(packageNameField.getChildComponent()); + classNameLabel.setLabelFor(classNameField); + parameterNameLabel.setLabelFor(parameterField); + openInEditorPanel.add(initOpenInEditorCb(), BorderLayout.EAST); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + + @Override + protected String getMovePropertySuffix() { + return KotlinBundle.message("text.nested.classes.to.upper.level"); + } + + @Override + protected String getHelpId() { + return HelpID.MOVE_INNER_UPPER; + } + + @Override + protected String getCbTitle() { + return KotlinBundle.message("checkbox.text.open.moved.files.in.editor"); + } + + public String getClassName() { + return classNameField.getText().trim(); + } + + public @Nullable String getParameterName() { + return parameterField != null ? parameterField.getEnteredName() : null; + } + + private boolean isThisNeeded() { + return innerClass instanceof KtClass && MoveUtilKt.traverseOuterInstanceReferences(innerClass, true); + } + + private @Nullable FqName getTargetPackageFqName() { + return MoveUtilKt.getTargetPackageFqName(targetContainer); + } + + private @NotNull KotlinType getOuterInstanceType() { + return ((ClassDescriptor)innerClassDescriptor.getContainingDeclaration()).getDefaultType(); + } + + private BitSet initializedCheckBoxesState; + + private BitSet getCheckboxesState(boolean applyDefaults) { + + BitSet state = new BitSet(3); + + state.set(0, !applyDefaults && searchInCommentsCheckBox.isSelected()); //searchInCommentsCheckBox default is false + state.set(1, !applyDefaults && searchForTextOccurrencesCheckBox.isSelected()); //searchForTextOccurrencesCheckBox default is false + state.set(2, passOuterClassCheckBox.isSelected()); + + return state; + } + + + @Override + protected void init() { + classNameField.setText(innerClass.getName()); + classNameField.selectAll(); + + if (innerClass instanceof KtClass && ((KtClass)innerClass).isInner()) { + passOuterClassCheckBox.setSelected(true); + passOuterClassCheckBox.addItemListener(e -> parameterField.setEnabled(passOuterClassCheckBox.isSelected())); + } + else { + passOuterClassCheckBox.setSelected(false); + passOuterClassCheckBox.setEnabled(false); + parameterField.setEnabled(false); + } + + if (passOuterClassCheckBox.isEnabled()) { + boolean thisNeeded = isThisNeeded(); + passOuterClassCheckBox.setSelected(thisNeeded); + parameterField.setEnabled(thisNeeded); + } + + passOuterClassCheckBox.addItemListener(e -> { + boolean selected = passOuterClassCheckBox.isSelected(); + parameterField.getComponent().setEnabled(selected); + }); + + if (!(targetContainer instanceof PsiDirectory)) { + packageNameField.setVisible(false); + packageNameLabel.setVisible(false); + } + + if (innerClass instanceof KtClass && ((KtClass)innerClass).isInner()) { + KtClassBody innerClassBody = innerClass.getBody(); + Function1 validator = + innerClassBody != null + ? new Fe10KotlinNewDeclarationNameValidator(innerClassBody, (PsiElement)null, + KotlinNameSuggestionProvider.ValidatorTarget.PARAMETER, + Collections.emptyList()) + : new CollectingNameValidator(); + List suggestions = Fe10KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer"); + parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions)); + } + else { + parameterField.getComponent().setEnabled(false); + } + + FqName packageFqName = getTargetPackageFqName(); + if (packageFqName != null) { + packageNameField.prependItem(packageFqName.asString()); + } + + KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); + searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT); + searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS); + + super.init(); + + initializedCheckBoxesState = getCheckboxesState(true); + } + + @Override + public JComponent getPreferredFocusedComponent() { + return classNameField; + } + + @Override + protected String getDimensionServiceKey() { + return "#com.intellij.refactoring.move.moveInner.MoveInnerDialog"; + } + + @Override + protected JComponent createNorthPanel() { + return panel; + } + + @Override + protected JComponent createCenterPanel() { + return null; + } + + + private static class MoveKotlinNestedClassesToUpperLevelModelWithUIChooser extends MoveKotlinNestedClassesToUpperLevelModel { + public MoveKotlinNestedClassesToUpperLevelModelWithUIChooser( + @NotNull Project project, + @NotNull KtClassOrObject innerClass, + @NotNull PsiElement target, + @Nullable String parameter, + @NotNull String className, + boolean passOuterClass, + boolean searchInComments, + boolean isSearchInNonJavaFiles, + @NotNull String packageName, + boolean isOpenInEditor ) { - super(project, true); - this.project = project; - this.innerClass = innerClass; - this.targetContainer = targetContainer; - this.innerClassDescriptor = (ClassDescriptor) ResolutionUtils.unsafeResolveToDescriptor(innerClass, BodyResolveMode.FULL); - setTitle(KotlinBundle.message("title.move.nested.classes.to.upper.level")); - init(); - packageNameLabel.setLabelFor(packageNameField.getChildComponent()); - classNameLabel.setLabelFor(classNameField); - parameterNameLabel.setLabelFor(parameterField); - openInEditorPanel.add(initOpenInEditorCb(), BorderLayout.EAST); - } - - private void createUIComponents() { - parameterField = new NameSuggestionsField(project); - packageNameField = new PackageNameReferenceEditorCombo("", project, RECENTS_KEY, - RefactoringBundle.message("choose.destination.package")); + super(project, innerClass, target, parameter, className, passOuterClass, searchInComments, isSearchInNonJavaFiles, packageName, + isOpenInEditor); } @Override - protected String getMovePropertySuffix() { - return KotlinBundle.message("text.nested.classes.to.upper.level"); + protected @Nullable VirtualFile chooseSourceRoot( + @NotNull PackageWrapper newPackage, + @NotNull List contentSourceRoots, + @Nullable PsiDirectory initialDir + ) { + return CommonMoveClassesOrPackagesUtil.chooseSourceRoot(newPackage, contentSourceRoots, initialDir); + } + } + + private Model getModel() { + return new MoveKotlinNestedClassesToUpperLevelModelWithUIChooser( + project, + innerClass, + targetContainer, + getParameterName(), + getClassName(), + passOuterClassCheckBox.isSelected(), + searchInCommentsCheckBox.isSelected(), + searchForTextOccurrencesCheckBox.isSelected(), + packageNameField.getText(), + isOpenInEditor() + ); + } + + @Override + protected void doAction() { + + ModelResultWithFUSData modelResult; + try { + modelResult = getModel().computeModelResult(); + } + catch (ConfigurationException e) { + setErrorHtml(e.getMessageHtml()); + return; } - @Override - protected String getHelpId() { - return HelpID.MOVE_INNER_UPPER; - } + KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); + settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT = searchForTextOccurrencesCheckBox.isSelected(); + settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS = searchInCommentsCheckBox.isSelected(); - @Override - protected String getCbTitle() { - return KotlinBundle.message("checkbox.text.open.moved.files.in.editor"); - } + saveOpenInEditorOption(); - public String getClassName() { - return classNameField.getText().trim(); - } - - public @Nullable String getParameterName() { - return parameterField != null ? parameterField.getEnteredName() : null; - } - - private boolean isThisNeeded() { - return innerClass instanceof KtClass && MoveUtilKt.traverseOuterInstanceReferences(innerClass, true); - } - - private @Nullable FqName getTargetPackageFqName() { - return MoveUtilKt.getTargetPackageFqName(targetContainer); - } - - private @NotNull KotlinType getOuterInstanceType() { - return ((ClassDescriptor) innerClassDescriptor.getContainingDeclaration()).getDefaultType(); - } - - private BitSet initializedCheckBoxesState; - private BitSet getCheckboxesState(boolean applyDefaults) { - - BitSet state = new BitSet(3); - - state.set(0, !applyDefaults && searchInCommentsCheckBox.isSelected()); //searchInCommentsCheckBox default is false - state.set(1, !applyDefaults && searchForTextOccurrencesCheckBox.isSelected()); //searchForTextOccurrencesCheckBox default is false - state.set(2, passOuterClassCheckBox.isSelected()); - - return state; - } - - - @Override - protected void init() { - classNameField.setText(innerClass.getName()); - classNameField.selectAll(); - - if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) { - passOuterClassCheckBox.setSelected(true); - passOuterClassCheckBox.addItemListener(e -> parameterField.setEnabled(passOuterClassCheckBox.isSelected())); - } - else { - passOuterClassCheckBox.setSelected(false); - passOuterClassCheckBox.setEnabled(false); - parameterField.setEnabled(false); - } - - if (passOuterClassCheckBox.isEnabled()) { - boolean thisNeeded = isThisNeeded(); - passOuterClassCheckBox.setSelected(thisNeeded); - parameterField.setEnabled(thisNeeded); - } - - passOuterClassCheckBox.addItemListener(e -> { - boolean selected = passOuterClassCheckBox.isSelected(); - parameterField.getComponent().setEnabled(selected); - }); - - if (!(targetContainer instanceof PsiDirectory)) { - packageNameField.setVisible(false); - packageNameLabel.setVisible(false); - } - - if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) { - KtClassBody innerClassBody = innerClass.getBody(); - Function1 validator = - innerClassBody != null - ? new Fe10KotlinNewDeclarationNameValidator(innerClassBody, (PsiElement) null, - KotlinNameSuggestionProvider.ValidatorTarget.PARAMETER, - Collections.emptyList()) - : new CollectingNameValidator(); - List suggestions = Fe10KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer"); - parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions)); - } - else { - parameterField.getComponent().setEnabled(false); - } - - FqName packageFqName = getTargetPackageFqName(); - if (packageFqName != null) { - packageNameField.prependItem(packageFqName.asString()); - } - - KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); - searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT); - searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS); - - super.init(); - - initializedCheckBoxesState = getCheckboxesState(true); - } - - @Override - public JComponent getPreferredFocusedComponent() { - return classNameField; - } - - @Override - protected String getDimensionServiceKey() { - return "#com.intellij.refactoring.move.moveInner.MoveInnerDialog"; - } - - @Override - protected JComponent createNorthPanel() { - return panel; - } - - @Override - protected JComponent createCenterPanel() { - return null; - } - - - private static class MoveKotlinNestedClassesToUpperLevelModelWithUIChooser extends MoveKotlinNestedClassesToUpperLevelModel { - public MoveKotlinNestedClassesToUpperLevelModelWithUIChooser( - @NotNull Project project, - @NotNull KtClassOrObject innerClass, - @NotNull PsiElement target, - @Nullable String parameter, - @NotNull String className, - boolean passOuterClass, - boolean searchInComments, - boolean isSearchInNonJavaFiles, - @NotNull String packageName, - boolean isOpenInEditor - ) { - super(project, innerClass, target, parameter, className, passOuterClass, searchInComments, isSearchInNonJavaFiles, packageName, - isOpenInEditor); - } - - @Override - protected @Nullable VirtualFile chooseSourceRoot( - @NotNull PackageWrapper newPackage, - @NotNull List contentSourceRoots, - @Nullable PsiDirectory initialDir - ) { - return CommonMoveClassesOrPackagesUtil.chooseSourceRoot(newPackage, contentSourceRoots, initialDir); - } - } - - private Model getModel() { - return new MoveKotlinNestedClassesToUpperLevelModelWithUIChooser( - project, - innerClass, - targetContainer, - getParameterName(), - getClassName(), - passOuterClassCheckBox.isSelected(), - searchInCommentsCheckBox.isSelected(), - searchForTextOccurrencesCheckBox.isSelected(), - packageNameField.getText(), - isOpenInEditor() - ); - } - - @Override - protected void doAction() { - - ModelResultWithFUSData modelResult; - try { - modelResult = getModel().computeModelResult(); - } - catch (ConfigurationException e) { - setErrorHtml(e.getMessageHtml()); - return; - } - - KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); - settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT = searchForTextOccurrencesCheckBox.isSelected(); - settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS = searchInCommentsCheckBox.isSelected(); - - saveOpenInEditorOption(); - - MoveUtilKt.logFusForMoveRefactoring( - modelResult.getElementsCount(), - modelResult.getEntityToMove(), - modelResult.getDestination(), - getCheckboxesState(false).equals(initializedCheckBoxesState), - () -> invokeRefactoring(modelResult.getProcessor()) - ); - } + MoveUtilKt.logFusForMoveRefactoring( + modelResult.getElementsCount(), + modelResult.getEntityToMove(), + modelResult.getDestination(), + getCheckboxesState(false).equals(initializedCheckBoxesState), + () -> invokeRefactoring(modelResult.getProcessor()) + ); + } } \ No newline at end of file diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java index 60b8f3abf97d..aba74fb584b0 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsDialog.java @@ -21,8 +21,12 @@ import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.ui.ComboboxWithBrowseButton; +import com.intellij.ui.NonFocusableCheckBox; import com.intellij.ui.RecentsManager; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.IncorrectOperationException; import com.intellij.util.ui.UIUtil; import kotlin.collections.CollectionsKt; @@ -44,449 +48,650 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration; import org.jetbrains.kotlin.psi.KtPureElement; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; import java.util.BitSet; import java.util.Collection; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import static org.jetbrains.kotlin.idea.roots.ProjectRootUtilsKt.getSuitableDestinationSourceRoots; public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog { - private static final String RECENTS_KEY = "MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY"; - private final MoveCallback moveCallback; - private final PsiDirectory initialTargetDirectory; - private JCheckBox cbSearchInComments; - private JCheckBox cbSearchTextOccurrences; - private JPanel mainPanel; - private ReferenceEditorComboWithBrowseButton classPackageChooser; - private ComboboxWithBrowseButton destinationFolderCB; - private JPanel targetPanel; - private JRadioButton rbMoveToPackage; - private JRadioButton rbMoveToFile; - private TextFieldWithBrowseButton fileChooser; - private JPanel memberInfoPanel; - private JTextField tfFileNameInPackage; - private JCheckBox cbDeleteEmptySourceFiles; - private JCheckBox cbSearchReferences; - private JCheckBox cbApplyMPPDeclarationsMove; - private KotlinMemberSelectionTable memberTable; + private static final String RECENTS_KEY = "MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY"; + private final MoveCallback moveCallback; + private final PsiDirectory initialTargetDirectory; + private final JCheckBox cbSearchInComments; + private final JCheckBox cbSearchTextOccurrences; + private final JPanel mainPanel; + private final ReferenceEditorComboWithBrowseButton classPackageChooser; + private final ComboboxWithBrowseButton destinationFolderCB; + private final JPanel targetPanel; + private final JRadioButton rbMoveToPackage; + private final JRadioButton rbMoveToFile; + private final TextFieldWithBrowseButton fileChooser; + private final JPanel memberInfoPanel; + private final JTextField tfFileNameInPackage; + private final JCheckBox cbDeleteEmptySourceFiles; + private final JCheckBox cbSearchReferences; + private final JCheckBox cbApplyMPPDeclarationsMove; + private KotlinMemberSelectionTable memberTable; - private final boolean freezeTargets; + private final boolean freezeTargets; - public MoveKotlinTopLevelDeclarationsDialog( - @NotNull Project project, - @NotNull Set elementsToMove, - @Nullable String targetPackageName, - @Nullable PsiDirectory targetDirectory, - @Nullable KtFile targetFile, - boolean freezeTargets, - boolean moveToPackage, - @Nullable MoveCallback moveCallback - ) { - this(project, - elementsToMove, - targetPackageName, - targetDirectory, - targetFile, - freezeTargets, - moveToPackage, - KotlinRefactoringSettings.getInstance().MOVE_SEARCH_IN_COMMENTS, - KotlinRefactoringSettings.getInstance().MOVE_SEARCH_FOR_TEXT, - KotlinRefactoringSettings.getInstance().MOVE_DELETE_EMPTY_SOURCE_FILES, - KotlinRefactoringSettings.getInstance().MOVE_MPP_DECLARATIONS, - moveCallback); + public MoveKotlinTopLevelDeclarationsDialog( + @NotNull Project project, + @NotNull Set elementsToMove, + @Nullable String targetPackageName, + @Nullable PsiDirectory targetDirectory, + @Nullable KtFile targetFile, + boolean freezeTargets, + boolean moveToPackage, + @Nullable MoveCallback moveCallback + ) { + this(project, + elementsToMove, + targetPackageName, + targetDirectory, + targetFile, + freezeTargets, + moveToPackage, + KotlinRefactoringSettings.getInstance().MOVE_SEARCH_IN_COMMENTS, + KotlinRefactoringSettings.getInstance().MOVE_SEARCH_FOR_TEXT, + KotlinRefactoringSettings.getInstance().MOVE_DELETE_EMPTY_SOURCE_FILES, + KotlinRefactoringSettings.getInstance().MOVE_MPP_DECLARATIONS, + moveCallback); + } + + public MoveKotlinTopLevelDeclarationsDialog( + @NotNull Project project, + @NotNull Set elementsToMove, + @Nullable String targetPackageName, + @Nullable PsiDirectory targetDirectory, + @Nullable KtFile targetFile, + boolean freezeTargets, + boolean moveToPackage, + boolean searchInComments, + boolean searchForTextOccurrences, + boolean deleteEmptySourceFiles, + boolean moveMppDeclarations, + @Nullable MoveCallback moveCallback + ) { + super(project, true); + this.freezeTargets = freezeTargets; + { + classPackageChooser = createPackageChooser(); + + destinationFolderCB = new KotlinDestinationFolderComboBox() { + @Override + public String getTargetPackage() { + return MoveKotlinTopLevelDeclarationsDialog.this.getTargetPackage(); + } + + @Override + protected boolean sourceRootsInTargetDirOnly() { + return !freezeTargets; + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(0, 0)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new BorderLayout(0, 0)); + mainPanel.add(panel1, BorderLayout.CENTER); + memberInfoPanel = new JPanel(); + memberInfoPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(memberInfoPanel, BorderLayout.CENTER); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, BorderLayout.SOUTH); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(6, 2, new Insets(7, 0, 7, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel3.add(classPackageChooser, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + rbMoveToPackage = new JRadioButton(); + this.$$$loadButtonText$$$(rbMoveToPackage, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.to.package")); + panel3.add(rbMoveToPackage, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + fileChooser = new TextFieldWithBrowseButton(); + panel3.add(fileChooser, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + rbMoveToFile = new JRadioButton(); + this.$$$loadButtonText$$$(rbMoveToFile, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.to.file")); + panel3.add(rbMoveToFile, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.file.name")); + panel3.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 5, + false)); + tfFileNameInPackage = new JTextField(); + tfFileNameInPackage.setEnabled(false); + panel3.add(tfFileNameInPackage, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + targetPanel = new JPanel(); + targetPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(targetPanel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 5, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.destination.directory")); + targetPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + targetPanel.add(destinationFolderCB, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + cbSearchInComments = new NonFocusableCheckBox(); + cbSearchInComments.setSelected(true); + this.$$$loadButtonText$$$(cbSearchInComments, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "search.in.comments.and.strings")); + panel4.add(cbSearchInComments, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cbSearchTextOccurrences = new NonFocusableCheckBox(); + cbSearchTextOccurrences.setSelected(true); + this.$$$loadButtonText$$$(cbSearchTextOccurrences, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "search.for.text.occurrences")); + panel4.add(cbSearchTextOccurrences, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cbSearchReferences = new JCheckBox(); + cbSearchReferences.setSelected(true); + this.$$$loadButtonText$$$(cbSearchReferences, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "checkbox.text.search.references")); + panel4.add(cbSearchReferences, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cbDeleteEmptySourceFiles = new JCheckBox(); + cbDeleteEmptySourceFiles.setSelected(true); + this.$$$loadButtonText$$$(cbDeleteEmptySourceFiles, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "checkbox.text.delete.empty.source.files")); + panel4.add(cbDeleteEmptySourceFiles, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cbApplyMPPDeclarationsMove = new JCheckBox(); + cbApplyMPPDeclarationsMove.setSelected(true); + this.$$$loadButtonText$$$(cbApplyMPPDeclarationsMove, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.move.expect.actual.counterparts")); + panel4.add(cbApplyMPPDeclarationsMove, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(tfFileNameInPackage); + label2.setLabelFor(destinationFolderCB); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(rbMoveToPackage); + buttonGroup.add(rbMoveToFile); } - public MoveKotlinTopLevelDeclarationsDialog( - @NotNull Project project, - @NotNull Set elementsToMove, - @Nullable String targetPackageName, - @Nullable PsiDirectory targetDirectory, - @Nullable KtFile targetFile, - boolean freezeTargets, - boolean moveToPackage, - boolean searchInComments, - boolean searchForTextOccurrences, - boolean deleteEmptySourceFiles, - boolean moveMppDeclarations, - @Nullable MoveCallback moveCallback - ) { - super(project, true); - this.freezeTargets = freezeTargets; + init(); - init(); + List sourceFiles = getSourceFiles(elementsToMove); - List sourceFiles = getSourceFiles(elementsToMove); - - this.moveCallback = moveCallback; - this.initialTargetDirectory = targetDirectory; + this.moveCallback = moveCallback; + this.initialTargetDirectory = targetDirectory; - setTitle(MoveHandler.getRefactoringName()); + setTitle(MoveHandler.getRefactoringName()); - List allDeclarations = getAllDeclarations(sourceFiles); + List allDeclarations = getAllDeclarations(sourceFiles); - initSearchOptions(searchInComments, searchForTextOccurrences, deleteEmptySourceFiles, moveMppDeclarations, allDeclarations); + initSearchOptions(searchInComments, searchForTextOccurrences, deleteEmptySourceFiles, moveMppDeclarations, allDeclarations); - initPackageChooser(targetPackageName, targetDirectory, sourceFiles); + initPackageChooser(targetPackageName, targetDirectory, sourceFiles); - initFileChooser(targetFile, freezeTargets ? targetDirectory : null, elementsToMove, sourceFiles); + initFileChooser(targetFile, freezeTargets ? targetDirectory : null, elementsToMove, sourceFiles); - initMoveToButtons(moveToPackage); + initMoveToButtons(moveToPackage); - initMemberInfo(elementsToMove, allDeclarations); + initMemberInfo(elementsToMove, allDeclarations); + updateControls(); + + initializedCheckBoxesState = getCheckboxesState(true); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + + private final BitSet initializedCheckBoxesState; + + private BitSet getCheckboxesState(boolean applyDefaults) { + + BitSet state = new BitSet(5); + + state.set(0, applyDefaults || cbSearchInComments.isSelected()); //cbSearchInComments default is true + state.set(1, applyDefaults || cbSearchTextOccurrences.isSelected()); //cbSearchTextOccurrences default is true + state.set(2, applyDefaults || cbDeleteEmptySourceFiles.isSelected()); //cbDeleteEmptySourceFiles default is true + state.set(3, applyDefaults || cbApplyMPPDeclarationsMove.isSelected()); //cbApplyMPPDeclarationsMove default is true + state.set(4, cbSearchReferences.isSelected()); + + return state; + } + + private static List getSourceFiles(@NotNull Collection elementsToMove) { + return CollectionsKt.distinct( + CollectionsKt.map( + elementsToMove, + KtPureElement::getContainingKtFile + ) + ); + } + + private static List getAllDeclarations(Collection sourceFiles) { + return CollectionsKt.filterIsInstance( + CollectionsKt.flatMap( + sourceFiles, + KtPsiUtilKt::getFileOrScriptDeclarations + ), + KtNamedDeclaration.class + ); + } + + private void initMemberInfo( + @NotNull Set elementsToMove, + @NotNull List declarations + ) { + //KotlinMemberInfo run resolve on declaration so it is good to place it to the process + List memberInfos = + MoveUtilKt.mapWithReadActionInProcess(declarations, myProject, MoveHandler.getRefactoringName(), (declaration) -> { + KotlinMemberInfo memberInfo = new KotlinMemberInfo(declaration, false); + memberInfo.setChecked(elementsToMove.contains(declaration)); + return memberInfo; + }); + + KotlinMemberSelectionPanel selectionPanel = new KotlinMemberSelectionPanel(getTitle(), memberInfos, null); + memberTable = selectionPanel.getTable(); + MemberInfoModelImpl memberInfoModel = new MemberInfoModelImpl(); + memberInfoModel.memberInfoChanged(new MemberInfoChange<>(memberInfos)); + selectionPanel.getTable().setMemberInfoModel(memberInfoModel); + selectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel); + selectionPanel.getTable().addMemberInfoChangeListener(listener -> updateControls()); + cbApplyMPPDeclarationsMove.addChangeListener(e -> updateControls()); + memberInfoPanel.add(selectionPanel, BorderLayout.CENTER); + } + + private void updateSuggestedFileName() { + tfFileNameInPackage.setText(MoveUtilKt.guessNewFileName(getSelectedElementsToMove())); + } + + private void updateFileNameInPackageField() { + boolean movingSingleFileToPackage = rbMoveToPackage.isSelected() && getSourceFiles(getSelectedElementsToMove()).size() == 1; + tfFileNameInPackage.setEnabled(movingSingleFileToPackage); + } + + private void initPackageChooser( + String targetPackageName, + PsiDirectory targetDirectory, + List sourceFiles + ) { + if (targetPackageName != null) { + classPackageChooser.prependItem(targetPackageName); + classPackageChooser.setEnabled(freezeTargets); + } + + ((KotlinDestinationFolderComboBox)destinationFolderCB).setData( + myProject, + targetDirectory, + s -> setErrorText(s), + classPackageChooser.getChildComponent() + ); + } + + private void initSearchOptions( + boolean searchInComments, + boolean searchForTextOccurences, + boolean deleteEmptySourceFiles, + boolean moveMppDeclarations, + List allDeclarations + ) { + cbSearchInComments.setSelected(searchInComments); + cbSearchTextOccurrences.setSelected(searchForTextOccurences); + cbDeleteEmptySourceFiles.setSelected(deleteEmptySourceFiles); + cbApplyMPPDeclarationsMove.setSelected(moveMppDeclarations); + cbApplyMPPDeclarationsMove.setVisible(isMPPDeclarationInList(allDeclarations)); + } + + private void initMoveToButtons(boolean moveToPackage) { + if (moveToPackage) { + rbMoveToPackage.setSelected(true); + } + else { + rbMoveToFile.setSelected(true); + } + + rbMoveToPackage.addActionListener( + e -> { + classPackageChooser.requestFocus(); updateControls(); + } + ); - initializedCheckBoxesState = getCheckboxesState(true); + rbMoveToFile.addActionListener( + e -> { + fileChooser.requestFocus(); + updateControls(); + } + ); + } + + private void initFileChooser( + @Nullable KtFile targetFile, + @Nullable PsiDirectory targetDirectory, + @NotNull Set elementsToMove, + @NotNull List sourceFiles + ) { + PsiDirectory sourceDir = sourceFiles.get(0).getParent(); + if (sourceDir == null) { + throw new AssertionError("File chooser initialization failed"); } - private final BitSet initializedCheckBoxesState; - private BitSet getCheckboxesState(boolean applyDefaults) { + Module targetModule = (targetDirectory != null) ? ModuleUtilCore.findModuleForPsiElement(targetDirectory) : null; + GlobalSearchScope targetModuleScope = targetModule == null ? null + : GlobalSearchScope.getScopeRestrictedByFileTypes( + targetModule.getModuleScope(), KotlinFileType.INSTANCE); - BitSet state = new BitSet(5); + fileChooser.addActionListener(e -> { + KotlinFileChooserDialog dialog = new KotlinFileChooserDialog( + KotlinBundle.message("text.choose.containing.file"), + myProject, + targetModuleScope, freezeTargets ? null : getTargetPackage()); - state.set(0, applyDefaults || cbSearchInComments.isSelected()); //cbSearchInComments default is true - state.set(1, applyDefaults || cbSearchTextOccurrences.isSelected()); //cbSearchTextOccurrences default is true - state.set(2, applyDefaults || cbDeleteEmptySourceFiles.isSelected()); //cbDeleteEmptySourceFiles default is true - state.set(3, applyDefaults || cbApplyMPPDeclarationsMove.isSelected()); //cbApplyMPPDeclarationsMove default is true - state.set(4, cbSearchReferences.isSelected()); + File targetFile1 = new File(fileChooser.getText()); + PsiFile targetPsiFile = PhysicalFileSystemUtilsKt.toPsiFile(targetFile1, myProject); - return state; + if (targetPsiFile != null) { + if (targetPsiFile instanceof KtFile) { + dialog.select((KtFile)targetPsiFile); + } + else { + PsiDirectory targetDir = PhysicalFileSystemUtilsKt.toPsiDirectory(targetFile1.getParentFile(), myProject); + if (targetDir != null) { + dialog.selectDirectory(targetDir); + } + else { + dialog.selectDirectory(sourceDir); + } + } + } + else { + dialog.selectDirectory(sourceDir); + } + + dialog.showDialog(); + KtFile selectedFile = dialog.isOK() ? dialog.getSelected() : null; + if (selectedFile != null) { + fileChooser.setText(selectedFile.getVirtualFile().getPath()); + } + } + ); + + String initialTargetPath = targetFile != null + ? targetFile.getVirtualFile().getPath() + : sourceFiles.get(0).getVirtualFile().getParent().getPath() + + "/" + + MoveUtilKt.guessNewFileName(elementsToMove); + fileChooser.setText(initialTargetPath); + } + + private ReferenceEditorComboWithBrowseButton createPackageChooser() { + return new PackageNameReferenceEditorCombo( + "", + myProject, + RECENTS_KEY, + RefactoringBundle.message("choose.destination.package") + ); + } + + private static boolean isMPPDeclarationInList(List declarations) { + for (KtNamedDeclaration element : declarations) { + if (ExpectActualUtilKt.isEffectivelyActual(element, true) || + ExpectActualUtilKt.isExpectDeclaration(element)) { + return true; + } + } + return false; + } + + private boolean isMppDeclarationSelected() { + return isMPPDeclarationInList(getSelectedElementsToMove()); + } + + private void updateControls() { + + boolean mppDeclarationSelected = isMppDeclarationSelected(); + cbApplyMPPDeclarationsMove.setEnabled(mppDeclarationSelected); + + boolean needToMoveMPPDeclarations = mppDeclarationSelected && cbApplyMPPDeclarationsMove.isSelected(); + + if (needToMoveMPPDeclarations) { + if (!rbMoveToPackage.isSelected()) { + rbMoveToPackage.setSelected(true); + } + } + UIUtil.setEnabled(rbMoveToFile, !needToMoveMPPDeclarations, true); + + boolean moveToPackage = rbMoveToPackage.isSelected(); + classPackageChooser.setEnabled(moveToPackage && freezeTargets); + updateFileNameInPackageField(); + fileChooser.setEnabled(!moveToPackage); + UIUtil.setEnabled(targetPanel, moveToPackage && !needToMoveMPPDeclarations && hasAnySourceRoots(), true); + updateSuggestedFileName(); + myHelpAction.setEnabled(false); + } + + private boolean hasAnySourceRoots() { + return !getSuitableDestinationSourceRoots(myProject).isEmpty(); + } + + private void saveRefactoringSettings() { + KotlinRefactoringSettings refactoringSettings = KotlinRefactoringSettings.getInstance(); + refactoringSettings.MOVE_SEARCH_IN_COMMENTS = cbSearchInComments.isSelected(); + refactoringSettings.MOVE_SEARCH_FOR_TEXT = cbSearchTextOccurrences.isSelected(); + refactoringSettings.MOVE_DELETE_EMPTY_SOURCE_FILES = cbDeleteEmptySourceFiles.isSelected(); + refactoringSettings.MOVE_PREVIEW_USAGES = isPreviewUsages(); + refactoringSettings.MOVE_MPP_DECLARATIONS = cbApplyMPPDeclarationsMove.isSelected(); + + RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, getTargetPackage()); + } + + private List getSelectedElementsToMove() { + return CollectionsKt.map( + memberTable.getSelectedMemberInfos(), + MemberInfoBase::getMember + ); + } + + @Override + protected JComponent createCenterPanel() { + return mainPanel; + } + + @Override + protected String getDimensionServiceKey() { + return "#" + getClass().getName(); + } + + private String getTargetPackage() { + return classPackageChooser.getText().trim(); + } + + private List getSelectedElementsToMoveChecked() throws ConfigurationException { + List elementsToMove = getSelectedElementsToMove(); + if (elementsToMove.isEmpty()) { + throw new ConfigurationException(KotlinBundle.message("text.no.elements.to.move.are.selected")); + } + return elementsToMove; + } + + private MoveKotlinTopLevelDeclarationsModel getModel() throws ConfigurationException { + + boolean mppDeclarationSelected = cbApplyMPPDeclarationsMove.isSelected() && isMppDeclarationSelected(); + + PsiDirectory selectedPsiDirectory = null; + if (!mppDeclarationSelected) { + DirectoryChooser.ItemWrapper selectedItem = (DirectoryChooser.ItemWrapper)destinationFolderCB.getComboBox().getSelectedItem(); + selectedPsiDirectory = selectedItem != null ? selectedItem.getDirectory() : initialTargetDirectory; } - private static List getSourceFiles(@NotNull Collection elementsToMove) { - return CollectionsKt.distinct( - CollectionsKt.map( - elementsToMove, - KtPureElement::getContainingKtFile - ) - ); + List selectedElements = getSelectedElementsToMoveChecked(); + + return new MoveKotlinTopLevelDeclarationsModel( + myProject, + selectedElements, + getTargetPackage(), + selectedPsiDirectory, + tfFileNameInPackage.getText(), + fileChooser.getText(), + rbMoveToPackage.isSelected(), + cbSearchReferences.isSelected(), + cbSearchInComments.isSelected(), + cbSearchTextOccurrences.isSelected(), + cbDeleteEmptySourceFiles.isSelected(), + mppDeclarationSelected, + moveCallback + ); + } + + @Override + protected void doAction() { + + ModelResultWithFUSData modelResult; + try { + modelResult = getModel().computeModelResult(); + } + catch (ConfigurationException e) { + setErrorHtml(e.getMessageHtml()); + return; } - private static List getAllDeclarations(Collection sourceFiles) { - return CollectionsKt.filterIsInstance( - CollectionsKt.flatMap( - sourceFiles, - KtPsiUtilKt::getFileOrScriptDeclarations - ), - KtNamedDeclaration.class - ); + saveRefactoringSettings(); + + try { + MoveUtilKt.logFusForMoveRefactoring( + modelResult.getElementsCount(), + modelResult.getEntityToMove(), + modelResult.getDestination(), + getCheckboxesState(false).equals(initializedCheckBoxesState), + () -> invokeRefactoring(modelResult.getProcessor()) + ); } - - private void initMemberInfo( - @NotNull Set elementsToMove, - @NotNull List declarations - ) { - //KotlinMemberInfo run resolve on declaration so it is good to place it to the process - List memberInfos = MoveUtilKt.mapWithReadActionInProcess(declarations, myProject, MoveHandler.getRefactoringName(), (declaration) -> { - KotlinMemberInfo memberInfo = new KotlinMemberInfo(declaration, false); - memberInfo.setChecked(elementsToMove.contains(declaration)); - return memberInfo; - }); - - KotlinMemberSelectionPanel selectionPanel = new KotlinMemberSelectionPanel(getTitle(), memberInfos, null); - memberTable = selectionPanel.getTable(); - MemberInfoModelImpl memberInfoModel = new MemberInfoModelImpl(); - memberInfoModel.memberInfoChanged(new MemberInfoChange<>(memberInfos)); - selectionPanel.getTable().setMemberInfoModel(memberInfoModel); - selectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel); - selectionPanel.getTable().addMemberInfoChangeListener(listener -> updateControls()); - cbApplyMPPDeclarationsMove.addChangeListener(e -> updateControls()); - memberInfoPanel.add(selectionPanel, BorderLayout.CENTER); + catch (IncorrectOperationException e) { + CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.getMessage(), null, myProject); } + } - private void updateSuggestedFileName() { - tfFileNameInPackage.setText(MoveUtilKt.guessNewFileName(getSelectedElementsToMove())); - } + @Override + public JComponent getPreferredFocusedComponent() { + return classPackageChooser.getChildComponent(); + } - private void updateFileNameInPackageField() { - boolean movingSingleFileToPackage = rbMoveToPackage.isSelected() && getSourceFiles(getSelectedElementsToMove()).size() == 1; - tfFileNameInPackage.setEnabled(movingSingleFileToPackage); - } - - private void initPackageChooser( - String targetPackageName, - PsiDirectory targetDirectory, - List sourceFiles - ) { - if (targetPackageName != null) { - classPackageChooser.prependItem(targetPackageName); - classPackageChooser.setEnabled(freezeTargets); - } - - ((KotlinDestinationFolderComboBox) destinationFolderCB).setData( - myProject, - targetDirectory, - s-> setErrorText(s), - classPackageChooser.getChildComponent() - ); - } - - private void initSearchOptions( - boolean searchInComments, - boolean searchForTextOccurences, - boolean deleteEmptySourceFiles, - boolean moveMppDeclarations, - List allDeclarations - ) { - cbSearchInComments.setSelected(searchInComments); - cbSearchTextOccurrences.setSelected(searchForTextOccurences); - cbDeleteEmptySourceFiles.setSelected(deleteEmptySourceFiles); - cbApplyMPPDeclarationsMove.setSelected(moveMppDeclarations); - cbApplyMPPDeclarationsMove.setVisible(isMPPDeclarationInList(allDeclarations)); - } - - private void initMoveToButtons(boolean moveToPackage) { - if (moveToPackage) { - rbMoveToPackage.setSelected(true); - } - else { - rbMoveToFile.setSelected(true); - } - - rbMoveToPackage.addActionListener( - e -> { - classPackageChooser.requestFocus(); - updateControls(); - } - ); - - rbMoveToFile.addActionListener( - e -> { - fileChooser.requestFocus(); - updateControls(); - } - ); - } - - private void initFileChooser( - @Nullable KtFile targetFile, - @Nullable PsiDirectory targetDirectory, - @NotNull Set elementsToMove, - @NotNull List sourceFiles - ) { - PsiDirectory sourceDir = sourceFiles.get(0).getParent(); - if (sourceDir == null) { - throw new AssertionError("File chooser initialization failed"); - } - - Module targetModule = (targetDirectory != null)? ModuleUtilCore.findModuleForPsiElement(targetDirectory) : null; - GlobalSearchScope targetModuleScope = targetModule == null ? null - : GlobalSearchScope.getScopeRestrictedByFileTypes(targetModule.getModuleScope(), KotlinFileType.INSTANCE); - - fileChooser.addActionListener(e -> { - KotlinFileChooserDialog dialog = new KotlinFileChooserDialog( - KotlinBundle.message("text.choose.containing.file"), - myProject, - targetModuleScope, freezeTargets ? null : getTargetPackage()); - - File targetFile1 = new File(fileChooser.getText()); - PsiFile targetPsiFile = PhysicalFileSystemUtilsKt.toPsiFile(targetFile1, myProject); - - if (targetPsiFile != null) { - if (targetPsiFile instanceof KtFile) { - dialog.select((KtFile) targetPsiFile); - } - else { - PsiDirectory targetDir = PhysicalFileSystemUtilsKt.toPsiDirectory(targetFile1.getParentFile(), myProject); - if (targetDir != null) { - dialog.selectDirectory(targetDir); - } else { - dialog.selectDirectory(sourceDir); - } - } - } else { - dialog.selectDirectory(sourceDir); - } - - dialog.showDialog(); - KtFile selectedFile = dialog.isOK() ? dialog.getSelected() : null; - if (selectedFile != null) { - fileChooser.setText(selectedFile.getVirtualFile().getPath()); - } - } - ); - - String initialTargetPath = targetFile != null - ? targetFile.getVirtualFile().getPath() - : sourceFiles.get(0).getVirtualFile().getParent().getPath() + "/" + MoveUtilKt.guessNewFileName(elementsToMove); - fileChooser.setText(initialTargetPath); - } - - private void createUIComponents() { - classPackageChooser = createPackageChooser(); - - destinationFolderCB = new KotlinDestinationFolderComboBox() { - @Override - public String getTargetPackage() { - return MoveKotlinTopLevelDeclarationsDialog.this.getTargetPackage(); - } - - @Override - protected boolean sourceRootsInTargetDirOnly() { - return !freezeTargets; - } - }; - } - - private ReferenceEditorComboWithBrowseButton createPackageChooser() { - return new PackageNameReferenceEditorCombo( - "", - myProject, - RECENTS_KEY, - RefactoringBundle.message("choose.destination.package") - ); - } - - private static boolean isMPPDeclarationInList(List declarations) { - for (KtNamedDeclaration element : declarations) { - if (ExpectActualUtilKt.isEffectivelyActual(element, true) || - ExpectActualUtilKt.isExpectDeclaration(element)) { - return true; - } - } - return false; - } - - private boolean isMppDeclarationSelected() { - return isMPPDeclarationInList(getSelectedElementsToMove()); - } - - private void updateControls() { - - boolean mppDeclarationSelected = isMppDeclarationSelected(); - cbApplyMPPDeclarationsMove.setEnabled(mppDeclarationSelected); - - boolean needToMoveMPPDeclarations = mppDeclarationSelected && cbApplyMPPDeclarationsMove.isSelected(); - - if (needToMoveMPPDeclarations) { - if (!rbMoveToPackage.isSelected()) { - rbMoveToPackage.setSelected(true); - } - } - UIUtil.setEnabled(rbMoveToFile, !needToMoveMPPDeclarations, true); - - boolean moveToPackage = rbMoveToPackage.isSelected(); - classPackageChooser.setEnabled(moveToPackage && freezeTargets); - updateFileNameInPackageField(); - fileChooser.setEnabled(!moveToPackage); - UIUtil.setEnabled(targetPanel, moveToPackage && !needToMoveMPPDeclarations && hasAnySourceRoots(), true); - updateSuggestedFileName(); - myHelpAction.setEnabled(false); - } - - private boolean hasAnySourceRoots() { - return !getSuitableDestinationSourceRoots(myProject).isEmpty(); - } - - private void saveRefactoringSettings() { - KotlinRefactoringSettings refactoringSettings = KotlinRefactoringSettings.getInstance(); - refactoringSettings.MOVE_SEARCH_IN_COMMENTS = cbSearchInComments.isSelected(); - refactoringSettings.MOVE_SEARCH_FOR_TEXT = cbSearchTextOccurrences.isSelected(); - refactoringSettings.MOVE_DELETE_EMPTY_SOURCE_FILES = cbDeleteEmptySourceFiles.isSelected(); - refactoringSettings.MOVE_PREVIEW_USAGES = isPreviewUsages(); - refactoringSettings.MOVE_MPP_DECLARATIONS = cbApplyMPPDeclarationsMove.isSelected(); - - RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, getTargetPackage()); - } - - private List getSelectedElementsToMove() { - return CollectionsKt.map( - memberTable.getSelectedMemberInfos(), - MemberInfoBase::getMember - ); - } - - @Override - protected JComponent createCenterPanel() { - return mainPanel; - } - - @Override - protected String getDimensionServiceKey() { - return "#" + getClass().getName(); - } - - private String getTargetPackage() { - return classPackageChooser.getText().trim(); - } - - private List getSelectedElementsToMoveChecked() throws ConfigurationException { - List elementsToMove = getSelectedElementsToMove(); - if (elementsToMove.isEmpty()) { - throw new ConfigurationException(KotlinBundle.message("text.no.elements.to.move.are.selected")); - } - return elementsToMove; - } - - private MoveKotlinTopLevelDeclarationsModel getModel() throws ConfigurationException { - - boolean mppDeclarationSelected = cbApplyMPPDeclarationsMove.isSelected() && isMppDeclarationSelected(); - - PsiDirectory selectedPsiDirectory = null; - if (!mppDeclarationSelected) { - DirectoryChooser.ItemWrapper selectedItem = (DirectoryChooser.ItemWrapper) destinationFolderCB.getComboBox().getSelectedItem(); - selectedPsiDirectory = selectedItem != null ? selectedItem.getDirectory() : initialTargetDirectory; - } - - List selectedElements = getSelectedElementsToMoveChecked(); - - return new MoveKotlinTopLevelDeclarationsModel( - myProject, - selectedElements, - getTargetPackage(), - selectedPsiDirectory, - tfFileNameInPackage.getText(), - fileChooser.getText(), - rbMoveToPackage.isSelected(), - cbSearchReferences.isSelected(), - cbSearchInComments.isSelected(), - cbSearchTextOccurrences.isSelected(), - cbDeleteEmptySourceFiles.isSelected(), - mppDeclarationSelected, - moveCallback - ); - } - - @Override - protected void doAction() { - - ModelResultWithFUSData modelResult; - try { - modelResult = getModel().computeModelResult(); - } - catch (ConfigurationException e) { - setErrorHtml(e.getMessageHtml()); - return; - } - - saveRefactoringSettings(); - - try { - MoveUtilKt.logFusForMoveRefactoring( - modelResult.getElementsCount(), - modelResult.getEntityToMove(), - modelResult.getDestination(), - getCheckboxesState(false).equals(initializedCheckBoxesState), - () -> invokeRefactoring(modelResult.getProcessor()) - ); - } catch (IncorrectOperationException e) { - CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.getMessage(), null, myProject); - } - } - - @Override - public JComponent getPreferredFocusedComponent() { - return classPackageChooser.getChildComponent(); - } - - private static class MemberInfoModelImpl extends AbstractMemberInfoModel { } + private static class MemberInfoModelImpl extends AbstractMemberInfoModel { + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveMethod/MoveKotlinMethodDialog.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveMethod/MoveKotlinMethodDialog.java index 5c4cf2ad8d70..afe88de383df 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveMethod/MoveKotlinMethodDialog.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveMethod/MoveKotlinMethodDialog.java @@ -14,6 +14,8 @@ import com.intellij.ui.EditorTextField; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBList; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.PsiIconUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +42,9 @@ import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.types.KotlinType; +import javax.swing.AbstractButton; import javax.swing.AbstractListModel; +import javax.swing.ButtonGroup; import javax.swing.DefaultListCellRenderer; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -49,260 +53,366 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.Set; import static org.jetbrains.kotlin.name.Name.isValidIdentifier; public class MoveKotlinMethodDialog extends RefactoringDialog { - private static final String RECENTS_KEY = MoveKotlinMethodDialog.class.getName() + ".RECENTS_KEY"; - private final KtNamedFunction method; - private final Map variableToClassMap; - private final KtNamedDeclaration[] variables; - private final Map> thisClassesToMembers; - private final KtClassOrObject targetContainer; - private final Map oldClassParameterNameFields; - private KtNamedDeclaration selectedTarget; - private JPanel mainPanel; - private JRadioButton toClassRadioButton; - private JRadioButton toObjectRadioButton; - private JPanel targetObjectChooserPanel; - private KotlinTypeReferenceEditorComboWithBrowseButton targetObjectChooser; - private JList targetVariableList; - private JPanel targetVariableListPanel; - private JPanel parametersPanel; - private JCheckBox openInEditorCheckBox; + private static final String RECENTS_KEY = MoveKotlinMethodDialog.class.getName() + ".RECENTS_KEY"; + private final KtNamedFunction method; + private final Map variableToClassMap; + private final KtNamedDeclaration[] variables; + private final Map> thisClassesToMembers; + private final KtClassOrObject targetContainer; + private final Map oldClassParameterNameFields; + private KtNamedDeclaration selectedTarget; + private final JPanel mainPanel; + private final JRadioButton toClassRadioButton; + private final JRadioButton toObjectRadioButton; + private final JPanel targetObjectChooserPanel; + private KotlinTypeReferenceEditorComboWithBrowseButton targetObjectChooser; + private JList targetVariableList; + private final JPanel targetVariableListPanel; + private final JPanel parametersPanel; + private final JCheckBox openInEditorCheckBox; - public MoveKotlinMethodDialog( - @NotNull KtNamedFunction method, - @NotNull Map variableToClassMap, - @Nullable KtClassOrObject targetContainer - ) { - super(method.getProject(), true); + public MoveKotlinMethodDialog( + @NotNull KtNamedFunction method, + @NotNull Map variableToClassMap, + @Nullable KtClassOrObject targetContainer + ) { + super(method.getProject(), true); - this.method = method; - this.variableToClassMap = variableToClassMap; - this.targetContainer = targetContainer; - this.thisClassesToMembers = MoveKotlinMethodProcessorKt.getThisClassesToMembers(method); - this.variables = variableToClassMap.keySet().toArray(new KtNamedDeclaration[0]); - this.oldClassParameterNameFields = new HashMap<>(); + this.method = method; + this.variableToClassMap = variableToClassMap; + this.targetContainer = targetContainer; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + toObjectRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(toObjectRadioButton, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.to.object")); + panel1.add(toObjectRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + targetObjectChooserPanel = new JPanel(); + targetObjectChooserPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(targetObjectChooserPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + parametersPanel = new JPanel(); + parametersPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(parametersPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + toClassRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(toClassRadioButton, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "label.text.to.class")); + panel2.add(toClassRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + targetVariableListPanel = new JPanel(); + targetVariableListPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(targetVariableListPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + openInEditorCheckBox = new JCheckBox(); + openInEditorCheckBox.setSelected(true); + this.$$$loadButtonText$$$(openInEditorCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "open.moved.method.in.editor")); + mainPanel.add(openInEditorCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(toObjectRadioButton); + buttonGroup.add(toClassRadioButton); + } + this.thisClassesToMembers = MoveKotlinMethodProcessorKt.getThisClassesToMembers(method); + this.variables = variableToClassMap.keySet().toArray(new KtNamedDeclaration[0]); + this.oldClassParameterNameFields = new HashMap<>(); - init(); - setTitle(KotlinBundle.message("title.move.method")); - initTargetObjectChooser(); - initTargetVariableList(); - initParametersPanel(); - initButtons(); + init(); + setTitle(KotlinBundle.message("title.move.method")); + initTargetObjectChooser(); + initTargetVariableList(); + initParametersPanel(); + initButtons(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + + @Override + protected void doAction() { + if (toClassRadioButton.isSelected()) selectedTarget = targetVariableList.getSelectedValue(); + if (toObjectRadioButton.isSelected() && selectedTarget == null) { + setErrorText(KotlinBundle.message("text.no.destination.object.specified")); + return; } - @Override - protected void doAction() { - if (toClassRadioButton.isSelected()) selectedTarget = targetVariableList.getSelectedValue(); - if (toObjectRadioButton.isSelected() && selectedTarget == null) { - setErrorText(KotlinBundle.message("text.no.destination.object.specified")); - return; - } - - Map oldClassParameterNames = new LinkedHashMap<>(); - for (Map.Entry entry : oldClassParameterNameFields.entrySet()) { - EditorTextField field = entry.getValue(); - if (!isValidIdentifier(field.getText())) { - setErrorText(KotlinBundle.message("parameter.name.is.invalid", field.getText())); - return; - } - if (field.isEnabled()) { - oldClassParameterNames.put(entry.getKey(), field.getText()); - } - } - - MoveKotlinMethodProcessor processor = - new MoveKotlinMethodProcessor(method, selectedTarget, oldClassParameterNames, openInEditorCheckBox.isSelected()); - invokeRefactoring(processor); + Map oldClassParameterNames = new LinkedHashMap<>(); + for (Map.Entry entry : oldClassParameterNameFields.entrySet()) { + EditorTextField field = entry.getValue(); + if (!isValidIdentifier(field.getText())) { + setErrorText(KotlinBundle.message("parameter.name.is.invalid", field.getText())); + return; + } + if (field.isEnabled()) { + oldClassParameterNames.put(entry.getKey(), field.getText()); + } } - @Override - protected @Nullable JComponent createCenterPanel() { - return mainPanel; + MoveKotlinMethodProcessor processor = + new MoveKotlinMethodProcessor(method, selectedTarget, oldClassParameterNames, openInEditorCheckBox.isSelected()); + invokeRefactoring(processor); + } + + @Override + protected @Nullable JComponent createCenterPanel() { + return mainPanel; + } + + private void initButtons() { + toClassRadioButton.addActionListener(e -> enableTargetChooser()); + toObjectRadioButton.addActionListener(e -> enableTargetChooser()); + + if (variables.length != 0 && !(targetContainer instanceof KtObjectDeclaration)) { + toClassRadioButton.setSelected(true); + } + else { + toObjectRadioButton.setSelected(true); + if (variables.length == 0) { + toClassRadioButton.setEnabled(false); + } } - private void initButtons() { - toClassRadioButton.addActionListener(e -> enableTargetChooser()); - toObjectRadioButton.addActionListener(e -> enableTargetChooser()); + enableTextFields(); + enableTargetChooser(); + } - if (variables.length != 0 && !(targetContainer instanceof KtObjectDeclaration)) { - toClassRadioButton.setSelected(true); - } - else { - toObjectRadioButton.setSelected(true); - if (variables.length == 0) { - toClassRadioButton.setEnabled(false); - } - } + private void initTargetVariableList() { + AbstractListModel listModel = new AbstractListModel<>() { + @Override + public int getSize() { + return variables.length; + } - enableTextFields(); - enableTargetChooser(); + @Override + public KtNamedDeclaration getElementAt(int index) { + return variables[index]; + } + }; + targetVariableList = new JBList<>(listModel); + DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { + private final DescriptorRenderer renderer = IdeDescriptorRenderers.SOURCE_CODE_TYPES_WITH_SHORT_NAMES; + + @Override + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof KtNamedDeclaration variable) { + setIcon(PsiIconUtil.getIconFromProviders(variable, 0)); + setText(variable.getName()); + KotlinType type = MoveKotlinMethodProcessorKt.type(variable); + if (type != null) { + @NlsSafe String renderType = renderer.renderType(type); + setText(getText() + ": " + renderType); + } + } + return this; + } + }; + + targetVariableList.setCellRenderer(listCellRenderer); + targetVariableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + int defaultVariableIndex = -1; + for (int i = 0; i < variables.length; i++) { + if (variableToClassMap.get(variables[i]) == targetContainer) { + defaultVariableIndex = i; + } } + targetVariableList.setSelectedIndex(defaultVariableIndex != -1 ? defaultVariableIndex : 0); + targetVariableList.getSelectionModel().addListSelectionListener(e -> enableTextFields()); - private void initTargetVariableList() { - AbstractListModel listModel = new AbstractListModel<>() { - @Override - public int getSize() { - return variables.length; - } + JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(targetVariableList); + targetVariableListPanel.add(scrollPane); + } - @Override - public KtNamedDeclaration getElementAt(int index) { - return variables[index]; - } - }; - targetVariableList = new JBList<>(listModel); - DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { - private final DescriptorRenderer renderer = IdeDescriptorRenderers.SOURCE_CODE_TYPES_WITH_SHORT_NAMES; - - @Override - public Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus - ) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof KtNamedDeclaration variable) { - setIcon(PsiIconUtil.getIconFromProviders(variable, 0)); - setText(variable.getName()); - KotlinType type = MoveKotlinMethodProcessorKt.type(variable); - if (type != null) { - @NlsSafe String renderType = renderer.renderType(type); - setText(getText() + ": " + renderType); - } - } - return this; - } - }; - - targetVariableList.setCellRenderer(listCellRenderer); - targetVariableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - int defaultVariableIndex = -1; - for (int i = 0; i < variables.length; i++) { - if (variableToClassMap.get(variables[i]) == targetContainer) { - defaultVariableIndex = i; - } + private void initTargetObjectChooser() { + targetObjectChooser = new KotlinTypeReferenceEditorComboWithBrowseButton( + e -> { + TreeClassChooser chooser = createTreeClassChooser(); + chooser.selectDirectory(method.getContainingFile().getContainingDirectory()); + chooser.showDialog(); + PsiClass psiClass = chooser.getSelected(); + if (psiClass instanceof KtLightClassForSourceDeclaration) { + selectedTarget = ((KtLightClassForSourceDeclaration)psiClass).getKotlinOrigin(); + targetObjectChooser.setText(Objects.requireNonNull(psiClass.getQualifiedName())); } - targetVariableList.setSelectedIndex(defaultVariableIndex != -1 ? defaultVariableIndex : 0); - targetVariableList.getSelectionModel().addListSelectionListener(e -> enableTextFields()); - - JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(targetVariableList); - targetVariableListPanel.add(scrollPane); + }, + (targetContainer == null || targetContainer.getFqName() == null) ? null : targetContainer.getFqName().asString(), + targetContainer == null ? Objects.requireNonNull(KtPsiUtilKt.getContainingClassOrObject(method)) : targetContainer, + RECENTS_KEY + ); + KtTypeCodeFragment codeFragment = targetObjectChooser.getCodeFragment(); + if (codeFragment != null) { + CompletionUtilsKt.setExtraCompletionFilter( + codeFragment, + lookupElement -> { + Object lookupObject = lookupElement.getObject(); + if (!(lookupObject instanceof DescriptorBasedDeclarationLookupObject)) return false; + PsiElement psiElement = ((DescriptorBasedDeclarationLookupObject)lookupObject).getPsiElement(); + if (lookupObject instanceof PackageLookupObject) return true; + return (psiElement instanceof KtObjectDeclaration) && KotlinCommonRefactoringUtilKt.canRefactorElement(psiElement); + } + ); } + targetObjectChooserPanel.add(targetObjectChooser); + } - private void initTargetObjectChooser() { - targetObjectChooser = new KotlinTypeReferenceEditorComboWithBrowseButton( - e -> { - TreeClassChooser chooser = createTreeClassChooser(); - chooser.selectDirectory(method.getContainingFile().getContainingDirectory()); - chooser.showDialog(); - PsiClass psiClass = chooser.getSelected(); - if (psiClass instanceof KtLightClassForSourceDeclaration) { - selectedTarget = ((KtLightClassForSourceDeclaration) psiClass).getKotlinOrigin(); - targetObjectChooser.setText(Objects.requireNonNull(psiClass.getQualifiedName())); - } - }, - (targetContainer == null || targetContainer.getFqName() == null) ? null : targetContainer.getFqName().asString(), - targetContainer == null ? Objects.requireNonNull(KtPsiUtilKt.getContainingClassOrObject(method)) : targetContainer, - RECENTS_KEY - ); - KtTypeCodeFragment codeFragment = targetObjectChooser.getCodeFragment(); - if (codeFragment != null) { - CompletionUtilsKt.setExtraCompletionFilter( - codeFragment, - lookupElement -> { - Object lookupObject = lookupElement.getObject(); - if (!(lookupObject instanceof DescriptorBasedDeclarationLookupObject)) return false; - PsiElement psiElement = ((DescriptorBasedDeclarationLookupObject) lookupObject).getPsiElement(); - if (lookupObject instanceof PackageLookupObject) return true; - return (psiElement instanceof KtObjectDeclaration) && KotlinCommonRefactoringUtilKt.canRefactorElement(psiElement); - } - ); - } - targetObjectChooserPanel.add(targetObjectChooser); + private void enableTextFields() { + for (EditorTextField textField : oldClassParameterNameFields.values()) { + textField.setEnabled(true); } - - private void enableTextFields() { - for (EditorTextField textField : oldClassParameterNameFields.values()) { - textField.setEnabled(true); - } - if (toClassRadioButton.isSelected()) { - KtNamedDeclaration variable = variables[targetVariableList.getSelectedIndex()]; - KtClassOrObject containingClass = KtPsiUtilKt.getContainingClassOrObject(variable); - if (!(containingClass instanceof KtClass)) return; - if (!(variable instanceof KtParameter) || ((KtParameter) variable).hasValOrVar()) { - Set members = thisClassesToMembers.get(containingClass); - if (members != null && members.size() == 1 && members.contains(variable)) { - EditorTextField field = oldClassParameterNameFields.get(containingClass); - if (field != null) field.setEnabled(false); - } - } + if (toClassRadioButton.isSelected()) { + KtNamedDeclaration variable = variables[targetVariableList.getSelectedIndex()]; + KtClassOrObject containingClass = KtPsiUtilKt.getContainingClassOrObject(variable); + if (!(containingClass instanceof KtClass)) return; + if (!(variable instanceof KtParameter) || ((KtParameter)variable).hasValOrVar()) { + Set members = thisClassesToMembers.get(containingClass); + if (members != null && members.size() == 1 && members.contains(variable)) { + EditorTextField field = oldClassParameterNameFields.get(containingClass); + if (field != null) field.setEnabled(false); } + } } + } - private void enableTargetChooser() { - if (toClassRadioButton.isSelected()) { - targetVariableList.setEnabled(true); - targetObjectChooser.setEnabled(false); - } - else { - targetVariableList.setEnabled(false); - targetObjectChooser.setEnabled(true); - } - enableTextFields(); + private void enableTargetChooser() { + if (toClassRadioButton.isSelected()) { + targetVariableList.setEnabled(true); + targetObjectChooser.setEnabled(false); } - - private void initParametersPanel() { - if (thisClassesToMembers.isEmpty()) return; - parametersPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)); - Fe10KotlinNewDeclarationNameValidator validator = new Fe10KotlinNewDeclarationNameValidator( - (PsiElement) method, - null, - KotlinNameSuggestionProvider.ValidatorTarget.PARAMETER, - new ArrayList<>() - ); - - for (KtClass ktClass : thisClassesToMembers.keySet()) { - KotlinType type = MoveKotlinMethodProcessorKt.defaultType(ktClass); - if (type == null) continue; - @SuppressWarnings("DialogTitleCapitalization") - String text = KotlinBundle.message("title.select.a.name.for.this.parameter", ktClass.getName()); - parametersPanel.add(new TitledSeparator(text, null)); - List suggestedNames = Fe10KotlinNameSuggester.INSTANCE.suggestNamesByType(type, validator, null); - String suggestedName = suggestedNames.isEmpty() ? "parameter" : suggestedNames.get(0); - EditorTextField field = new EditorTextField(suggestedName, myProject, KotlinFileType.INSTANCE); - oldClassParameterNameFields.put(ktClass, field); - parametersPanel.add(field); - } + else { + targetVariableList.setEnabled(false); + targetObjectChooser.setEnabled(true); } + enableTextFields(); + } - private TreeJavaClassChooserDialog createTreeClassChooser() { - return new TreeJavaClassChooserDialog( - KotlinBundle.message("title.choose.destination.object"), - myProject, - GlobalSearchScope.projectScope(myProject), - aClass -> { - if (!(aClass instanceof KtLightClassForSourceDeclaration)) return false; - KtClassOrObject ktClassOrObject = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin(); - return ktClassOrObject instanceof KtObjectDeclaration && !((KtObjectDeclaration) ktClassOrObject).isObjectLiteral(); - }, - null, - null, - true - ); + private void initParametersPanel() { + if (thisClassesToMembers.isEmpty()) return; + parametersPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)); + Fe10KotlinNewDeclarationNameValidator validator = new Fe10KotlinNewDeclarationNameValidator( + (PsiElement)method, + null, + KotlinNameSuggestionProvider.ValidatorTarget.PARAMETER, + new ArrayList<>() + ); + + for (KtClass ktClass : thisClassesToMembers.keySet()) { + KotlinType type = MoveKotlinMethodProcessorKt.defaultType(ktClass); + if (type == null) continue; + @SuppressWarnings("DialogTitleCapitalization") + String text = KotlinBundle.message("title.select.a.name.for.this.parameter", ktClass.getName()); + parametersPanel.add(new TitledSeparator(text, null)); + List suggestedNames = Fe10KotlinNameSuggester.INSTANCE.suggestNamesByType(type, validator, null); + String suggestedName = suggestedNames.isEmpty() ? "parameter" : suggestedNames.get(0); + EditorTextField field = new EditorTextField(suggestedName, myProject, KotlinFileType.INSTANCE); + oldClassParameterNameFields.put(ktClass, field); + parametersPanel.add(field); } + } + + private TreeJavaClassChooserDialog createTreeClassChooser() { + return new TreeJavaClassChooserDialog( + KotlinBundle.message("title.choose.destination.object"), + myProject, + GlobalSearchScope.projectScope(myProject), + aClass -> { + if (!(aClass instanceof KtLightClassForSourceDeclaration)) return false; + KtClassOrObject ktClassOrObject = ((KtLightClassForSourceDeclaration)aClass).getKotlinOrigin(); + return ktClassOrObject instanceof KtObjectDeclaration && !((KtObjectDeclaration)ktClassOrObject).isObjectLiteral(); + }, + null, + null, + true + ); + } } diff --git a/plugins/kotlin/j2k/shared/src/org/jetbrains/kotlin/j2k/copyPaste/KotlinPasteFromJavaDialog.java b/plugins/kotlin/j2k/shared/src/org/jetbrains/kotlin/j2k/copyPaste/KotlinPasteFromJavaDialog.java index 3e526a59a766..f7fad9104b45 100644 --- a/plugins/kotlin/j2k/shared/src/org/jetbrains/kotlin/j2k/copyPaste/KotlinPasteFromJavaDialog.java +++ b/plugins/kotlin/j2k/shared/src/org/jetbrains/kotlin/j2k/copyPaste/KotlinPasteFromJavaDialog.java @@ -5,10 +5,14 @@ package org.jetbrains.kotlin.j2k.copyPaste; import com.intellij.CommonBundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.editor.KotlinEditorOptions; import org.jetbrains.kotlin.nj2k.KotlinNJ2KBundle; +import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -16,54 +20,151 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Container; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; @SuppressWarnings("UnusedDeclaration") public class KotlinPasteFromJavaDialog extends DialogWrapper { - private JPanel panel; - private JCheckBox donTShowThisCheckBox; - private JLabel questionLabel; - private JButton buttonOK; + private final JPanel panel; + private final JCheckBox donTShowThisCheckBox; + private final JLabel questionLabel; + private JButton buttonOK; - public KotlinPasteFromJavaDialog(@NotNull Project project, boolean isPlainText) { - super(project, true); - setModal(true); - getRootPane().setDefaultButton(buttonOK); - setTitle(KotlinNJ2KBundle.message("copy.title.convert.code.from.java")); - if (isPlainText) { - questionLabel.setText( - KotlinNJ2KBundle.message("copy.text.clipboard.content.seems.to.be.java.code.do.you.want.to.convert.it.to.kotlin")); - //TODO: should we also use different set of settings? + public KotlinPasteFromJavaDialog(@NotNull Project project, boolean isPlainText) { + super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + questionLabel = new JLabel(); + this.$$$loadLabelText$$$(questionLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", + "clipboard.content.copied.from.java.file.do.you.want.to.convert.it.to.kotlin.code")); + panel.add(questionLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + donTShowThisCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(donTShowThisCheckBox, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "don.t.show.this.dialog.next.time")); + panel.add(donTShowThisCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + setModal(true); + getRootPane().setDefaultButton(buttonOK); + setTitle(KotlinNJ2KBundle.message("copy.title.convert.code.from.java")); + if (isPlainText) { + questionLabel.setText( + KotlinNJ2KBundle.message("copy.text.clipboard.content.seems.to.be.java.code.do.you.want.to.convert.it.to.kotlin")); + //TODO: should we also use different set of settings? + } + init(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - init(); + } + result.append(text.charAt(i)); } - - @Override - protected JComponent createCenterPanel() { - return panel; + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - @Override - public Container getContentPane() { - return panel; - } - - @Override - protected @NotNull Action @NotNull [] createActions() { - setOKButtonText(CommonBundle.getYesButtonText()); - setCancelButtonText(CommonBundle.getNoButtonText()); - return new Action[] {getOKAction(), getCancelAction()}; - } - - @Override - protected void doOKAction() { - if (donTShowThisCheckBox.isSelected()) { - KotlinEditorOptions.getInstance().setDonTShowConversionDialog(true); + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - super.doOKAction(); + } + result.append(text.charAt(i)); } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } - @Override - public void dispose() { - super.dispose(); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + + @Override + protected JComponent createCenterPanel() { + return panel; + } + + @Override + public Container getContentPane() { + return panel; + } + + @Override + protected @NotNull Action @NotNull [] createActions() { + setOKButtonText(CommonBundle.getYesButtonText()); + setCancelButtonText(CommonBundle.getNoButtonText()); + return new Action[]{getOKAction(), getCancelAction()}; + } + + @Override + protected void doOKAction() { + if (donTShowThisCheckBox.isSelected()) { + KotlinEditorOptions.getInstance().setDonTShowConversionDialog(true); } + super.doOKAction(); + } + + @Override + public void dispose() { + super.dispose(); + } } diff --git a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/KotlinDelegatedPropertyRendererConfigurableUi.java b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/KotlinDelegatedPropertyRendererConfigurableUi.java index 70d80293cc2a..4be4ac3aac0c 100644 --- a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/KotlinDelegatedPropertyRendererConfigurableUi.java +++ b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/KotlinDelegatedPropertyRendererConfigurableUi.java @@ -4,34 +4,109 @@ package org.jetbrains.kotlin.idea.debugger.core; import com.intellij.openapi.options.ConfigurableUi; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class KotlinDelegatedPropertyRendererConfigurableUi implements ConfigurableUi { - private JCheckBox disableCoroutineAgent; - private JPanel myPanel; + private final JCheckBox disableCoroutineAgent; + private final JPanel myPanel; - @Override - public void reset(@NotNull KotlinDebuggerSettings settings) { - disableCoroutineAgent.setSelected(!settings.getDebugDisableCoroutineAgent()); + public KotlinDelegatedPropertyRendererConfigurableUi() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + disableCoroutineAgent = new JCheckBox(); + this.$$$loadButtonText$$$(disableCoroutineAgent, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "variables.disable.coroutine.agent.values")); + disableCoroutineAgent.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", "variables.disable.coroutine.agent.tooltip")); + myPanel.add(disableCoroutineAgent, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); } + } - @Override - public boolean isModified(@NotNull KotlinDebuggerSettings settings) { - return settings.getDebugDisableCoroutineAgent() == disableCoroutineAgent.isSelected(); - } + private static Method $$$cachedGetBundleMethod$$$ = null; - @Override - public void apply(@NotNull KotlinDebuggerSettings settings) { - settings.setDebugDisableCoroutineAgent(!disableCoroutineAgent.isSelected()); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } - @Override - public @NotNull JComponent getComponent() { - return myPanel; + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + + @Override + public void reset(@NotNull KotlinDebuggerSettings settings) { + disableCoroutineAgent.setSelected(!settings.getDebugDisableCoroutineAgent()); + } + + @Override + public boolean isModified(@NotNull KotlinDebuggerSettings settings) { + return settings.getDebugDisableCoroutineAgent() == disableCoroutineAgent.isSelected(); + } + + @Override + public void apply(@NotNull KotlinDebuggerSettings settings) { + settings.setDebugDisableCoroutineAgent(!disableCoroutineAgent.isSelected()); + } + + @Override + public @NotNull JComponent getComponent() { + return myPanel; + } } diff --git a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/KotlinBreakpointFiltersPanel.java b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/KotlinBreakpointFiltersPanel.java index a7a2c05b43e9..8b242cda2fb4 100644 --- a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/KotlinBreakpointFiltersPanel.java +++ b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/KotlinBreakpointFiltersPanel.java @@ -10,8 +10,12 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiClass; import com.intellij.ui.FieldPanel; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.MultiLineTooltipUI; import com.intellij.ui.classFilter.ClassFilter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; @@ -20,361 +24,530 @@ import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JToolTip; import javax.swing.ToolTipManager; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.ResourceBundle; public class KotlinBreakpointFiltersPanel> - extends XBreakpointCustomPropertiesPanel { - private JPanel myConditionsPanel; - private JPanel myInstanceFiltersPanel; - private JCheckBox myInstanceFiltersCheckBox; - private JPanel myInstanceFiltersFieldPanel; - private JPanel myClassFiltersPanel; - private JCheckBox myClassFiltersCheckBox; - private JPanel myClassFiltersFieldPanel; - private JPanel myPassCountPanel; - private JCheckBox myPassCountCheckbox; - private JTextField myPassCountField; + extends XBreakpointCustomPropertiesPanel { + private final JPanel myConditionsPanel; + private final JPanel myInstanceFiltersPanel; + private final JCheckBox myInstanceFiltersCheckBox; + private final JPanel myInstanceFiltersFieldPanel; + private final JPanel myClassFiltersPanel; + private final JCheckBox myClassFiltersCheckBox; + private final JPanel myClassFiltersFieldPanel; + private final JPanel myPassCountPanel; + private final JCheckBox myPassCountCheckbox; + private final JTextField myPassCountField; - private final FieldPanel myInstanceFiltersField; - private final FieldPanel myClassFiltersField; + private final FieldPanel myInstanceFiltersField; + private final FieldPanel myClassFiltersField; - private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY; - private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY; - private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY; - protected final Project myProject; + private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY; + private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY; + private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY; + protected final Project myProject; - private PsiClass myBreakpointPsiClass; + private PsiClass myBreakpointPsiClass; - public KotlinBreakpointFiltersPanel(Project project) { - myProject = project; - myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null, - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - reloadInstanceFilters(); - EditInstanceFiltersDialog _dialog = new EditInstanceFiltersDialog(myProject); - _dialog.setFilters(myInstanceFilters); - _dialog.show(); - if (_dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { - myInstanceFilters = _dialog.getFilters(); - updateInstanceFilterEditor(true); - } - } - }, - null - ); - - myClassFiltersField = new FieldPanel(new MyTextField(), "", null, - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - reloadClassFilters(); - - com.intellij.ide.util.ClassFilter classFilter = createClassConditionFilter(); - - EditClassFiltersDialog _dialog = new EditClassFiltersDialog(myProject, classFilter); - _dialog.setFilters(myClassFilters, myClassExclusionFilters); - _dialog.show(); - if (_dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { - myClassFilters = _dialog.getFilters(); - myClassExclusionFilters = _dialog.getExclusionFilters(); - updateClassFilterEditor(true); - } - } - }, - null - ); - - ActionListener updateListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - updateCheckboxes(); - } - }; - - myPassCountCheckbox.addActionListener(updateListener); - myInstanceFiltersCheckBox.addActionListener(updateListener); - myClassFiltersCheckBox.addActionListener(updateListener); - - ToolTipManager.sharedInstance().registerComponent(myClassFiltersField.getTextField()); - ToolTipManager.sharedInstance().registerComponent(myInstanceFiltersField.getTextField()); - - insert(myInstanceFiltersFieldPanel, myInstanceFiltersField); - insert(myClassFiltersFieldPanel, myClassFiltersField); - - DebuggerUIUtil.focusEditorOnCheck(myPassCountCheckbox, myPassCountField); - DebuggerUIUtil.focusEditorOnCheck(myInstanceFiltersCheckBox, myInstanceFiltersField.getTextField()); - DebuggerUIUtil.focusEditorOnCheck(myClassFiltersCheckBox, myClassFiltersField.getTextField()); + public KotlinBreakpointFiltersPanel(Project project) { + myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myConditionsPanel = new JPanel(); + myConditionsPanel.setLayout(new GridLayoutManager(4, 2, new Insets(2, 2, 5, 5), -1, 7)); + myConditionsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + panel1.add(myConditionsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myConditionsPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/KotlinDebuggerCoreBundle", + "property.watchpoint.properties.panel.panel.group.conditions"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myInstanceFiltersPanel = new JPanel(); + myInstanceFiltersPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(myInstanceFiltersPanel, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myInstanceFiltersCheckBox = new JCheckBox(); + myInstanceFiltersCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myInstanceFiltersCheckBox, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "property.watchpoint.properties.panel.option.instance.filters")); + myInstanceFiltersPanel.add(myInstanceFiltersCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myInstanceFiltersPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, null, new Dimension(15, -1), null, 0, false)); + myInstanceFiltersFieldPanel = new JPanel(); + panel2.add(myInstanceFiltersFieldPanel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myClassFiltersPanel = new JPanel(); + myClassFiltersPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(myClassFiltersPanel, + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myClassFiltersCheckBox = new JCheckBox(); + myClassFiltersCheckBox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myClassFiltersCheckBox, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "property.watchpoint.properties.panel.option.class.filters")); + myClassFiltersPanel.add(myClassFiltersCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myClassFiltersPanel.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myClassFiltersFieldPanel = new JPanel(); + panel3.add(myClassFiltersFieldPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, null, new Dimension(15, -1), null, 0, false)); + myPassCountPanel = new JPanel(); + myPassCountPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, 0)); + myConditionsPanel.add(myPassCountPanel, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myPassCountCheckbox = new JCheckBox(); + myPassCountCheckbox.setMargin(new Insets(2, 2, 0, 2)); + this.$$$loadButtonText$$$(myPassCountCheckbox, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "property.watchpoint.properties.panel.option.pass.count")); + myPassCountPanel.add(myPassCountCheckbox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPassCountPanel.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPassCountField = new JTextField(); + myPassCountField.setEnabled(false); + myPassCountField.setHorizontalAlignment(10); + panel4.add(myPassCountField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(15, -1), null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel4.add(spacer3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, null, new Dimension(15, -1), null, 0, false)); + final Spacer spacer4 = new Spacer(); + myConditionsPanel.add(spacer4, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); } + myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null, + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + reloadInstanceFilters(); + EditInstanceFiltersDialog _dialog = new EditInstanceFiltersDialog(myProject); + _dialog.setFilters(myInstanceFilters); + _dialog.show(); + if (_dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { + myInstanceFilters = _dialog.getFilters(); + updateInstanceFilterEditor(true); + } + } + }, + null + ); - @Override - public @NotNull JComponent getComponent() { - return myConditionsPanel; - } + myClassFiltersField = new FieldPanel(new MyTextField(), "", null, + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + reloadClassFilters(); - @Override - public boolean isVisibleOnPopup(@NotNull B breakpoint) { - JavaBreakpointProperties properties = breakpoint.getProperties(); - if (properties != null) { - return properties.isCOUNT_FILTER_ENABLED() || properties.isCLASS_FILTERS_ENABLED() || properties.isINSTANCE_FILTERS_ENABLED(); - } - return false; - } + com.intellij.ide.util.ClassFilter classFilter = createClassConditionFilter(); - @Override - public void saveTo(@NotNull B breakpoint) { - JavaBreakpointProperties properties = breakpoint.getProperties(); - if (properties == null) { - return; - } + EditClassFiltersDialog _dialog = new EditClassFiltersDialog(myProject, classFilter); + _dialog.setFilters(myClassFilters, myClassExclusionFilters); + _dialog.show(); + if (_dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { + myClassFilters = _dialog.getFilters(); + myClassExclusionFilters = _dialog.getExclusionFilters(); + updateClassFilterEditor(true); + } + } + }, + null + ); - boolean changed = false; - try { - String text = myPassCountField.getText().trim(); - int filter = !text.isEmpty() ? Integer.parseInt(text) : 0; - if (filter < 0) filter = 0; - changed = properties.setCOUNT_FILTER(filter); - } catch (Exception ignored) { - } - - changed = properties.setCOUNT_FILTER_ENABLED(properties.getCOUNT_FILTER() > 0 && myPassCountCheckbox.isSelected()) || changed; - reloadInstanceFilters(); - reloadClassFilters(); - updateInstanceFilterEditor(true); - updateClassFilterEditor(true); - - changed = properties.setINSTANCE_FILTERS_ENABLED( - !myInstanceFiltersField.getText().isEmpty() && myInstanceFiltersCheckBox.isSelected()) || changed; - changed = properties.setCLASS_FILTERS_ENABLED(!myClassFiltersField.getText().isEmpty() && myClassFiltersCheckBox.isSelected()) || - changed; - changed = properties.setClassFilters(myClassFilters) || changed; - changed = properties.setClassExclusionFilters(myClassExclusionFilters) || changed; - changed = properties.setInstanceFilters(myInstanceFilters) || changed; - if (changed) { - ((XBreakpointBase) breakpoint).fireBreakpointChanged(); - } - } - - private static void insert(JPanel panel, JComponent component) { - panel.setLayout(new BorderLayout()); - panel.add(component, BorderLayout.CENTER); - } - - @Override - public void loadFrom(@NotNull B breakpoint) { - JavaBreakpointProperties properties = breakpoint.getProperties(); - if (properties != null) { - if (properties.getCOUNT_FILTER() > 0) { - myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER())); - } else { - myPassCountField.setText(""); - } - - myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED()); - - myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED()); - myInstanceFiltersField.setEnabled(properties.isINSTANCE_FILTERS_ENABLED()); - myInstanceFiltersField.getTextField().setEditable(properties.isINSTANCE_FILTERS_ENABLED()); - myInstanceFilters = properties.getInstanceFilters(); - updateInstanceFilterEditor(true); - - myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED()); - myClassFiltersField.setEnabled(properties.isCLASS_FILTERS_ENABLED()); - myClassFiltersField.getTextField().setEditable(properties.isCLASS_FILTERS_ENABLED()); - myClassFilters = properties.getClassFilters(); - myClassExclusionFilters = properties.getClassExclusionFilters(); - updateClassFilterEditor(true); - - XSourcePosition position = breakpoint.getSourcePosition(); - // TODO: need to calculate psi class - //myBreakpointPsiClass = breakpoint.getPsiClass(); - } + ActionListener updateListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { updateCheckboxes(); + } + }; + + myPassCountCheckbox.addActionListener(updateListener); + myInstanceFiltersCheckBox.addActionListener(updateListener); + myClassFiltersCheckBox.addActionListener(updateListener); + + ToolTipManager.sharedInstance().registerComponent(myClassFiltersField.getTextField()); + ToolTipManager.sharedInstance().registerComponent(myInstanceFiltersField.getTextField()); + + insert(myInstanceFiltersFieldPanel, myInstanceFiltersField); + insert(myClassFiltersFieldPanel, myClassFiltersField); + + DebuggerUIUtil.focusEditorOnCheck(myPassCountCheckbox, myPassCountField); + DebuggerUIUtil.focusEditorOnCheck(myInstanceFiltersCheckBox, myInstanceFiltersField.getTextField()); + DebuggerUIUtil.focusEditorOnCheck(myClassFiltersCheckBox, myClassFiltersField.getTextField()); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + @Override + public @NotNull JComponent getComponent() { + return myConditionsPanel; + } + + @Override + public boolean isVisibleOnPopup(@NotNull B breakpoint) { + JavaBreakpointProperties properties = breakpoint.getProperties(); + if (properties != null) { + return properties.isCOUNT_FILTER_ENABLED() || properties.isCLASS_FILTERS_ENABLED() || properties.isINSTANCE_FILTERS_ENABLED(); + } + return false; + } + + @Override + public void saveTo(@NotNull B breakpoint) { + JavaBreakpointProperties properties = breakpoint.getProperties(); + if (properties == null) { + return; } - private void updateInstanceFilterEditor(boolean updateText) { - List filters = new ArrayList<>(); - for (InstanceFilter instanceFilter : myInstanceFilters) { - if (instanceFilter.isEnabled()) { - filters.add(Long.toString(instanceFilter.getId())); - } - } - if (updateText) { - myInstanceFiltersField.setText(StringUtil.join(filters, " ")); - } - - String tipText = concatWithEx(new StringBuilder(), filters, " ", (int) Math.sqrt(myInstanceFilters.length) + 1, "\n").toString(); - myInstanceFiltersField.getTextField().setToolTipText(tipText); + boolean changed = false; + try { + String text = myPassCountField.getText().trim(); + int filter = !text.isEmpty() ? Integer.parseInt(text) : 0; + if (filter < 0) filter = 0; + changed = properties.setCOUNT_FILTER(filter); + } + catch (Exception ignored) { } - private class MyTextField extends JTextField { - private MyTextField() {} + changed = properties.setCOUNT_FILTER_ENABLED(properties.getCOUNT_FILTER() > 0 && myPassCountCheckbox.isSelected()) || changed; + reloadInstanceFilters(); + reloadClassFilters(); + updateInstanceFilterEditor(true); + updateClassFilterEditor(true); - @Override - public String getToolTipText(MouseEvent event) { - reloadClassFilters(); - updateClassFilterEditor(false); - reloadInstanceFilters(); - updateInstanceFilterEditor(false); - String toolTipText = super.getToolTipText(event); - return getToolTipText().isEmpty() ? null : toolTipText; - } + changed = properties.setINSTANCE_FILTERS_ENABLED( + !myInstanceFiltersField.getText().isEmpty() && myInstanceFiltersCheckBox.isSelected()) || changed; + changed = properties.setCLASS_FILTERS_ENABLED(!myClassFiltersField.getText().isEmpty() && myClassFiltersCheckBox.isSelected()) || + changed; + changed = properties.setClassFilters(myClassFilters) || changed; + changed = properties.setClassExclusionFilters(myClassExclusionFilters) || changed; + changed = properties.setInstanceFilters(myInstanceFilters) || changed; + if (changed) { + ((XBreakpointBase)breakpoint).fireBreakpointChanged(); + } + } - @Override - public JToolTip createToolTip() { - JToolTip toolTip = new JToolTip() {{ - setUI(new MultiLineTooltipUI()); - }}; - toolTip.setComponent(this); - return toolTip; - } + private static void insert(JPanel panel, JComponent component) { + panel.setLayout(new BorderLayout()); + panel.add(component, BorderLayout.CENTER); + } + + @Override + public void loadFrom(@NotNull B breakpoint) { + JavaBreakpointProperties properties = breakpoint.getProperties(); + if (properties != null) { + if (properties.getCOUNT_FILTER() > 0) { + myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER())); + } + else { + myPassCountField.setText(""); + } + + myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED()); + + myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED()); + myInstanceFiltersField.setEnabled(properties.isINSTANCE_FILTERS_ENABLED()); + myInstanceFiltersField.getTextField().setEditable(properties.isINSTANCE_FILTERS_ENABLED()); + myInstanceFilters = properties.getInstanceFilters(); + updateInstanceFilterEditor(true); + + myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED()); + myClassFiltersField.setEnabled(properties.isCLASS_FILTERS_ENABLED()); + myClassFiltersField.getTextField().setEditable(properties.isCLASS_FILTERS_ENABLED()); + myClassFilters = properties.getClassFilters(); + myClassExclusionFilters = properties.getClassExclusionFilters(); + updateClassFilterEditor(true); + + XSourcePosition position = breakpoint.getSourcePosition(); + // TODO: need to calculate psi class + //myBreakpointPsiClass = breakpoint.getPsiClass(); + } + updateCheckboxes(); + } + + private void updateInstanceFilterEditor(boolean updateText) { + List filters = new ArrayList<>(); + for (InstanceFilter instanceFilter : myInstanceFilters) { + if (instanceFilter.isEnabled()) { + filters.add(Long.toString(instanceFilter.getId())); + } + } + if (updateText) { + myInstanceFiltersField.setText(StringUtil.join(filters, " ")); } - private void reloadClassFilters() { - String filtersText = myClassFiltersField.getText(); + String tipText = concatWithEx(new StringBuilder(), filters, " ", (int)Math.sqrt(myInstanceFilters.length) + 1, "\n").toString(); + myInstanceFiltersField.getTextField().setToolTipText(tipText); + } - ArrayList classFilters = new ArrayList<>(); - ArrayList exclusionFilters = new ArrayList<>(); - int startFilter = -1; - for (int i = 0; i <= filtersText.length(); i++) { - if (i < filtersText.length() && !Character.isWhitespace(filtersText.charAt(i))) { - if (startFilter == -1) { - startFilter = i; - } - } else { - if (startFilter >= 0) { - if (filtersText.charAt(startFilter) == '-') { - exclusionFilters.add(new ClassFilter(filtersText.substring(startFilter + 1, i))); - } else { - classFilters.add(new ClassFilter(filtersText.substring(startFilter, i))); - } - startFilter = -1; - } - } - } - for (ClassFilter classFilter : myClassFilters) { - if (!classFilter.isEnabled()) { - classFilters.add(classFilter); - } - } - for (ClassFilter classFilter : myClassExclusionFilters) { - if (!classFilter.isEnabled()) { - exclusionFilters.add(classFilter); - } - } - myClassFilters = classFilters.toArray(ClassFilter.EMPTY_ARRAY); - myClassExclusionFilters = exclusionFilters.toArray(ClassFilter.EMPTY_ARRAY); + private class MyTextField extends JTextField { + private MyTextField() { } + + @Override + public String getToolTipText(MouseEvent event) { + reloadClassFilters(); + updateClassFilterEditor(false); + reloadInstanceFilters(); + updateInstanceFilterEditor(false); + String toolTipText = super.getToolTipText(event); + return getToolTipText().isEmpty() ? null : toolTipText; } - private void reloadInstanceFilters() { - String filtersText = myInstanceFiltersField.getText(); + @Override + public JToolTip createToolTip() { + JToolTip toolTip = new JToolTip() {{ + setUI(new MultiLineTooltipUI()); + }}; + toolTip.setComponent(this); + return toolTip; + } + } - ArrayList idxs = new ArrayList<>(); - int startNumber = -1; - for (int i = 0; i <= filtersText.length(); i++) { - if (i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) { - if (startNumber == -1) { - startNumber = i; - } - } else { - if (startNumber >= 0) { - idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i))); - startNumber = -1; - } - } + private void reloadClassFilters() { + String filtersText = myClassFiltersField.getText(); + + ArrayList classFilters = new ArrayList<>(); + ArrayList exclusionFilters = new ArrayList<>(); + int startFilter = -1; + for (int i = 0; i <= filtersText.length(); i++) { + if (i < filtersText.length() && !Character.isWhitespace(filtersText.charAt(i))) { + if (startFilter == -1) { + startFilter = i; } - for (InstanceFilter instanceFilter : myInstanceFilters) { - if (!instanceFilter.isEnabled()) { - idxs.add(instanceFilter); - } + } + else { + if (startFilter >= 0) { + if (filtersText.charAt(startFilter) == '-') { + exclusionFilters.add(new ClassFilter(filtersText.substring(startFilter + 1, i))); + } + else { + classFilters.add(new ClassFilter(filtersText.substring(startFilter, i))); + } + startFilter = -1; } - myInstanceFilters = idxs.toArray(InstanceFilter.EMPTY_ARRAY); + } + } + for (ClassFilter classFilter : myClassFilters) { + if (!classFilter.isEnabled()) { + classFilters.add(classFilter); + } + } + for (ClassFilter classFilter : myClassExclusionFilters) { + if (!classFilter.isEnabled()) { + exclusionFilters.add(classFilter); + } + } + myClassFilters = classFilters.toArray(ClassFilter.EMPTY_ARRAY); + myClassExclusionFilters = exclusionFilters.toArray(ClassFilter.EMPTY_ARRAY); + } + + private void reloadInstanceFilters() { + String filtersText = myInstanceFiltersField.getText(); + + ArrayList idxs = new ArrayList<>(); + int startNumber = -1; + for (int i = 0; i <= filtersText.length(); i++) { + if (i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) { + if (startNumber == -1) { + startNumber = i; + } + } + else { + if (startNumber >= 0) { + idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i))); + startNumber = -1; + } + } + } + for (InstanceFilter instanceFilter : myInstanceFilters) { + if (!instanceFilter.isEnabled()) { + idxs.add(instanceFilter); + } + } + myInstanceFilters = idxs.toArray(InstanceFilter.EMPTY_ARRAY); + } + + private void updateClassFilterEditor(boolean updateText) { + List filters = new ArrayList<>(); + for (ClassFilter classFilter : myClassFilters) { + if (classFilter.isEnabled()) { + filters.add(classFilter.getPattern()); + } + } + List excludeFilters = new ArrayList<>(); + for (ClassFilter classFilter : myClassExclusionFilters) { + if (classFilter.isEnabled()) { + excludeFilters.add("-" + classFilter.getPattern()); + } + } + if (updateText) { + String editorText = StringUtil.join(filters, " "); + if (!filters.isEmpty()) { + editorText += " "; + } + editorText += StringUtil.join(excludeFilters, " "); + myClassFiltersField.setText(editorText); } - private void updateClassFilterEditor(boolean updateText) { - List filters = new ArrayList<>(); - for (ClassFilter classFilter : myClassFilters) { - if (classFilter.isEnabled()) { - filters.add(classFilter.getPattern()); - } - } - List excludeFilters = new ArrayList<>(); - for (ClassFilter classFilter : myClassExclusionFilters) { - if (classFilter.isEnabled()) { - excludeFilters.add("-" + classFilter.getPattern()); - } - } - if (updateText) { - String editorText = StringUtil.join(filters, " "); - if (!filters.isEmpty()) { - editorText += " "; - } - editorText += StringUtil.join(excludeFilters, " "); - myClassFiltersField.setText(editorText); - } - - int width = (int) Math.sqrt(myClassExclusionFilters.length + myClassFilters.length) + 1; - StringBuilder tipTextBuilder = new StringBuilder(); - concatWithEx(tipTextBuilder, filters, " ", width, "\n"); - if (!filters.isEmpty()) { - tipTextBuilder.append("\n"); - } - String tipText = concatWithEx(tipTextBuilder, excludeFilters, " ", width, "\n").toString(); - myClassFiltersField.getTextField().setToolTipText(tipText); + int width = (int)Math.sqrt(myClassExclusionFilters.length + myClassFilters.length) + 1; + StringBuilder tipTextBuilder = new StringBuilder(); + concatWithEx(tipTextBuilder, filters, " ", width, "\n"); + if (!filters.isEmpty()) { + tipTextBuilder.append("\n"); } + String tipText = concatWithEx(tipTextBuilder, excludeFilters, " ", width, "\n").toString(); + myClassFiltersField.getTextField().setToolTipText(tipText); + } - private static @NlsSafe StringBuilder concatWithEx(StringBuilder builder, List s, String glue, int N, String nthGlue) { - int i = 1; - for (Iterator iterator = s.iterator(); iterator.hasNext(); i++) { - String str = iterator.next(); - builder.append(str); - if (iterator.hasNext()) { - if (i % N == 0) { - builder.append(nthGlue); - } else { - builder.append(glue); - } - } + private static @NlsSafe StringBuilder concatWithEx(StringBuilder builder, List s, String glue, int N, String nthGlue) { + int i = 1; + for (Iterator iterator = s.iterator(); iterator.hasNext(); i++) { + String str = iterator.next(); + builder.append(str); + if (iterator.hasNext()) { + if (i % N == 0) { + builder.append(nthGlue); } - return builder; - } - - protected com.intellij.ide.util.ClassFilter createClassConditionFilter() { - return myBreakpointPsiClass == null - ? null - : (aClass -> myBreakpointPsiClass == aClass || aClass.isInheritor(myBreakpointPsiClass, true)); - } - - protected void updateCheckboxes() { - boolean passCountApplicable = true; - if (myInstanceFiltersCheckBox.isSelected() || myClassFiltersCheckBox.isSelected()) { - passCountApplicable = false; + else { + builder.append(glue); } - myPassCountCheckbox.setEnabled(passCountApplicable); - - boolean passCountSelected = myPassCountCheckbox.isSelected(); - myInstanceFiltersCheckBox.setEnabled(!passCountSelected); - myClassFiltersCheckBox.setEnabled(!passCountSelected); - - myPassCountField.setEditable(myPassCountCheckbox.isSelected()); - myPassCountField.setEnabled(myPassCountCheckbox.isSelected()); - - myInstanceFiltersField.setEnabled(myInstanceFiltersCheckBox.isSelected()); - myInstanceFiltersField.getTextField().setEditable(myInstanceFiltersCheckBox.isSelected()); - - myClassFiltersField.setEnabled(myClassFiltersCheckBox.isSelected()); - myClassFiltersField.getTextField().setEditable(myClassFiltersCheckBox.isSelected()); + } } + return builder; + } + + protected com.intellij.ide.util.ClassFilter createClassConditionFilter() { + return myBreakpointPsiClass == null + ? null + : (aClass -> myBreakpointPsiClass == aClass || aClass.isInheritor(myBreakpointPsiClass, true)); + } + + protected void updateCheckboxes() { + boolean passCountApplicable = true; + if (myInstanceFiltersCheckBox.isSelected() || myClassFiltersCheckBox.isSelected()) { + passCountApplicable = false; + } + myPassCountCheckbox.setEnabled(passCountApplicable); + + boolean passCountSelected = myPassCountCheckbox.isSelected(); + myInstanceFiltersCheckBox.setEnabled(!passCountSelected); + myClassFiltersCheckBox.setEnabled(!passCountSelected); + + myPassCountField.setEditable(myPassCountCheckbox.isSelected()); + myPassCountField.setEnabled(myPassCountCheckbox.isSelected()); + + myInstanceFiltersField.setEnabled(myInstanceFiltersCheckBox.isSelected()); + myInstanceFiltersField.getTextField().setEditable(myInstanceFiltersCheckBox.isSelected()); + + myClassFiltersField.setEnabled(myClassFiltersCheckBox.isSelected()); + myClassFiltersField.getTextField().setEditable(myClassFiltersCheckBox.isSelected()); + } } diff --git a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/dialog/AddFieldBreakpointDialog.java b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/dialog/AddFieldBreakpointDialog.java index f0cfed289174..4a58ad456175 100644 --- a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/dialog/AddFieldBreakpointDialog.java +++ b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/breakpoints/dialog/AddFieldBreakpointDialog.java @@ -19,6 +19,9 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.concurrency.AppExecutorUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.asJava.classes.KtLightClass; @@ -30,148 +33,240 @@ import org.jetbrains.kotlin.psi.KtClassOrObject; import org.jetbrains.kotlin.psi.KtDeclaration; import org.jetbrains.kotlin.psi.KtProperty; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.ResourceBundle; public abstract class AddFieldBreakpointDialog extends DialogWrapper { - private final Project myProject; - private JPanel myPanel; - private TextFieldWithBrowseButton myFieldChooser; - private TextFieldWithBrowseButton myClassChooser; + private final Project myProject; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myFieldChooser; + private final TextFieldWithBrowseButton myClassChooser; - public AddFieldBreakpointDialog(Project project) { - super(project, true); - myProject = project; - setTitle(KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.title")); - init(); + public AddFieldBreakpointDialog(Project project) { + super(project, true); + myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, 6)); + myClassChooser = new TextFieldWithBrowseButton(); + myPanel.add(myClassChooser, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myFieldChooser = new TextFieldWithBrowseButton(); + myPanel.add(myFieldChooser, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JPanel panel1 = new JPanel(); + myPanel.add(panel1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(-1, 1), null, new Dimension(-1, 1), 0, false)); + panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "property.watchpoint.add.dialog.choose.property.label")); + myPanel.add(label1, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", + "property.watchpoint.add.dialog.choose.owner.class.label")); + myPanel.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } + setTitle(KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.title")); + init(); + } - @Override - protected JComponent createCenterPanel() { - myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { - @Override - public void textChanged(@NotNull DocumentEvent event) { - updateUI(); - } - }); + private static Method $$$cachedGetBundleMethod$$$ = null; - myClassChooser.addActionListener(e -> { - PsiClass currentClass = getSelectedClass(); - TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser( - KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.choose.owner.class.title")); - if (currentClass != null) { - PsiFile containingFile = currentClass.getContainingFile(); - if (containingFile != null) { - PsiDirectory containingDirectory = containingFile.getContainingDirectory(); - if (containingDirectory != null) { - chooser.selectDirectory(containingDirectory); - } - } - } - chooser.showDialog(); - PsiClass selectedClass = chooser.getSelected(); - if (selectedClass != null) { - myClassChooser.setText(selectedClass.getQualifiedName()); - } - }); - - myFieldChooser.addActionListener(e -> { - PsiClass selectedClass = getSelectedClass(); - if (selectedClass != null) { - showFieldChooser(selectedClass); - } - }); - myFieldChooser.setEnabled(false); - return myPanel; + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - private void showFieldChooser(@NotNull PsiClass selectedClass) { - Project project = selectedClass.getProject(); - - ReadAction.nonBlocking(() -> collectPropertyMembers(selectedClass)) - .expireWith(KotlinPluginDisposable.getInstance(project)) - .finishOnUiThread(ModalityState.defaultModalityState(), (properties) -> { - if (properties != null) { - var chooser = new MemberChooser<>(properties, false, false, project); - chooser.setTitle(KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.chooser.title", properties.length)); - chooser.setCopyJavadocVisible(false); - chooser.show(); - var selectedElements = chooser.getSelectedElements(); - if (selectedElements != null && selectedElements.size() == 1) { - var field = (KtProperty) selectedElements.get(0).getElement(); - myFieldChooser.setText(field.getName()); - } - } - }).submit(AppExecutorUtil.getAppExecutorService()); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - private static KotlinPsiElementMemberChooserObject[] collectPropertyMembers(PsiClass container) { - var result = new ArrayList(); - - if (container instanceof KtLightClassForFacade facadeClass) { - for (var file : facadeClass.getFiles()) { - for (var declaration : file.getDeclarations()) { - ProgressManager.checkCanceled(); - if (declaration instanceof KtProperty) { - result.add(KotlinPsiElementMemberChooserObject.getKotlinMemberChooserObject(declaration)); - } - } - } - } else if (container instanceof KtLightClass) { - KtClassOrObject kotlinOrigin = ((KtLightClass) container).getKotlinOrigin(); - if (kotlinOrigin != null) { - for (KtDeclaration declaration : kotlinOrigin.getDeclarations()) { - ProgressManager.checkCanceled(); - if (declaration instanceof KtProperty) { - result.add(KotlinPsiElementMemberChooserObject.getKotlinMemberChooserObject(declaration)); - } - } - } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - - return result.toArray(new KotlinPsiElementMemberChooserObject[0]); + } + result.append(text.charAt(i)); } - - private void updateUI() { - PsiClass selectedClass = getSelectedClass(); - myFieldChooser.setEnabled(selectedClass != null); + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - private PsiClass getSelectedClass() { - PsiManager psiManager = PsiManager.getInstance(myProject); - String classQName = myClassChooser.getText(); - if (StringUtil.isEmpty(classQName)) { - return null; + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + + @Override + protected JComponent createCenterPanel() { + myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + @Override + public void textChanged(@NotNull DocumentEvent event) { + updateUI(); + } + }); + + myClassChooser.addActionListener(e -> { + PsiClass currentClass = getSelectedClass(); + TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser( + KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.choose.owner.class.title")); + if (currentClass != null) { + PsiFile containingFile = currentClass.getContainingFile(); + if (containingFile != null) { + PsiDirectory containingDirectory = containingFile.getContainingDirectory(); + if (containingDirectory != null) { + chooser.selectDirectory(containingDirectory); + } } - return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(classQName, GlobalSearchScope.allScope(myProject)); - } + } + chooser.showDialog(); + PsiClass selectedClass = chooser.getSelected(); + if (selectedClass != null) { + myClassChooser.setText(selectedClass.getQualifiedName()); + } + }); - @Override - public JComponent getPreferredFocusedComponent() { - return myClassChooser.getTextField(); - } + myFieldChooser.addActionListener(e -> { + PsiClass selectedClass = getSelectedClass(); + if (selectedClass != null) { + showFieldChooser(selectedClass); + } + }); + myFieldChooser.setEnabled(false); + return myPanel; + } - public String getClassName() { - return myClassChooser.getText(); - } + private void showFieldChooser(@NotNull PsiClass selectedClass) { + Project project = selectedClass.getProject(); - @Override - protected String getDimensionServiceKey() { - return "#com.intellij.debugger.ui.breakpoints.BreakpointsConfigurationDialogFactory.BreakpointsConfigurationDialog.AddFieldBreakpointDialog"; - } - - public String getFieldName() { - return myFieldChooser.getText(); - } - - protected abstract boolean validateData(); - - @Override - protected void doOKAction() { - if (validateData()) { - super.doOKAction(); + ReadAction.nonBlocking(() -> collectPropertyMembers(selectedClass)) + .expireWith(KotlinPluginDisposable.getInstance(project)) + .finishOnUiThread(ModalityState.defaultModalityState(), (properties) -> { + if (properties != null) { + var chooser = new MemberChooser<>(properties, false, false, project); + chooser.setTitle(KotlinDebuggerCoreBundle.message("property.watchpoint.add.dialog.chooser.title", properties.length)); + chooser.setCopyJavadocVisible(false); + chooser.show(); + var selectedElements = chooser.getSelectedElements(); + if (selectedElements != null && selectedElements.size() == 1) { + var field = (KtProperty)selectedElements.get(0).getElement(); + myFieldChooser.setText(field.getName()); + } } + }).submit(AppExecutorUtil.getAppExecutorService()); + } + + private static KotlinPsiElementMemberChooserObject[] collectPropertyMembers(PsiClass container) { + var result = new ArrayList(); + + if (container instanceof KtLightClassForFacade facadeClass) { + for (var file : facadeClass.getFiles()) { + for (var declaration : file.getDeclarations()) { + ProgressManager.checkCanceled(); + if (declaration instanceof KtProperty) { + result.add(KotlinPsiElementMemberChooserObject.getKotlinMemberChooserObject(declaration)); + } + } + } } + else if (container instanceof KtLightClass) { + KtClassOrObject kotlinOrigin = ((KtLightClass)container).getKotlinOrigin(); + if (kotlinOrigin != null) { + for (KtDeclaration declaration : kotlinOrigin.getDeclarations()) { + ProgressManager.checkCanceled(); + if (declaration instanceof KtProperty) { + result.add(KotlinPsiElementMemberChooserObject.getKotlinMemberChooserObject(declaration)); + } + } + } + } + + return result.toArray(new KotlinPsiElementMemberChooserObject[0]); + } + + private void updateUI() { + PsiClass selectedClass = getSelectedClass(); + myFieldChooser.setEnabled(selectedClass != null); + } + + private PsiClass getSelectedClass() { + PsiManager psiManager = PsiManager.getInstance(myProject); + String classQName = myClassChooser.getText(); + if (StringUtil.isEmpty(classQName)) { + return null; + } + return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(classQName, GlobalSearchScope.allScope(myProject)); + } + + @Override + public JComponent getPreferredFocusedComponent() { + return myClassChooser.getTextField(); + } + + public String getClassName() { + return myClassChooser.getText(); + } + + @Override + protected String getDimensionServiceKey() { + return "#com.intellij.debugger.ui.breakpoints.BreakpointsConfigurationDialogFactory.BreakpointsConfigurationDialog.AddFieldBreakpointDialog"; + } + + public String getFieldName() { + return myFieldChooser.getText(); + } + + protected abstract boolean validateData(); + + @Override + protected void doOKAction() { + if (validateData()) { + super.doOKAction(); + } + } } diff --git a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/stepping/KotlinSteppingConfigurableUi.java b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/stepping/KotlinSteppingConfigurableUi.java index c7789870f122..66e5c6ca5dab 100644 --- a/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/stepping/KotlinSteppingConfigurableUi.java +++ b/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/stepping/KotlinSteppingConfigurableUi.java @@ -4,38 +4,118 @@ package org.jetbrains.kotlin.idea.debugger.core.stepping; import com.intellij.openapi.options.ConfigurableUi; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class KotlinSteppingConfigurableUi implements ConfigurableUi { - private JCheckBox ignoreKotlinMethods; - private JCheckBox alwaysDoSmartStepInto; - private JPanel myPanel; + private final JCheckBox ignoreKotlinMethods; + private final JCheckBox alwaysDoSmartStepInto; + private final JPanel myPanel; - @Override - public void reset(@NotNull KotlinDebuggerSettings settings) { - ignoreKotlinMethods.setSelected(settings.getDisableKotlinInternalClasses()); - alwaysDoSmartStepInto.setSelected(settings.getAlwaysDoSmartStepInto()); + public KotlinSteppingConfigurableUi() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + ignoreKotlinMethods = new JCheckBox(); + ignoreKotlinMethods.setSelected(false); + this.$$$loadButtonText$$$(ignoreKotlinMethods, + this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", "filter.ignore.internal.classes")); + myPanel.add(ignoreKotlinMethods, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + alwaysDoSmartStepInto = new JCheckBox(); + this.$$$loadButtonText$$$(alwaysDoSmartStepInto, + this.$$$getMessageFromBundle$$$("messages/KotlinDebuggerCoreBundle", "always.do.smart.step.into")); + myPanel.add(alwaysDoSmartStepInto, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); } + } - @Override - public boolean isModified(@NotNull KotlinDebuggerSettings settings) { - return settings.getDisableKotlinInternalClasses() != ignoreKotlinMethods.isSelected() || - settings.getAlwaysDoSmartStepInto() != alwaysDoSmartStepInto.isSelected(); - } + private static Method $$$cachedGetBundleMethod$$$ = null; - @Override - public void apply(@NotNull KotlinDebuggerSettings settings) { - settings.setDisableKotlinInternalClasses(ignoreKotlinMethods.isSelected()); - settings.setAlwaysDoSmartStepInto(alwaysDoSmartStepInto.isSelected()); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } - @Override - public @NotNull JComponent getComponent() { - return myPanel; + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + + @Override + public void reset(@NotNull KotlinDebuggerSettings settings) { + ignoreKotlinMethods.setSelected(settings.getDisableKotlinInternalClasses()); + alwaysDoSmartStepInto.setSelected(settings.getAlwaysDoSmartStepInto()); + } + + @Override + public boolean isModified(@NotNull KotlinDebuggerSettings settings) { + return settings.getDisableKotlinInternalClasses() != ignoreKotlinMethods.isSelected() || + settings.getAlwaysDoSmartStepInto() != alwaysDoSmartStepInto.isSelected(); + } + + @Override + public void apply(@NotNull KotlinDebuggerSettings settings) { + settings.setDisableKotlinInternalClasses(ignoreKotlinMethods.isSelected()); + settings.setAlwaysDoSmartStepInto(alwaysDoSmartStepInto.isSelected()); + } + + @Override + public @NotNull JComponent getComponent() { + return myPanel; + } } diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/extractFunction/ui/KotlinFirExtractFunctionDialog.java b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/extractFunction/ui/KotlinFirExtractFunctionDialog.java index ab84820af270..0ffaf17fa07a 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/extractFunction/ui/KotlinFirExtractFunctionDialog.java +++ b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/extractFunction/ui/KotlinFirExtractFunctionDialog.java @@ -10,7 +10,11 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.psi.PsiElement; import com.intellij.refactoring.ui.NameSuggestionsField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TitledSeparator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; @@ -39,6 +43,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression; import org.jetbrains.kotlin.psi.KtTypeCodeFragment; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; @@ -46,286 +51,444 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; public class KotlinFirExtractFunctionDialog extends DialogWrapper { - private JPanel contentPane; - private TitledSeparator inputParametersPanel; - private JComboBox visibilityBox; - private KotlinSignatureComponent signaturePreviewField; - private JPanel functionNamePanel; - private NameSuggestionsField functionNameField; - private JLabel functionNameLabel; - private JComboBox returnTypeBox; - private JPanel returnTypePanel; - private FirExtractFunctionParameterTablePanel parameterTablePanel; + private final JPanel contentPane; + private final TitledSeparator inputParametersPanel; + private final JComboBox visibilityBox; + private final KotlinSignatureComponent signaturePreviewField; + private final JPanel functionNamePanel; + private NameSuggestionsField functionNameField; + private final JLabel functionNameLabel; + private final JComboBox returnTypeBox; + private final JPanel returnTypePanel; + private FirExtractFunctionParameterTablePanel parameterTablePanel; - private final Project project; + private final Project project; - private final ExtractableCodeDescriptorWithConflicts originalDescriptor; + private final ExtractableCodeDescriptorWithConflicts originalDescriptor; - private final Function1 onAccept; + private final Function1 onAccept; - public KotlinFirExtractFunctionDialog( - @NotNull Project project, - @NotNull ExtractableCodeDescriptorWithConflicts originalDescriptor, - @NotNull Function1 onAccept - ) { - super(project, true); + public KotlinFirExtractFunctionDialog( + @NotNull Project project, + @NotNull ExtractableCodeDescriptorWithConflicts originalDescriptor, + @NotNull Function1 onAccept + ) { + super(project, true); - this.project = project; - this.originalDescriptor = originalDescriptor; - this.onAccept = onAccept; - - setModal(true); - setTitle(KotlinBundle.message("extract.function")); - init(); - update(); + this.project = project; + this.originalDescriptor = originalDescriptor; + this.onAccept = onAccept; + { + this.signaturePreviewField = new KotlinSignatureComponent("", project); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + inputParametersPanel = new TitledSeparator(); + inputParametersPanel.setLayout(new BorderLayout(0, 0)); + inputParametersPanel.setText(""); + inputParametersPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(inputParametersPanel, BorderLayout.CENTER); + inputParametersPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/KotlinBundle", "title.parameters"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 200), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", + "signature.preview"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + signaturePreviewField.setText(""); + panel4.add(signaturePreviewField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(500, 100), new Dimension(500, 100), null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.setEnabled(true); + panel5.setVisible(true); + contentPane.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + functionNameLabel = new JLabel(); + this.$$$loadLabelText$$$(functionNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "name")); + panel5.add(functionNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "visibility")); + label1.setVisible(true); + panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(114, 16), null, 0, false)); + functionNamePanel = new JPanel(); + functionNamePanel.setLayout(new BorderLayout(0, 0)); + panel5.add(functionNamePanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + visibilityBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("private"); + defaultComboBoxModel1.addElement("protected"); + defaultComboBoxModel1.addElement("internal"); + defaultComboBoxModel1.addElement("public"); + visibilityBox.setModel(defaultComboBoxModel1); + visibilityBox.setVisible(true); + panel5.add(visibilityBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(114, 26), null, 0, false)); + returnTypePanel = new JPanel(); + returnTypePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.add(returnTypePanel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "return.type")); + returnTypePanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + returnTypePanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + returnTypeBox = new JComboBox(); + returnTypePanel.add(returnTypeBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPane.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(visibilityBox); + label2.setLabelFor(returnTypeBox); } - private void createUIComponents() { - this.signaturePreviewField = new KotlinSignatureComponent("", project); + setModal(true); + setTitle(KotlinBundle.message("extract.function")); + init(); + update(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - private boolean isVisibilitySectionAvailable() { - return ExtractUtilKt.isVisibilityApplicable(originalDescriptor.getDescriptor().getExtractionData()); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - private String getFunctionName() { - return KtPsiUtilKt.quoteIfNeeded(functionNameField.getEnteredName()); - } - - private @Nullable KtModifierKeywordToken getVisibility() { - if (!isVisibilitySectionAvailable()) return null; - - KtModifierKeywordToken value = (KtModifierKeywordToken) visibilityBox.getSelectedItem(); - return KtTokens.DEFAULT_VISIBILITY_KEYWORD.equals(value) ? null : value; - } - - private boolean checkNames() { - if (!KtPsiUtilKt.isIdentifier(getFunctionName())) return false; - for (FirExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : parameterTablePanel.getSelectedParameterInfos()) { - if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - return true; + } + result.append(text.charAt(i)); } - - private void update() { - setOKActionEnabled(checkNames()); - ReadAction.nonBlocking(() -> - PresentationUtilKt.getSignaturePreview(originalDescriptor.getDescriptor(), - getFunctionName(), - getVisibility(), - parameterTablePanel.getSelectedReceiverInfo(), - parameterTablePanel.getSelectedParameterInfos(), - ((KtTypeCodeFragment) returnTypeBox.getSelectedItem()), - originalDescriptor.getDescriptor().getContext()) - ) - .expireWith(getDisposable()) - .finishOnUiThread(ModalityState.stateForComponent(signaturePreviewField), preview -> signaturePreviewField.setText(preview)) - .submit(AppExecutorUtil.getAppExecutorService()); + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - @Override - protected void init() { - super.init(); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } - ExtractableCodeDescriptor extractableCodeDescriptor = originalDescriptor.getDescriptor(); + private boolean isVisibilitySectionAvailable() { + return ExtractUtilKt.isVisibilityApplicable(originalDescriptor.getDescriptor().getExtractionData()); + } - functionNameField = new NameSuggestionsField( - //TODO ArrayUtil.toStringArray(extractableCodeDescriptor.getSuggestedNames()), - // without type pointers (see KT-60484), combobox with names fires events which invalidate types precalculated by first phase of refactoring - new String[] { extractableCodeDescriptor.getName() }, - project, - PlainTextFileType.INSTANCE - ); - functionNameField.addDataChangedListener(() -> update()); - functionNamePanel.add(functionNameField, BorderLayout.CENTER); - functionNameLabel.setLabelFor(functionNameField); + private String getFunctionName() { + return KtPsiUtilKt.quoteIfNeeded(functionNameField.getEnteredName()); + } - KtElement context = originalDescriptor.getDescriptor().getContext(); - List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); - if (!possibleReturnTypes.isEmpty()) { - List fragments = ContainerUtil.map(possibleReturnTypes, - t -> new KtPsiFactory(project).createTypeCodeFragment( - PresentationUtilKt.render(t, context), context)); - DefaultComboBoxModel returnTypeBoxModel = - new DefaultComboBoxModel<>(fragments.toArray(new KtTypeCodeFragment[0])); - returnTypeBox.setModel(returnTypeBoxModel); - returnTypeBox.setRenderer( - new DefaultListCellRenderer() { - @Override - public @NotNull Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus - ) { - @NlsSafe - String text = ((KtTypeCodeFragment) value).getText(); - setText(text); - return this; - } - } - ); - returnTypeBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); - } else { - returnTypePanel.getParent().remove(returnTypePanel); + private @Nullable KtModifierKeywordToken getVisibility() { + if (!isVisibilitySectionAvailable()) return null; + + KtModifierKeywordToken value = (KtModifierKeywordToken)visibilityBox.getSelectedItem(); + return KtTokens.DEFAULT_VISIBILITY_KEYWORD.equals(value) ? null : value; + } + + private boolean checkNames() { + if (!KtPsiUtilKt.isIdentifier(getFunctionName())) return false; + for (FirExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : parameterTablePanel.getSelectedParameterInfos()) { + if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + } + return true; + } + + private void update() { + setOKActionEnabled(checkNames()); + ReadAction.nonBlocking(() -> + PresentationUtilKt.getSignaturePreview(originalDescriptor.getDescriptor(), + getFunctionName(), + getVisibility(), + parameterTablePanel.getSelectedReceiverInfo(), + parameterTablePanel.getSelectedParameterInfos(), + ((KtTypeCodeFragment)returnTypeBox.getSelectedItem()), + originalDescriptor.getDescriptor().getContext()) + ) + .expireWith(getDisposable()) + .finishOnUiThread(ModalityState.stateForComponent(signaturePreviewField), preview -> signaturePreviewField.setText(preview)) + .submit(AppExecutorUtil.getAppExecutorService()); + } + + @Override + protected void init() { + super.init(); + + ExtractableCodeDescriptor extractableCodeDescriptor = originalDescriptor.getDescriptor(); + + functionNameField = new NameSuggestionsField( + //TODO ArrayUtil.toStringArray(extractableCodeDescriptor.getSuggestedNames()), + // without type pointers (see KT-60484), combobox with names fires events which invalidate types precalculated by first phase of refactoring + new String[]{extractableCodeDescriptor.getName()}, + project, + PlainTextFileType.INSTANCE + ); + functionNameField.addDataChangedListener(() -> update()); + functionNamePanel.add(functionNameField, BorderLayout.CENTER); + functionNameLabel.setLabelFor(functionNameField); + + KtElement context = originalDescriptor.getDescriptor().getContext(); + List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); + if (!possibleReturnTypes.isEmpty()) { + List fragments = ContainerUtil.map(possibleReturnTypes, + t -> new KtPsiFactory(project).createTypeCodeFragment( + PresentationUtilKt.render(t, context), context)); + DefaultComboBoxModel returnTypeBoxModel = + new DefaultComboBoxModel<>(fragments.toArray(new KtTypeCodeFragment[0])); + returnTypeBox.setModel(returnTypeBoxModel); + returnTypeBox.setRenderer( + new DefaultListCellRenderer() { + @Override + public @NotNull Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + @NlsSafe + String text = ((KtTypeCodeFragment)value).getText(); + setText(text); + return this; + } } - - visibilityBox.setModel(new DefaultComboBoxModel(KtTokens.VISIBILITY_MODIFIERS.getTypes())); - - boolean enableVisibility = isVisibilitySectionAvailable(); - visibilityBox.setEnabled(enableVisibility); - if (enableVisibility) { - KtModifierKeywordToken defaultVisibility = extractableCodeDescriptor.getVisibility(); - visibilityBox.setSelectedItem(defaultVisibility); + ); + returnTypeBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); + } } - visibilityBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); - - parameterTablePanel = new FirExtractFunctionParameterTablePanel() { - @Override - public @NotNull KtElement getContext() { - return context; - } - - @Override - protected void updateSignature() { - KotlinFirExtractFunctionDialog.this.update(); - } - - @Override - protected void onEnterAction() { - doOKAction(); - } - - @Override - protected void onCancelAction() { - doCancelAction(); - } - }; - parameterTablePanel.init(extractableCodeDescriptor.getReceiverParameter(), extractableCodeDescriptor.getParameters()); - - inputParametersPanel.setText(KotlinBundle.message("text.parameters")); - inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); - inputParametersPanel.add(parameterTablePanel); + ); + } + else { + returnTypePanel.getParent().remove(returnTypePanel); } - @Override - protected void doOKAction() { - ExtractableCodeDescriptorWithConflicts result = PresentationUtilKt.validate(originalDescriptor.getDescriptor(), - getFunctionName(), - getVisibility(), - parameterTablePanel.getSelectedReceiverInfo(), - parameterTablePanel.getSelectedParameterInfos(), - ((KtTypeCodeFragment) returnTypeBox.getSelectedItem()), - originalDescriptor.getDescriptor().getContext()); + visibilityBox.setModel(new DefaultComboBoxModel(KtTokens.VISIBILITY_MODIFIERS.getTypes())); - MultiMap conflicts = result.getConflicts(); - conflicts.values().removeAll(originalDescriptor.getConflicts().values()); - - KotlinCommonRefactoringUtilKt.checkConflictsInteractively( - project, - conflicts, - new Function0<>() { - @Override - public Unit invoke() { - close(OK_EXIT_CODE); - return Unit.INSTANCE; - } - }, - new Function0<>() { - @Override - public Unit invoke() { - KotlinFirExtractFunctionDialog.super.doOKAction(); - return onAccept.invoke(result.getDescriptor()); - } - } - ); - close(OK_EXIT_CODE); + boolean enableVisibility = isVisibilitySectionAvailable(); + visibilityBox.setEnabled(enableVisibility); + if (enableVisibility) { + KtModifierKeywordToken defaultVisibility = extractableCodeDescriptor.getVisibility(); + visibilityBox.setSelectedItem(defaultVisibility); } - - @Override - public JComponent getPreferredFocusedComponent() { - return functionNameField.getFocusableComponent(); - } - - @Override - protected JComponent createCenterPanel() { - return contentPane; - } - - @Override - protected @NotNull JComponent createContentPane() { - return contentPane; - } - - public static ExtractableCodeDescriptor createNewDescriptor( - @NotNull ExtractableCodeDescriptor originalDescriptor, - @NotNull String newName, - @Nullable KtModifierKeywordToken newVisibility, - @Nullable FirExtractFunctionParameterTablePanel.ParameterInfo newReceiverInfo, - @NotNull List newParameterInfos, - @Nullable KaType returnType - ) { - Map oldToNewParameters = new LinkedHashMap<>(); - for (FirExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) { - oldToNewParameters.put(parameterInfo.getOriginalParameter(), parameterInfo.toParameter()); - } - Parameter originalReceiver = originalDescriptor.getReceiverParameter(); - Parameter newReceiver = newReceiverInfo != null ? newReceiverInfo.toParameter() : null; - if (originalReceiver != null && newReceiver != null) { - oldToNewParameters.put(originalReceiver, newReceiver); + visibilityBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); } + } + ); - ExtractionData data = originalDescriptor.getExtractionData(); - var newReplacementMap = MultiMap.>create(); - originalDescriptor.getReplacementMap() - .entrySet() - .forEach(entry -> { - List> newReplacement = ContainerUtil.map(entry.getValue(), p -> { - if (p instanceof ParameterReplacement r) { - Parameter newParameter = oldToNewParameters.get(r.getParameter()); - return newParameter != null ? r.copy(newParameter) : p; - } else { - return p; - } - }); - newReplacementMap.putValues(entry.getKey(), newReplacement); - }); - return new ExtractableCodeDescriptor(originalDescriptor.getContext(), - data, - List.of(newName), - newVisibility, - oldToNewParameters.values().stream().filter(p -> p != newReceiver).toList(), - newReceiver, - originalDescriptor.getTypeParameters(), - newReplacementMap, - originalDescriptor.getControlFlow(), - returnType, - originalDescriptor.getModifiers(), - originalDescriptor.getOptInMarkers(), - originalDescriptor.getRenderedAnnotations()); + parameterTablePanel = new FirExtractFunctionParameterTablePanel() { + @Override + public @NotNull KtElement getContext() { + return context; + } + + @Override + protected void updateSignature() { + KotlinFirExtractFunctionDialog.this.update(); + } + + @Override + protected void onEnterAction() { + doOKAction(); + } + + @Override + protected void onCancelAction() { + doCancelAction(); + } + }; + parameterTablePanel.init(extractableCodeDescriptor.getReceiverParameter(), extractableCodeDescriptor.getParameters()); + + inputParametersPanel.setText(KotlinBundle.message("text.parameters")); + inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); + inputParametersPanel.add(parameterTablePanel); + } + + @Override + protected void doOKAction() { + ExtractableCodeDescriptorWithConflicts result = PresentationUtilKt.validate(originalDescriptor.getDescriptor(), + getFunctionName(), + getVisibility(), + parameterTablePanel.getSelectedReceiverInfo(), + parameterTablePanel.getSelectedParameterInfos(), + ((KtTypeCodeFragment)returnTypeBox.getSelectedItem()), + originalDescriptor.getDescriptor().getContext()); + + MultiMap conflicts = result.getConflicts(); + conflicts.values().removeAll(originalDescriptor.getConflicts().values()); + + KotlinCommonRefactoringUtilKt.checkConflictsInteractively( + project, + conflicts, + new Function0<>() { + @Override + public Unit invoke() { + close(OK_EXIT_CODE); + return Unit.INSTANCE; + } + }, + new Function0<>() { + @Override + public Unit invoke() { + KotlinFirExtractFunctionDialog.super.doOKAction(); + return onAccept.invoke(result.getDescriptor()); + } + } + ); + close(OK_EXIT_CODE); + } + + @Override + public JComponent getPreferredFocusedComponent() { + return functionNameField.getFocusableComponent(); + } + + @Override + protected JComponent createCenterPanel() { + return contentPane; + } + + @Override + protected @NotNull JComponent createContentPane() { + return contentPane; + } + + public static ExtractableCodeDescriptor createNewDescriptor( + @NotNull ExtractableCodeDescriptor originalDescriptor, + @NotNull String newName, + @Nullable KtModifierKeywordToken newVisibility, + @Nullable FirExtractFunctionParameterTablePanel.ParameterInfo newReceiverInfo, + @NotNull List newParameterInfos, + @Nullable KaType returnType + ) { + Map oldToNewParameters = new LinkedHashMap<>(); + for (FirExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) { + oldToNewParameters.put(parameterInfo.getOriginalParameter(), parameterInfo.toParameter()); } + Parameter originalReceiver = originalDescriptor.getReceiverParameter(); + Parameter newReceiver = newReceiverInfo != null ? newReceiverInfo.toParameter() : null; + if (originalReceiver != null && newReceiver != null) { + oldToNewParameters.put(originalReceiver, newReceiver); + } + + ExtractionData data = originalDescriptor.getExtractionData(); + var newReplacementMap = MultiMap.>create(); + originalDescriptor.getReplacementMap() + .entrySet() + .forEach(entry -> { + List> newReplacement = ContainerUtil.map(entry.getValue(), p -> { + if (p instanceof ParameterReplacement r) { + Parameter newParameter = oldToNewParameters.get(r.getParameter()); + return newParameter != null ? r.copy(newParameter) : p; + } + else { + return p; + } + }); + newReplacementMap.putValues(entry.getKey(), newReplacement); + }); + return new ExtractableCodeDescriptor(originalDescriptor.getContext(), + data, + List.of(newName), + newVisibility, + oldToNewParameters.values().stream().filter(p -> p != newReceiver).toList(), + newReceiver, + originalDescriptor.getTypeParameters(), + newReplacementMap, + originalDescriptor.getControlFlow(), + returnType, + originalDescriptor.getModifiers(), + originalDescriptor.getOptInMarkers(), + originalDescriptor.getRenderedAnnotations()); + } } diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java index e7d1a4fe56d6..fcf94c9919d6 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java +++ b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java @@ -7,7 +7,11 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.psi.PsiElement; import com.intellij.refactoring.ui.NameSuggestionsField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TitledSeparator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.MultiMap; import kotlin.Unit; import kotlin.jvm.functions.Function0; @@ -24,6 +28,7 @@ import org.jetbrains.kotlin.lexer.KtModifierKeywordToken; import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; @@ -31,207 +36,338 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; import static org.jetbrains.kotlin.idea.refactoring.KotlinCommonRefactoringUtilKt.checkConflictsInteractively; public class KotlinIntroduceTypeAliasDialog extends DialogWrapper { - private JPanel contentPane; - private TitledSeparator inputParametersPanel; - private JComboBox visibilityBox; - private KotlinSignatureComponent signaturePreviewField; - private JPanel aliasNamePanel; - private NameSuggestionsField aliasNameField; - private JLabel aliasNameLabel; - private IntroduceTypeAliasParameterTablePanel parameterTablePanel; + private final JPanel contentPane; + private final TitledSeparator inputParametersPanel; + private final JComboBox visibilityBox; + private final KotlinSignatureComponent signaturePreviewField; + private final JPanel aliasNamePanel; + private NameSuggestionsField aliasNameField; + private final JLabel aliasNameLabel; + private IntroduceTypeAliasParameterTablePanel parameterTablePanel; - private final Project project; + private final Project project; - private final IntroduceTypeAliasDescriptor originalDescriptor; - private IntroduceTypeAliasDescriptor currentDescriptor; + private final IntroduceTypeAliasDescriptor originalDescriptor; + private IntroduceTypeAliasDescriptor currentDescriptor; - private final Function1 onAccept; + private final Function1 onAccept; - public KotlinIntroduceTypeAliasDialog( - @NotNull Project project, - @NotNull IntroduceTypeAliasDescriptor originalDescriptor, - @NotNull Function1 onAccept) { - super(project, true); + public KotlinIntroduceTypeAliasDialog( + @NotNull Project project, + @NotNull IntroduceTypeAliasDescriptor originalDescriptor, + @NotNull Function1 onAccept) { + super(project, true); - this.project = project; - this.originalDescriptor = originalDescriptor; - this.currentDescriptor = originalDescriptor; - this.onAccept = onAccept; - - setModal(true); - setTitle(KotlinIntroduceTypeAliasHandler.getREFACTORING_NAME()); - init(); - update(); + this.project = project; + this.originalDescriptor = originalDescriptor; + this.currentDescriptor = originalDescriptor; + this.onAccept = onAccept; + { + this.signaturePreviewField = new KotlinSignatureComponent("", project); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + inputParametersPanel = new TitledSeparator(); + inputParametersPanel.setLayout(new BorderLayout(0, 0)); + inputParametersPanel.setText(""); + inputParametersPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel2.add(inputParametersPanel, BorderLayout.CENTER); + inputParametersPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/KotlinBundle", "title.parameters"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 200), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/KotlinBundle", + "signature.preview"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + signaturePreviewField.setText(""); + panel4.add(signaturePreviewField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(500, 100), new Dimension(500, 100), null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel5.setEnabled(true); + panel5.setVisible(true); + contentPane.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + aliasNameLabel = new JLabel(); + this.$$$loadLabelText$$$(aliasNameLabel, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "name")); + panel5.add(aliasNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/KotlinBundle", "visibility")); + label1.setVisible(true); + panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(114, 16), null, 0, false)); + aliasNamePanel = new JPanel(); + aliasNamePanel.setLayout(new BorderLayout(0, 0)); + panel5.add(aliasNamePanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + visibilityBox = new JComboBox(); + visibilityBox.setVisible(true); + panel5.add(visibilityBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(114, 26), null, 0, false)); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(visibilityBox); } - private void createUIComponents() { - this.signaturePreviewField = new KotlinSignatureComponent("", project); - } + setModal(true); + setTitle(KotlinIntroduceTypeAliasHandler.getREFACTORING_NAME()); + init(); + update(); + } - private boolean isVisibilitySectionAvailable() { - return !getApplicableVisibilities().isEmpty(); - } + private static Method $$$cachedGetBundleMethod$$$ = null; - private @NotNull List getApplicableVisibilities() { - return IntroduceTypeAliasImplKt.getApplicableVisibilities(originalDescriptor.getOriginalData()); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - private String getAliasName() { - return KtPsiUtilKt.quoteIfNeeded(aliasNameField.getEnteredName()); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - private @Nullable KtModifierKeywordToken getVisibility() { - if (!isVisibilitySectionAvailable()) return null; - return (KtModifierKeywordToken) visibilityBox.getSelectedItem(); - } - - private boolean checkNames() { - if (!KtPsiUtilKt.isIdentifier(getAliasName())) return false; - if (parameterTablePanel != null) { - for (IntroduceTypeAliasParameterTablePanel.TypeParameterInfo parameterInfo : parameterTablePanel.getSelectedTypeParameterInfos()) { - if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; - } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - return true; + } + result.append(text.charAt(i)); } - - private void update() { - this.currentDescriptor = createDescriptor(); - - setOKActionEnabled(checkNames()); - signaturePreviewField.setText(IntroduceTypeAliasImplKt.generateTypeAlias(currentDescriptor, true).getText()); + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - @Override - protected void init() { - super.init(); + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } - visibilityBox.setModel(new DefaultComboBoxModel<>(getApplicableVisibilities().toArray(new KtModifierKeywordToken[0]))); - visibilityBox.setRenderer( - new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus - ) { - @NlsSafe String tokenValue = value != null ? ((KtModifierKeywordToken) value).getValue() : null; - return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus); - } - } - ); + private boolean isVisibilitySectionAvailable() { + return !getApplicableVisibilities().isEmpty(); + } - aliasNameField = new NameSuggestionsField(new String[]{originalDescriptor.getName()}, project, KotlinFileType.INSTANCE); - aliasNameField.addDataChangedListener(() -> update()); - aliasNamePanel.add(aliasNameField, BorderLayout.CENTER); - aliasNameLabel.setLabelFor(aliasNameField); + private @NotNull List getApplicableVisibilities() { + return IntroduceTypeAliasImplKt.getApplicableVisibilities(originalDescriptor.getOriginalData()); + } - boolean enableVisibility = isVisibilitySectionAvailable(); - visibilityBox.setEnabled(enableVisibility); - if (enableVisibility) { - KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility(); - if (defaultVisibility == null) { - defaultVisibility = KtTokens.PUBLIC_KEYWORD; - } - visibilityBox.setSelectedItem(defaultVisibility); + private String getAliasName() { + return KtPsiUtilKt.quoteIfNeeded(aliasNameField.getEnteredName()); + } + + private @Nullable KtModifierKeywordToken getVisibility() { + if (!isVisibilitySectionAvailable()) return null; + return (KtModifierKeywordToken)visibilityBox.getSelectedItem(); + } + + private boolean checkNames() { + if (!KtPsiUtilKt.isIdentifier(getAliasName())) return false; + if (parameterTablePanel != null) { + for (IntroduceTypeAliasParameterTablePanel.TypeParameterInfo parameterInfo : parameterTablePanel.getSelectedTypeParameterInfos()) { + if (!KtPsiUtilKt.isIdentifier(parameterInfo.getName())) return false; + } + } + return true; + } + + private void update() { + this.currentDescriptor = createDescriptor(); + + setOKActionEnabled(checkNames()); + signaturePreviewField.setText(IntroduceTypeAliasImplKt.generateTypeAlias(currentDescriptor, true).getText()); + } + + @Override + protected void init() { + super.init(); + + visibilityBox.setModel(new DefaultComboBoxModel<>(getApplicableVisibilities().toArray(new KtModifierKeywordToken[0]))); + visibilityBox.setRenderer( + new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + @NlsSafe String tokenValue = value != null ? ((KtModifierKeywordToken)value).getValue() : null; + return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus); } - visibilityBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - update(); - } - } - ); + } + ); - if (!originalDescriptor.getTypeParameters().isEmpty()) { - parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() { - @Override - protected void updateSignature() { - KotlinIntroduceTypeAliasDialog.this.update(); - } + aliasNameField = new NameSuggestionsField(new String[]{originalDescriptor.getName()}, project, KotlinFileType.INSTANCE); + aliasNameField.addDataChangedListener(() -> update()); + aliasNamePanel.add(aliasNameField, BorderLayout.CENTER); + aliasNameLabel.setLabelFor(aliasNameField); - @Override - protected void onEnterAction() { - doOKAction(); - } - - @Override - protected void onCancelAction() { - doCancelAction(); - } - }; - parameterTablePanel.init(originalDescriptor.getTypeParameters()); - - inputParametersPanel.setText(KotlinBundle.message("text.type.parameters")); - inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); - inputParametersPanel.add(parameterTablePanel); + boolean enableVisibility = isVisibilitySectionAvailable(); + visibilityBox.setEnabled(enableVisibility); + if (enableVisibility) { + KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility(); + if (defaultVisibility == null) { + defaultVisibility = KtTokens.PUBLIC_KEYWORD; + } + visibilityBox.setSelectedItem(defaultVisibility); + } + visibilityBox.addItemListener( + new ItemListener() { + @Override + public void itemStateChanged(@NotNull ItemEvent e) { + update(); } - else { - inputParametersPanel.setVisible(false); + } + ); + + if (!originalDescriptor.getTypeParameters().isEmpty()) { + parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() { + @Override + protected void updateSignature() { + KotlinIntroduceTypeAliasDialog.this.update(); } - } - @Override - protected void doOKAction() { - MultiMap conflicts = IntroduceTypeAliasImplKt.validate(currentDescriptor).getConflicts(); - checkConflictsInteractively( - project, - conflicts, - new Function0<>() { - @Override - public Unit invoke() { - close(OK_EXIT_CODE); - return Unit.INSTANCE; - } - }, - new Function0<>() { - @Override - public Unit invoke() { - KotlinIntroduceTypeAliasDialog.super.doOKAction(); - return onAccept.invoke(KotlinIntroduceTypeAliasDialog.this); - } - } - ); - } + @Override + protected void onEnterAction() { + doOKAction(); + } - @Override - public JComponent getPreferredFocusedComponent() { - return aliasNameField; - } + @Override + protected void onCancelAction() { + doCancelAction(); + } + }; + parameterTablePanel.init(originalDescriptor.getTypeParameters()); - @Override - protected JComponent createCenterPanel() { - return contentPane; + inputParametersPanel.setText(KotlinBundle.message("text.type.parameters")); + inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); + inputParametersPanel.add(parameterTablePanel); } + else { + inputParametersPanel.setVisible(false); + } + } - @Override - protected @NotNull JComponent createContentPane() { - return contentPane; - } + @Override + protected void doOKAction() { + MultiMap conflicts = IntroduceTypeAliasImplKt.validate(currentDescriptor).getConflicts(); + checkConflictsInteractively( + project, + conflicts, + new Function0<>() { + @Override + public Unit invoke() { + close(OK_EXIT_CODE); + return Unit.INSTANCE; + } + }, + new Function0<>() { + @Override + public Unit invoke() { + KotlinIntroduceTypeAliasDialog.super.doOKAction(); + return onAccept.invoke(KotlinIntroduceTypeAliasDialog.this); + } + } + ); + } - private @NotNull IntroduceTypeAliasDescriptor createDescriptor() { - return originalDescriptor.copy( - originalDescriptor.getOriginalData(), - getAliasName(), - getVisibility(), - parameterTablePanel != null ? parameterTablePanel.getSelectedTypeParameters() : Collections.emptyList() - ); - } + @Override + public JComponent getPreferredFocusedComponent() { + return aliasNameField; + } - public IntroduceTypeAliasDescriptor getCurrentDescriptor() { - return currentDescriptor; - } + @Override + protected JComponent createCenterPanel() { + return contentPane; + } + + @Override + protected @NotNull JComponent createContentPane() { + return contentPane; + } + + private @NotNull IntroduceTypeAliasDescriptor createDescriptor() { + return originalDescriptor.copy( + originalDescriptor.getOriginalData(), + getAliasName(), + getVisibility(), + parameterTablePanel != null ? parameterTablePanel.getSelectedTypeParameters() : Collections.emptyList() + ); + } + + public IntroduceTypeAliasDescriptor getCurrentDescriptor() { + return currentDescriptor; + } } diff --git a/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java b/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java index bbdfbe000dfb..50b0999cfac0 100644 --- a/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java +++ b/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java @@ -28,130 +28,207 @@ import com.intellij.psi.JavaCodeFragment; import com.intellij.psi.PsiClass; import com.intellij.psi.util.PsiMethodUtil; import com.intellij.ui.PanelWithAnchor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.asJava.classes.KtLightClass; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class KotlinRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { - private JPanel mainPanel; - private LabeledComponent mainClassEditorField; + private final JPanel mainPanel; + private final LabeledComponent mainClassEditorField; - private CommonJavaParametersPanel commonProgramParameters; - private LabeledComponentNoThrow moduleChooser; - private JrePathEditor jrePathEditor; - private LabeledComponent shortenClasspathModeCombo; + private final CommonJavaParametersPanel commonProgramParameters; + private final LabeledComponentNoThrow moduleChooser; + private final JrePathEditor jrePathEditor; + private final LabeledComponent shortenClasspathModeCombo; - private JComponent anchor; + private JComponent anchor; - private final ConfigurationModuleSelector moduleSelector; - private final Project project; + private final ConfigurationModuleSelector moduleSelector; + private final Project project; - private ClassBrowser createApplicationClassBrowser( - Project project, - Computable moduleSelector - ) { - ClassFilter applicationClass = - aClass -> aClass instanceof KtLightClass && - ConfigurationUtil.MAIN_CLASS.value(aClass) && - ReadAction.compute(() -> PsiMethodUtil.findMainMethod(aClass)) != null; - return new ClassBrowser.MainClassBrowser<>(project, moduleSelector, ExecutionBundle.message("choose.main.class.dialog.title")) { - @Override - protected ClassFilter createFilter(Module module) { - return applicationClass; - } + private ClassBrowser createApplicationClassBrowser( + Project project, + Computable moduleSelector + ) { + ClassFilter applicationClass = + aClass -> aClass instanceof KtLightClass && + ConfigurationUtil.MAIN_CLASS.value(aClass) && + ReadAction.compute(() -> PsiMethodUtil.findMainMethod(aClass)) != null; + return new ClassBrowser.MainClassBrowser<>(project, moduleSelector, ExecutionBundle.message("choose.main.class.dialog.title")) { + @Override + protected ClassFilter createFilter(Module module) { + return applicationClass; + } - @Override - protected void onClassChosen(@NotNull PsiClass psiClass) { - Module module = ModuleUtilCore.findModuleForPsiElement(psiClass); - if (module != null && ModuleTypeManager.getInstance().isClasspathProvider(ModuleType.get(module))) { - moduleChooser.getComponent().setSelectedModule(module); - } - } - - @Override - protected TreeClassChooser createClassChooser(ClassFilter.ClassFilterWithScope classFilter) { - Project project = getProject(); - return new TreeJavaClassChooserDialog(myTitle, project, classFilter.getScope(), classFilter, null, null, true); - } - }; - } - - public KotlinRunConfigurationEditor(Project project) { - this.project = project; - moduleSelector = new ConfigurationModuleSelector(project, moduleChooser.getComponent()); - jrePathEditor.setDefaultJreSelector(DefaultJreSelector.fromModuleDependencies(moduleChooser.getComponent(), false)); - commonProgramParameters.setModuleContext(moduleSelector.getModule()); - moduleChooser.getComponent().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - commonProgramParameters.setModuleContext(moduleSelector.getModule()); - } - }); - anchor = UIUtil.mergeComponentsWithAnchor(mainClassEditorField, commonProgramParameters, jrePathEditor, jrePathEditor, moduleChooser, - shortenClasspathModeCombo); - shortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(project, jrePathEditor, moduleChooser.getComponent())); - } - - @Override - protected void applyEditorTo(@NotNull KotlinRunConfiguration configuration) { - commonProgramParameters.applyTo(configuration); - moduleSelector.applyTo(configuration); - - configuration.setMainClassName(mainClassEditorField.getComponent().getText()); - configuration.setAlternativeJrePath(jrePathEditor.getJrePathOrName()); - configuration.setAlternativeJrePathEnabled(jrePathEditor.isAlternativeJreSelected()); - configuration.setShortenCommandLine(shortenClasspathModeCombo.getComponent().getSelectedItem()); - } - - @Override - protected void resetEditorFrom(@NotNull KotlinRunConfiguration configuration) { - commonProgramParameters.reset(configuration); - moduleSelector.reset(configuration); - String mainClassName = configuration.getMainClassName(); - mainClassEditorField.getComponent().setText(mainClassName != null ? mainClassName.replaceAll("\\$", ".") : ""); - jrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled()); - shortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine()); - } - - @Override - protected @NotNull JComponent createEditor() { - return mainPanel; - } - - private void createUIComponents() { - mainClassEditorField = new LabeledComponent<>(); - mainClassEditorField.setComponent(ClassEditorField.createClassField(project, () -> moduleSelector.getModule(), VISIBILITY_CHECKER, - createApplicationClassBrowser(project, () -> moduleSelector.getModule()))); - } - - @Override - public JComponent getAnchor() { - return anchor; - } - - @Override - public void setAnchor(JComponent anchor) { - this.anchor = anchor; - mainClassEditorField.setAnchor(anchor); - commonProgramParameters.setAnchor(anchor); - jrePathEditor.setAnchor(anchor); - moduleChooser.setAnchor(anchor); - shortenClasspathModeCombo.setAnchor(anchor); - } - - public static final JavaCodeFragment.VisibilityChecker VISIBILITY_CHECKER = (declaration, place) -> { - if (declaration instanceof KtLightClass aClass) { - if (ConfigurationUtil.MAIN_CLASS.value(aClass) - && (PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null) - && ModuleUtilCore.findModuleForPsiElement(declaration) != null) { - return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE; - } + @Override + protected void onClassChosen(@NotNull PsiClass psiClass) { + Module module = ModuleUtilCore.findModuleForPsiElement(psiClass); + if (module != null && ModuleTypeManager.getInstance().isClasspathProvider(ModuleType.get(module))) { + moduleChooser.getComponent().setSelectedModule(module); } - return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE; + } + + @Override + protected TreeClassChooser createClassChooser(ClassFilter.ClassFilterWithScope classFilter) { + Project project = getProject(); + return new TreeJavaClassChooserDialog(myTitle, project, classFilter.getScope(), classFilter, null, null, true); + } }; + } + + public KotlinRunConfigurationEditor(Project project) { + this.project = project; + { + mainClassEditorField = new LabeledComponent<>(); + mainClassEditorField.setComponent(ClassEditorField.createClassField(project, () -> moduleSelector.getModule(), VISIBILITY_CHECKER, + createApplicationClassBrowser(project, + () -> moduleSelector.getModule()))); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainClassEditorField.setLabelLocation("West"); + mainClassEditorField.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.main.class.label")); + mainPanel.add(mainClassEditorField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(-1, 20), null, 0, false)); + commonProgramParameters = new CommonJavaParametersPanel(); + mainPanel.add(commonProgramParameters, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + moduleChooser = new LabeledComponentNoThrow(); + moduleChooser.setComponentClass("com.intellij.application.options.ModuleDescriptionsComboBox"); + moduleChooser.setLabelLocation("West"); + moduleChooser.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.use.classpath.and.jdk.of.module.label")); + mainPanel.add(moduleChooser, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + jrePathEditor = new JrePathEditor(); + mainPanel.add(jrePathEditor, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + mainPanel.add(spacer2, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + shortenClasspathModeCombo = new LabeledComponentNoThrow(); + shortenClasspathModeCombo.setEnabled(true); + shortenClasspathModeCombo.setLabelLocation("West"); + shortenClasspathModeCombo.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.shorten.command.line.label")); + mainPanel.add(shortenClasspathModeCombo, + new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + moduleSelector = new ConfigurationModuleSelector(project, moduleChooser.getComponent()); + jrePathEditor.setDefaultJreSelector(DefaultJreSelector.fromModuleDependencies(moduleChooser.getComponent(), false)); + commonProgramParameters.setModuleContext(moduleSelector.getModule()); + moduleChooser.getComponent().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + commonProgramParameters.setModuleContext(moduleSelector.getModule()); + } + }); + anchor = UIUtil.mergeComponentsWithAnchor(mainClassEditorField, commonProgramParameters, jrePathEditor, jrePathEditor, moduleChooser, + shortenClasspathModeCombo); + shortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(project, jrePathEditor, moduleChooser.getComponent())); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } + + @Override + protected void applyEditorTo(@NotNull KotlinRunConfiguration configuration) { + commonProgramParameters.applyTo(configuration); + moduleSelector.applyTo(configuration); + + configuration.setMainClassName(mainClassEditorField.getComponent().getText()); + configuration.setAlternativeJrePath(jrePathEditor.getJrePathOrName()); + configuration.setAlternativeJrePathEnabled(jrePathEditor.isAlternativeJreSelected()); + configuration.setShortenCommandLine(shortenClasspathModeCombo.getComponent().getSelectedItem()); + } + + @Override + protected void resetEditorFrom(@NotNull KotlinRunConfiguration configuration) { + commonProgramParameters.reset(configuration); + moduleSelector.reset(configuration); + String mainClassName = configuration.getMainClassName(); + mainClassEditorField.getComponent().setText(mainClassName != null ? mainClassName.replaceAll("\\$", ".") : ""); + jrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled()); + shortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine()); + } + + @Override + protected @NotNull JComponent createEditor() { + return mainPanel; + } + + @Override + public JComponent getAnchor() { + return anchor; + } + + @Override + public void setAnchor(JComponent anchor) { + this.anchor = anchor; + mainClassEditorField.setAnchor(anchor); + commonProgramParameters.setAnchor(anchor); + jrePathEditor.setAnchor(anchor); + moduleChooser.setAnchor(anchor); + shortenClasspathModeCombo.setAnchor(anchor); + } + + public static final JavaCodeFragment.VisibilityChecker VISIBILITY_CHECKER = (declaration, place) -> { + if (declaration instanceof KtLightClass aClass) { + if (ConfigurationUtil.MAIN_CLASS.value(aClass) + && (PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null) + && ModuleUtilCore.findModuleForPsiElement(declaration) != null) { + return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE; + } + } + return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE; + }; } diff --git a/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/runConfigurations/jvm/script/KotlinStandaloneScriptRunConfigurationEditor.java b/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/runConfigurations/jvm/script/KotlinStandaloneScriptRunConfigurationEditor.java index 27cd6ce1edd1..53c4a31c7c30 100644 --- a/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/runConfigurations/jvm/script/KotlinStandaloneScriptRunConfigurationEditor.java +++ b/plugins/kotlin/run-configurations/jvm/src/org/jetbrains/kotlin/idea/runConfigurations/jvm/script/KotlinStandaloneScriptRunConfigurationEditor.java @@ -13,6 +13,9 @@ import com.intellij.openapi.ui.LabeledComponentNoThrow; import com.intellij.openapi.ui.TextComponentAccessor; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.ui.PanelWithAnchor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.KotlinRunConfigurationsBundle; @@ -20,70 +23,134 @@ import org.jetbrains.kotlin.parsing.KotlinParserDefinition; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; -public class KotlinStandaloneScriptRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { - private JPanel mainPanel; - private CommonJavaParametersPanel commonProgramParameters; - private JrePathEditor jrePathEditor; - private TextFieldWithBrowseButton chooseScriptFileTextField; - private LabeledComponentNoThrow chooseScriptFileComponent; - private LabeledComponentNoThrow shortenClasspathModeCombo; - private JComponent anchor; +public class KotlinStandaloneScriptRunConfigurationEditor extends SettingsEditor + implements PanelWithAnchor { + private final JPanel mainPanel; + private final CommonJavaParametersPanel commonProgramParameters; + private final JrePathEditor jrePathEditor; + private TextFieldWithBrowseButton chooseScriptFileTextField; + private final LabeledComponentNoThrow chooseScriptFileComponent; + private final LabeledComponentNoThrow shortenClasspathModeCombo; + private JComponent anchor; - public KotlinStandaloneScriptRunConfigurationEditor(Project project) { - initChooseFileField(project); - jrePathEditor.setDefaultJreSelector(DefaultJreSelector.projectSdk(project)); - anchor = UIUtil.mergeComponentsWithAnchor(chooseScriptFileComponent, commonProgramParameters, jrePathEditor, shortenClasspathModeCombo); - shortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(project, jrePathEditor, () -> null, listener -> {})); + public KotlinStandaloneScriptRunConfigurationEditor(Project project) { + { + chooseScriptFileComponent = new LabeledComponentNoThrow<>(); + chooseScriptFileTextField = new TextFieldWithBrowseButton(); + chooseScriptFileComponent.setComponent(chooseScriptFileTextField); } - - void initChooseFileField(Project project) { - var descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(KotlinParserDefinition.STD_SCRIPT_SUFFIX) - .withTitle(KotlinRunConfigurationsBundle.message("script.choose.file")) - .withTreeRootVisible(true); - chooseScriptFileTextField.addBrowseFolderListener(project, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + mainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + commonProgramParameters = new CommonJavaParametersPanel(); + mainPanel.add(commonProgramParameters, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + jrePathEditor = new JrePathEditor(); + mainPanel.add(jrePathEditor, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + chooseScriptFileComponent.setLabelLocation("West"); + chooseScriptFileComponent.setText( + this.$$$getMessageFromBundle$$$("messages/KotlinRunConfigurationsBundle", "configuration.title.script.file")); + mainPanel.add(chooseScriptFileComponent, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + shortenClasspathModeCombo = new LabeledComponentNoThrow(); + shortenClasspathModeCombo.setEnabled(true); + shortenClasspathModeCombo.setLabelLocation("West"); + shortenClasspathModeCombo.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.shorten.command.line.label")); + mainPanel.add(shortenClasspathModeCombo, + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } + initChooseFileField(project); + jrePathEditor.setDefaultJreSelector(DefaultJreSelector.projectSdk(project)); + anchor = UIUtil.mergeComponentsWithAnchor(chooseScriptFileComponent, commonProgramParameters, jrePathEditor, shortenClasspathModeCombo); + shortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(project, jrePathEditor, () -> null, listener -> { + })); + } - @Override - protected void resetEditorFrom(@NotNull KotlinStandaloneScriptRunConfiguration configuration) { - commonProgramParameters.reset(configuration); - String path = configuration.filePath; - chooseScriptFileTextField.setText(path != null ? path : ""); - jrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled()); - shortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine()); - } + private static Method $$$cachedGetBundleMethod$$$ = null; - @Override - protected void applyEditorTo(@NotNull KotlinStandaloneScriptRunConfiguration configuration) { - commonProgramParameters.applyTo(configuration); - configuration.setAlternativeJrePath(jrePathEditor.getJrePathOrName()); - configuration.setAlternativeJrePathEnabled(jrePathEditor.isAlternativeJreSelected()); - configuration.filePath = chooseScriptFileTextField.getText(); - configuration.setShortenCommandLine(shortenClasspathModeCombo.getComponent().getSelectedItem()); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } - @Override - protected @NotNull JComponent createEditor() { - return mainPanel; - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return mainPanel; } - @Override - public JComponent getAnchor() { - return anchor; - } + void initChooseFileField(Project project) { + var descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(KotlinParserDefinition.STD_SCRIPT_SUFFIX) + .withTitle(KotlinRunConfigurationsBundle.message("script.choose.file")) + .withTreeRootVisible(true); + chooseScriptFileTextField.addBrowseFolderListener(project, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); + } - @Override - public void setAnchor(JComponent anchor) { - this.anchor = anchor; - commonProgramParameters.setAnchor(anchor); - jrePathEditor.setAnchor(anchor); - chooseScriptFileComponent.setAnchor(anchor); - shortenClasspathModeCombo.setAnchor(anchor); - } + @Override + protected void resetEditorFrom(@NotNull KotlinStandaloneScriptRunConfiguration configuration) { + commonProgramParameters.reset(configuration); + String path = configuration.filePath; + chooseScriptFileTextField.setText(path != null ? path : ""); + jrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled()); + shortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine()); + } - private void createUIComponents() { - chooseScriptFileComponent = new LabeledComponentNoThrow<>(); - chooseScriptFileTextField = new TextFieldWithBrowseButton(); - chooseScriptFileComponent.setComponent(chooseScriptFileTextField); - } + @Override + protected void applyEditorTo(@NotNull KotlinStandaloneScriptRunConfiguration configuration) { + commonProgramParameters.applyTo(configuration); + configuration.setAlternativeJrePath(jrePathEditor.getJrePathOrName()); + configuration.setAlternativeJrePathEnabled(jrePathEditor.isAlternativeJreSelected()); + configuration.filePath = chooseScriptFileTextField.getText(); + configuration.setShortenCommandLine(shortenClasspathModeCombo.getComponent().getSelectedItem()); + } + + @Override + protected @NotNull JComponent createEditor() { + return mainPanel; + } + + @Override + public JComponent getAnchor() { + return anchor; + } + + @Override + public void setAnchor(JComponent anchor) { + this.anchor = anchor; + commonProgramParameters.setAnchor(anchor); + jrePathEditor.setAnchor(anchor); + chooseScriptFileComponent.setAnchor(anchor); + shortenClasspathModeCombo.setAnchor(anchor); + } } diff --git a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java index f122d7491ff3..ce8be2b571ae 100644 --- a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java +++ b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java @@ -3,28 +3,104 @@ package de.plushnikov.intellij.plugin.settings; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import de.plushnikov.intellij.plugin.LombokBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import static de.plushnikov.intellij.plugin.settings.ProjectSettings.isEnabled; import static de.plushnikov.intellij.plugin.settings.ProjectSettings.setEnabled; public final class ProjectSettingsPage implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myGeneralPanel; + private final JPanel myGeneralPanel; - private JCheckBox myEnableJSPFix; + private final JCheckBox myEnableJSPFix; private final Project myProject; public ProjectSettingsPage(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myGeneralPanel = new JPanel(); + myGeneralPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myGeneralPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myGeneralPanel.setBorder( + IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, "General Settings", TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); //NON-NLS + myEnableJSPFix = new JCheckBox(); + this.$$$loadButtonText$$$(myEnableJSPFix, this.$$$getMessageFromBundle$$$("messages/LombokBundle", "checkbox.settings.jps.fix")); + myGeneralPanel.add(myEnableJSPFix, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myGeneralPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myGeneralPanel; } + @Override public @Nls String getDisplayName() { return LombokBundle.message("plugin.settings.title"); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/SelectMavenProjectDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/SelectMavenProjectDialog.java index 7771d9beb90d..bd5c469eaf37 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/SelectMavenProjectDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/SelectMavenProjectDialog.java @@ -5,6 +5,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Pair; import com.intellij.refactoring.RefactoringBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,24 +17,29 @@ import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel; import org.jetbrains.idea.maven.utils.ComboBoxUtil; +import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import java.util.Set; public class SelectMavenProjectDialog extends DialogWrapper { private final Set myMavenDomProjectModels; private final boolean myHasExclusions; - private JComboBox myMavenProjectsComboBox; - private JPanel myMainPanel; - private JCheckBox myReplaceAllCheckBox; - private JCheckBox myExtractExclusions; + private final JComboBox myMavenProjectsComboBox; + private final JPanel myMainPanel; + private final JCheckBox myReplaceAllCheckBox; + private final JCheckBox myExtractExclusions; private boolean myHasUsagesInProjects = false; private ItemListener myReplaceAllListener; @@ -44,6 +52,36 @@ public class SelectMavenProjectDialog extends DialogWrapper { super(project, true); myMavenDomProjectModels = mavenDomProjectModels; myHasExclusions = hasExclusions; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.introduce.project")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myMavenProjectsComboBox = new JComboBox(); + myMainPanel.add(myMavenProjectsComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myReplaceAllCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myReplaceAllCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.replace.all")); + myMainPanel.add(myReplaceAllCheckBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myExtractExclusions = new JCheckBox(); + this.$$$loadButtonText$$$(myExtractExclusions, + this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.extract.exclusions")); + myMainPanel.add(myExtractExclusions, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } setTitle(MavenDomBundle.message("choose.project")); @@ -58,6 +96,78 @@ public class SelectMavenProjectDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected Action @NotNull [] createActions() { return new Action[]{getOKAction(), getCancelAction()}; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyDialog.java index eda4ae780ab1..1c285c445586 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyDialog.java @@ -11,6 +11,9 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlTag; import com.intellij.refactoring.ui.NameSuggestionsField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.intellij.util.StringLenComparator; import com.intellij.util.xml.DomElement; @@ -29,12 +32,16 @@ import javax.swing.Action; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; public class IntroducePropertyDialog extends DialogWrapper { @@ -46,9 +53,9 @@ public class IntroducePropertyDialog extends DialogWrapper { private NameSuggestionsField myNameField; private NameSuggestionsField.DataChanged myNameChangedListener; - private JComboBox myMavenProjectsComboBox; - private JPanel myMainPanel; - private JPanel myFieldNamePanel; + private final JComboBox myMavenProjectsComboBox; + private final JPanel myMainPanel; + private final JPanel myFieldNamePanel; public IntroducePropertyDialog(@NotNull Project project, @NotNull XmlElement context, @@ -60,11 +67,88 @@ public class IntroducePropertyDialog extends DialogWrapper { myMavenDomProjectModel = mavenDomProjectModel; mySelectedString = selectedString; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.introduce.project")); + myMainPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.introduce.name")); + myMainPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFieldNamePanel = new JPanel(); + myFieldNamePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myFieldNamePanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myMavenProjectsComboBox = new JComboBox(); + myMainPanel.add(myMavenProjectsComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } setTitle(MavenDomBundle.message("refactoring.introduce.property")); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected void dispose() { myNameField.removeDataChangedListener(myNameChangedListener); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/EditMavenPropertyDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/EditMavenPropertyDialog.java index 2f21799b8641..768a4c865e74 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/EditMavenPropertyDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/EditMavenPropertyDialog.java @@ -3,6 +3,8 @@ package org.jetbrains.idea.maven.execution; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Pair; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.dom.MavenDomBundle; @@ -10,23 +12,54 @@ import org.jetbrains.idea.maven.dom.MavenDomBundle; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Map; +import java.util.ResourceBundle; public class EditMavenPropertyDialog extends DialogWrapper { - private JPanel contentPane; - private JComboBox myNameBox; - private JTextField myValueField; + private final JPanel contentPane; + private final JComboBox myNameBox; + private final JTextField myValueField; private final Map myAvailableProperties; public EditMavenPropertyDialog(@Nullable Pair value, Map availableProperties) { super(false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myNameBox = new JComboBox(); + myNameBox.setEditable(true); + contentPane.add(myNameBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myValueField = new JTextField(); + contentPane.add(myValueField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.introduce.name")); + contentPane.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/MavenDomBundle", "property.introduce.value")); + contentPane.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } setTitle(MavenDomBundle.message(value == null ? "property.title.add" : "property.title.edit")); myAvailableProperties = availableProperties; @@ -45,6 +78,53 @@ public class EditMavenPropertyDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + private void installFocusListeners() { myNameBox.addFocusListener(new FocusAdapter() { @Override diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java index 8d25c5e87f0e..7b954bf51f30 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java @@ -14,6 +14,8 @@ import com.intellij.ui.EditorComboBoxEditor; import com.intellij.ui.EditorComboBoxRenderer; import com.intellij.ui.EditorTextField; import com.intellij.ui.StringComboboxEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,20 +26,25 @@ import org.jetbrains.idea.maven.tasks.TasksBundle; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; public class MavenEditGoalDialog extends DialogWrapper { private final Project myProject; private final @Nullable Collection myHistory; - private JPanel contentPane; + private final JPanel contentPane; - private FixedSizeButton showProjectTreeButton; - private TextFieldWithBrowseButton workDirectoryField; + private final FixedSizeButton showProjectTreeButton; + private final TextFieldWithBrowseButton workDirectoryField; - private JPanel goalsPanel; - private JLabel goalsLabel; + private final JPanel goalsPanel; + private final JLabel goalsLabel; private ComboBox goalsComboBox; private EditorTextField goalsEditor; @@ -50,6 +57,47 @@ public class MavenEditGoalDialog extends DialogWrapper { super(project, true); myProject = project; myHistory = history; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new BorderLayout(10, 10)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, BorderLayout.NORTH); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.working.directory")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + goalsLabel = new JLabel(); + this.$$$loadLabelText$$$(goalsLabel, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.command.line")); + panel1.add(goalsLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + showProjectTreeButton = new FixedSizeButton(); + showProjectTreeButton.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.edit.goal.select.maven.project")); + panel2.add(showProjectTreeButton, BorderLayout.EAST); + workDirectoryField = new TextFieldWithBrowseButton(); + panel2.add(workDirectoryField, BorderLayout.CENTER); + goalsPanel = new JPanel(); + goalsPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(goalsPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(600, -1), null, 0, false)); + label1.setLabelFor(workDirectoryField); + } setTitle(TasksBundle.message("maven.tasks.goal.edit")); setUpDialog(); @@ -57,6 +105,53 @@ public class MavenEditGoalDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + private void setUpDialog() { JComponent goalComponent; if (myHistory == null) { @@ -94,7 +189,8 @@ public class MavenEditGoalDialog extends DialogWrapper { MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton, goalsComboBox != null ? goalsComboBox : goalsEditor); - workDirectoryField.addBrowseFolderListener(myProject, new MavenPomFileChooserDescriptor(myProject).withTitle(RunnerBundle.message("maven.select.working.directory"))); + workDirectoryField.addBrowseFolderListener(myProject, new MavenPomFileChooserDescriptor(myProject).withTitle( + RunnerBundle.message("maven.select.working.directory"))); } @Override @@ -144,5 +240,4 @@ public class MavenEditGoalDialog extends DialogWrapper { public JComponent getPreferredFocusedComponent() { return goalsComboBox; } - } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/EditMavenIndexDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/EditMavenIndexDialog.java index 8a7dd72d43ba..c98e0dbd3074 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/EditMavenIndexDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/EditMavenIndexDialog.java @@ -3,15 +3,23 @@ package org.jetbrains.idea.maven.indices; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.idea.maven.project.MavenConfigurableBundle; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class EditMavenIndexDialog extends DialogWrapper { - private JPanel myMainPanel; - private JTextField myUrlField; + private final JPanel myMainPanel; + private final JTextField myUrlField; public EditMavenIndexDialog() { this(""); @@ -19,11 +27,77 @@ public class EditMavenIndexDialog extends DialogWrapper { public EditMavenIndexDialog(String url) { super(false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myUrlField = new JTextField(); + myMainPanel.add(myUrlField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(250, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/MavenIndicesBundle", "maven.index.url")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } setTitle(MavenConfigurableBundle.message("maven.settings.index.edit.repository")); myUrlField.setText(url.isEmpty() ? "http://" : url); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected JComponent createCenterPanel() { return myMainPanel; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java index 8336e1db3884..3294302376ca 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java @@ -8,7 +8,11 @@ import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.AnimatedIcon; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.JBUI; @@ -17,6 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.maven.model.MavenRepositoryInfo; import org.jetbrains.idea.maven.project.MavenConfigurableBundle; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JPanel; @@ -29,19 +34,22 @@ import javax.swing.table.DefaultTableCellRenderer; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; public class MavenRepositoriesConfigurable implements SearchableConfigurable, Configurable.NoScroll { private final Project myProject; - private JPanel myMainPanel; - private JBTable myRepositoriesTable; - private JButton myUpdateButton; - private JPanel myBorderPanel; + private final JPanel myMainPanel; + private final JBTable myRepositoriesTable; + private final JButton myUpdateButton; + private final JPanel myBorderPanel; private AnimatedIcon myUpdatingIcon; private Timer myRepaintTimer; @@ -49,6 +57,45 @@ public class MavenRepositoriesConfigurable implements SearchableConfigurable, Co public MavenRepositoriesConfigurable(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myBorderPanel = new JPanel(); + myBorderPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myBorderPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myBorderPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, true)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myBorderPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myRepositoriesTable = new JBTable(); + myRepositoriesTable.setShowHorizontalLines(false); + myRepositoriesTable.setShowVerticalLines(false); + jBScrollPane1.setViewportView(myRepositoriesTable); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myBorderPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myUpdateButton = new JButton(); + myUpdateButton.setFocusable(false); + this.$$$loadButtonText$$$(myUpdateButton, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.repositories.update")); + panel1.add(myUpdateButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } configControls(); myBorderPanel.setBorder( @@ -56,6 +103,53 @@ public class MavenRepositoriesConfigurable implements SearchableConfigurable, Co .setShowLine(false)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public boolean isModified() { return false; @@ -80,7 +174,8 @@ public class MavenRepositoriesConfigurable implements SearchableConfigurable, Co myRepositoriesTable.setDefaultRenderer(IndexUpdatingState.class, new MyIconCellRenderer()); myRepositoriesTable.getEmptyText().setText(MavenConfigurableBundle.message("maven.settings.repositories.no")); - myRepositoriesTable.getAccessibleContext().setAccessibleName(MavenConfigurableBundle.message("maven.settings.repositories.table.accessible.name")); + myRepositoriesTable.getAccessibleContext() + .setAccessibleName(MavenConfigurableBundle.message("maven.settings.repositories.table.accessible.name")); updateButtonsState(); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.java index aecbb7509359..c14f4851e2d3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.java @@ -20,6 +20,9 @@ import com.intellij.ui.DocumentAdapter; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.TextFieldWithHistory; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.SingleEdtTaskScheduler; import com.intellij.util.ui.EdtInvocationManager; import com.intellij.util.ui.UIUtil; @@ -32,6 +35,7 @@ import org.jetbrains.idea.maven.execution.target.MavenRuntimeTargetConfiguration import org.jetbrains.idea.maven.utils.MavenEelUtil; import org.jetbrains.idea.maven.utils.MavenUtil; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; @@ -39,13 +43,16 @@ import javax.swing.SwingConstants; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.nio.file.Path; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.stream.Collectors; import static org.jetbrains.idea.maven.project.MavenHomeKt.getAllKnownHomes; @@ -53,15 +60,15 @@ import static org.jetbrains.idea.maven.project.MavenHomeKt.resolveMavenHomeType; import static org.jetbrains.idea.maven.project.MavenHomeKt.staticOrBundled; public class MavenEnvironmentForm implements PanelWithAnchor { - private JPanel panel; - private LabeledComponent> mavenHomeComponent; + private final JPanel panel; + private final LabeledComponent> mavenHomeComponent; private ContextHelpLabel mavenHomeOnTargetHelpLabel; private TextFieldWithHistory mavenHomeField; - private LabeledComponent mavenVersionLabelComponent; - private LabeledComponentNoThrow settingsFileComponent; - private LabeledComponentNoThrow localRepositoryComponent; - private JCheckBox settingsOverrideCheckBox; - private JCheckBox localRepositoryOverrideCheckBox; + private final LabeledComponent mavenVersionLabelComponent; + private final LabeledComponentNoThrow settingsFileComponent; + private final LabeledComponentNoThrow localRepositoryComponent; + private final JCheckBox settingsOverrideCheckBox; + private final JCheckBox localRepositoryOverrideCheckBox; private JComponent anchor; private final PathOverrider userSettingsFileOverrider; @@ -73,6 +80,81 @@ public class MavenEnvironmentForm implements PanelWithAnchor { private Project myProject; public MavenEnvironmentForm() { + { + mavenHomeField = new TextFieldWithHistory(); + mavenHomeField.setHistorySize(-1); + final ArrayList foundMavenHomes = new ArrayList<>(); + getAllKnownHomes().forEach(it -> foundMavenHomes.add(it.getTitle())); + mavenHomeField.setHistory(foundMavenHomes); + mavenHomeComponent = LabeledComponent.create( + new ComponentWithBrowseButton<>(mavenHomeField, null), + MavenConfigurableBundle.message("maven.settings.environment.home.directory")); + mavenHomeOnTargetHelpLabel = + ContextHelpLabel.create(MavenConfigurableBundle.message("maven.settings.on.targets.environment.home.directory.context.help")); + mavenHomeOnTargetHelpLabel.setVisible(false); + mavenHomeOnTargetHelpLabel.setOpaque(true); + mavenHomeComponent.add(mavenHomeOnTargetHelpLabel, BorderLayout.EAST); + + final JBLabel versionLabel = new JBLabel(); + versionLabel.setOpaque(true); + versionLabel.setVerticalAlignment(SwingConstants.TOP); + versionLabel.setVerticalTextPosition(SwingConstants.TOP); + mavenVersionLabelComponent = LabeledComponent.create(versionLabel, ""); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + settingsFileComponent = new LabeledComponentNoThrow(); + settingsFileComponent.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton"); + settingsFileComponent.setLabelLocation("West"); + settingsFileComponent.setText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.environment.user.settings")); + panel.add(settingsFileComponent, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + settingsOverrideCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(settingsOverrideCheckBox, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.override")); + panel.add(settingsOverrideCheckBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + localRepositoryComponent = new LabeledComponentNoThrow(); + localRepositoryComponent.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton"); + localRepositoryComponent.setLabelLocation("West"); + localRepositoryComponent.setText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.environment.local.repository")); + panel.add(localRepositoryComponent, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + localRepositoryOverrideCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(localRepositoryOverrideCheckBox, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.override")); + panel.add(localRepositoryOverrideCheckBox, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mavenHomeComponent.setLabelLocation("West"); + mavenHomeComponent.setText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.environment.home.directory")); + panel.add(mavenHomeComponent, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mavenVersionLabelComponent.setLabelLocation("West"); + mavenVersionLabelComponent.setText(""); //NON-NLS + panel.add(mavenVersionLabelComponent, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } DocumentAdapter listener = new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { @@ -109,12 +191,59 @@ public class MavenEnvironmentForm implements PanelWithAnchor { mavenHomeField.addDocumentListener(listener); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + private @NotNull Path doResolveDefaultLocalRepository() { MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject); MavenConfig config = projectsManager != null ? projectsManager.getGeneralSettings().getMavenConfig() : null; return MavenEelUtil.getLocalRepoUnderModalProgress(myProject, "", - staticOrBundled(resolveMavenHomeType(mavenHomeField.getText().trim())), - settingsFileComponent.getComponent().getText(), config); + staticOrBundled(resolveMavenHomeType(mavenHomeField.getText().trim())), + settingsFileComponent.getComponent().getText(), config); } private @NotNull Path doResolveDefaultUserSettingsFile() { @@ -123,27 +252,6 @@ public class MavenEnvironmentForm implements PanelWithAnchor { return MavenEelUtil.getUserSettingsUnderModalProgress(myProject, "", config); } - private void createUIComponents() { - mavenHomeField = new TextFieldWithHistory(); - mavenHomeField.setHistorySize(-1); - final ArrayList foundMavenHomes = new ArrayList<>(); - getAllKnownHomes().forEach(it -> foundMavenHomes.add(it.getTitle())); - mavenHomeField.setHistory(foundMavenHomes); - mavenHomeComponent = LabeledComponent.create( - new ComponentWithBrowseButton<>(mavenHomeField, null), MavenConfigurableBundle.message("maven.settings.environment.home.directory")); - mavenHomeOnTargetHelpLabel = - ContextHelpLabel.create(MavenConfigurableBundle.message("maven.settings.on.targets.environment.home.directory.context.help")); - mavenHomeOnTargetHelpLabel.setVisible(false); - mavenHomeOnTargetHelpLabel.setOpaque(true); - mavenHomeComponent.add(mavenHomeOnTargetHelpLabel, BorderLayout.EAST); - - final JBLabel versionLabel = new JBLabel(); - versionLabel.setOpaque(true); - versionLabel.setVerticalAlignment(SwingConstants.TOP); - versionLabel.setVerticalTextPosition(SwingConstants.TOP); - mavenVersionLabelComponent = LabeledComponent.create(versionLabel, ""); - } - public boolean isModified(MavenGeneralSettings data) { MavenGeneralSettings formData = new MavenGeneralSettings(); setData(formData); @@ -210,7 +318,8 @@ public class MavenEnvironmentForm implements PanelWithAnchor { public JComponent createComponent() { // all listeners will be removed when dialog is closed - var descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(MavenProjectBundle.message("maven.select.maven.home.directory")); + var descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor() + .withTitle(MavenProjectBundle.message("maven.select.maven.home.directory")); mavenHomeComponent.getComponent().addBrowseFolderListener(null, descriptor, TextComponentAccessors.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); mavenHomeField.addDocumentListener(new DocumentAdapter() { @Override diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java index f1c545e16cef..e3ef1146ec65 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java @@ -8,6 +8,9 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nls; @@ -17,43 +20,205 @@ import org.jetbrains.annotations.VisibleForTesting; import org.jetbrains.idea.maven.execution.MavenExecutionOptions; import org.jetbrains.idea.maven.utils.ComboBoxUtil; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.Locale; import java.util.Objects; +import java.util.ResourceBundle; import static com.intellij.openapi.util.text.StringUtil.nullize; @ApiStatus.Internal public class MavenGeneralPanel implements PanelWithAnchor { - private JCheckBox checkboxWorkOffline; - private JPanel panel; - private JComboBox outputLevelCombo; - private JCheckBox checkboxProduceExceptionErrorMessages; - private JComboBox checksumPolicyCombo; - private JComboBox failPolicyCombo; - private JCheckBox checkboxRecursive; - private MavenEnvironmentForm mavenPathsForm; - private JBLabel myMultiProjectBuildFailPolicyLabel; - private JCheckBox alwaysUpdateSnapshotsCheckBox; - private JTextField threadsEditor; + private final JCheckBox checkboxWorkOffline; + private final JPanel panel; + private final JComboBox outputLevelCombo; + private final JCheckBox checkboxProduceExceptionErrorMessages; + private final JComboBox checksumPolicyCombo; + private final JComboBox failPolicyCombo; + private final JCheckBox checkboxRecursive; + private final MavenEnvironmentForm mavenPathsForm; + private final JBLabel myMultiProjectBuildFailPolicyLabel; + private final JCheckBox alwaysUpdateSnapshotsCheckBox; + private final JTextField threadsEditor; private final DefaultComboBoxModel outputLevelComboModel = new DefaultComboBoxModel(); private final DefaultComboBoxModel checksumPolicyComboModel = new DefaultComboBoxModel(); private final DefaultComboBoxModel failPolicyComboModel = new DefaultComboBoxModel(); private JComponent anchor; - private JCheckBox showDialogWithAdvancedSettingsCheckBox; - private JCheckBox useMavenConfigCheckBox; - private JBLabel mavenConfigWarningLabel; + private final JCheckBox showDialogWithAdvancedSettingsCheckBox; + private final JCheckBox useMavenConfigCheckBox; + private final JBLabel mavenConfigWarningLabel; private boolean isShowAdvancedSettingsCheckBox = false; private MavenGeneralSettings myInitialSettings; public MavenGeneralPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(13, 6, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.output.level")); + panel.add(label1, + new GridConstraints(5, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(66, 23), null, 0, false)); + outputLevelCombo = new JComboBox(); + panel.add(outputLevelCombo, new GridConstraints(5, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.checksum.policy")); + panel.add(label2, + new GridConstraints(6, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + checksumPolicyCombo = new JComboBox(); + panel.add(checksumPolicyCombo, new GridConstraints(6, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myMultiProjectBuildFailPolicyLabel = new JBLabel(); + this.$$$loadLabelText$$$(myMultiProjectBuildFailPolicyLabel, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.multiproject.build.policy")); + panel.add(myMultiProjectBuildFailPolicyLabel, + new GridConstraints(7, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + failPolicyCombo = new JComboBox(); + panel.add(failPolicyCombo, new GridConstraints(7, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + checkboxWorkOffline = new JCheckBox(); + checkboxWorkOffline.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(checkboxWorkOffline, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.work.offline")); + checkboxWorkOffline.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.work.offline.tooltip")); + panel.add(checkboxWorkOffline, new GridConstraints(0, 0, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + checkboxRecursive = new JCheckBox(); + checkboxRecursive.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(checkboxRecursive, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.execute.recursively")); + checkboxRecursive.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.execute.recursively.tooltip")); + panel.add(checkboxRecursive, new GridConstraints(1, 0, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(185, 22), null, 0, false)); + checkboxProduceExceptionErrorMessages = new JCheckBox(); + checkboxProduceExceptionErrorMessages.setAlignmentY(0.5f); + checkboxProduceExceptionErrorMessages.setMargin(new Insets(2, 0, 2, 0)); + this.$$$loadButtonText$$$(checkboxProduceExceptionErrorMessages, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.print.stacktraces")); + checkboxProduceExceptionErrorMessages.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.print.stacktraces.tooltip")); + panel.add(checkboxProduceExceptionErrorMessages, + new GridConstraints(2, 0, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mavenPathsForm = new MavenEnvironmentForm(); + panel.add(mavenPathsForm.$$$getRootComponent$$$(), + new GridConstraints(9, 0, 1, 6, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + panel.add(spacer1, new GridConstraints(5, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + alwaysUpdateSnapshotsCheckBox = new JCheckBox(); + alwaysUpdateSnapshotsCheckBox.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(alwaysUpdateSnapshotsCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.update.snapshots")); + alwaysUpdateSnapshotsCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.update.snapshots.tooltip")); + panel.add(alwaysUpdateSnapshotsCheckBox, new GridConstraints(3, 0, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setHorizontalAlignment(10); + jBLabel1.setHorizontalTextPosition(11); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.thread.count")); + jBLabel1.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.general.thread.count.tooltip")); + panel.add(jBLabel1, + new GridConstraints(8, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + threadsEditor = new JTextField(); + panel.add(threadsEditor, new GridConstraints(8, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + jBLabel2.setComponentStyle(UIUtil.ComponentStyle.SMALL); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.general.thread.count.note")); + panel.add(jBLabel2, + new GridConstraints(8, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + showDialogWithAdvancedSettingsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(showDialogWithAdvancedSettingsCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.environment.show.advanced.settings")); + showDialogWithAdvancedSettingsCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.environment.show.advanced.settings.tooltip")); + panel.add(showDialogWithAdvancedSettingsCheckBox, + new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + useMavenConfigCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(useMavenConfigCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.environment.use.maven.config.settings")); + useMavenConfigCheckBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.environment.use.maven.config.settings.tooltip")); + panel.add(useMavenConfigCheckBox, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel.add(spacer2, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel.add(panel1, new GridConstraints(11, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + mavenConfigWarningLabel = new JBLabel(); + mavenConfigWarningLabel.setAutoscrolls(false); + mavenConfigWarningLabel.setFocusable(false); + Font mavenConfigWarningLabelFont = this.$$$getFont$$$(null, -1, -1, mavenConfigWarningLabel.getFont()); + if (mavenConfigWarningLabelFont != null) mavenConfigWarningLabel.setFont(mavenConfigWarningLabelFont); + mavenConfigWarningLabel.setHorizontalAlignment(10); + mavenConfigWarningLabel.setHorizontalTextPosition(11); + this.$$$loadLabelText$$$(mavenConfigWarningLabel, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.environment.use.maven.config.settings.hint")); + mavenConfigWarningLabel.setToolTipText(""); + panel1.add(mavenConfigWarningLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel1.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + label1.setLabelFor(outputLevelCombo); + label2.setLabelFor(checksumPolicyCombo); + myMultiProjectBuildFailPolicyLabel.setLabelFor(failPolicyCombo); + jBLabel1.setLabelFor(threadsEditor); + } fillOutputLevelCombobox(); fillChecksumPolicyCombobox(); fillFailureBehaviorCombobox(); @@ -61,6 +226,102 @@ public class MavenGeneralPanel implements PanelWithAnchor { setAnchor(myMultiProjectBuildFailPolicyLabel); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + private void fillOutputLevelCombobox() { ComboBoxUtil.setModel(outputLevelCombo, outputLevelComboModel, Arrays.asList(MavenExecutionOptions.LoggingLevel.values()), diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenIgnoredFilesConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenIgnoredFilesConfigurable.java index 9ed7c24baf12..333e6167a05b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenIgnoredFilesConfigurable.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenIgnoredFilesConfigurable.java @@ -9,6 +9,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; @@ -21,6 +24,8 @@ import org.jetbrains.idea.maven.utils.Strings; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextArea; +import java.awt.Dimension; +import java.awt.Insets; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -33,13 +38,52 @@ public class MavenIgnoredFilesConfigurable implements SearchableConfigurable, Co private Collection myOriginallyIgnoredFilesPaths; private String myOriginallyIgnoredFilesPatterns; - private JPanel myMainPanel; - private ElementsChooser myIgnoredFilesPathsChooser; - private JTextArea myIgnoredFilesPattersEditor; - private JPanel myIgnoredFilesPatternsPanel; - private JPanel myIgnoredFilesPanel; + private final JPanel myMainPanel; + private final ElementsChooser myIgnoredFilesPathsChooser; + private final JTextArea myIgnoredFilesPattersEditor; + private final JPanel myIgnoredFilesPatternsPanel; + private final JPanel myIgnoredFilesPanel; public MavenIgnoredFilesConfigurable(Project project) { + { + myIgnoredFilesPathsChooser = new ElementsChooser<>(true); + myIgnoredFilesPathsChooser.getEmptyText().setText(MavenConfigurableBundle.message("maven.settings.ignored.no.file")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myIgnoredFilesPatternsPanel = new JPanel(); + myIgnoredFilesPatternsPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myIgnoredFilesPatternsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myIgnoredFilesPatternsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myIgnoredFilesPatternsPanel.add(jBScrollPane1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, new Dimension(-1, 40), null, 0, false)); + myIgnoredFilesPattersEditor = new JTextArea(); + jBScrollPane1.setViewportView(myIgnoredFilesPattersEditor); + myIgnoredFilesPanel = new JPanel(); + myIgnoredFilesPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myIgnoredFilesPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(myIgnoredFilesPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myIgnoredFilesPanel.add(myIgnoredFilesPathsChooser, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + } myManager = MavenProjectsManager.getInstance(project); myIgnoredFilesPatternsPanel.setBorder( IdeBorderFactory.createTitledBorder(MavenConfigurableBundle.message("maven.settings.ignored.tooltip"), false, JBUI.insetsTop(8)) @@ -50,10 +94,8 @@ public class MavenIgnoredFilesConfigurable implements SearchableConfigurable, Co .setShowLine(false)); } - private void createUIComponents() { - myIgnoredFilesPathsChooser = new ElementsChooser<>(true); - myIgnoredFilesPathsChooser.getEmptyText().setText(MavenConfigurableBundle.message("maven.settings.ignored.no.file")); - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } @Override public JComponent createComponent() { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java index 4766b063bc8d..7a4ca275e88f 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java @@ -12,48 +12,279 @@ import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.updateSettings.impl.LabelTextReplacingUtil; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.EnumComboBoxModel; +import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTextField; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.project.actions.LookForNestedToggleAction; import org.jetbrains.idea.maven.utils.MavenUtil; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class MavenImportingSettingsForm { - private JPanel myPanel; + private final JPanel myPanel; - private JCheckBox mySearchRecursivelyCheckBox; + private final JCheckBox mySearchRecursivelyCheckBox; - private JComboBox myUpdateFoldersOnImportPhaseComboBox; - private JCheckBox myUseMavenOutputCheckBox; - private JCheckBox myDownloadSourcesCheckBox; - private JCheckBox myDownloadDocsCheckBox; - private JCheckBox myDownloadAnnotationsCheckBox; + private final JComboBox myUpdateFoldersOnImportPhaseComboBox; + private final JCheckBox myUseMavenOutputCheckBox; + private final JCheckBox myDownloadSourcesCheckBox; + private final JCheckBox myDownloadDocsCheckBox; + private final JCheckBox myDownloadAnnotationsCheckBox; - private JPanel myAdditionalSettingsPanel; - private JComboBox myGeneratedSourcesComboBox; - private JCheckBox myExcludeTargetFolderCheckBox; - private JTextField myDependencyTypes; - private JBTextField myVMOptionsForImporter; - private ExternalSystemJdkComboBox myJdkForImporterComboBox; - private JBLabel myImporterJdkWarning; - private JCheckBox myAutoDetectCompilerCheckBox; - private JCheckBox runPluginsCompat; + private final JPanel myAdditionalSettingsPanel; + private final JComboBox myGeneratedSourcesComboBox; + private final JCheckBox myExcludeTargetFolderCheckBox; + private final JTextField myDependencyTypes; + private final JBTextField myVMOptionsForImporter; + private final ExternalSystemJdkComboBox myJdkForImporterComboBox; + private final JBLabel myImporterJdkWarning; + private final JCheckBox myAutoDetectCompilerCheckBox; + private final JCheckBox runPluginsCompat; private final ComponentValidator myImporterJdkValidator; private volatile boolean myMuteJdkValidation = false; public MavenImportingSettingsForm(Project project, @NotNull Disposable disposable) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(22, 4, new Insets(0, 0, 0, 0), -1, -1)); + mySearchRecursivelyCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(mySearchRecursivelyCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.search.recursively")); + myPanel.add(mySearchRecursivelyCheckBox, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myUseMavenOutputCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseMavenOutputCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.use.output.directories")); + myUseMavenOutputCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.use.output.directories.tooltip")); + myPanel.add(myUseMavenOutputCheckBox, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel1.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.phase.for.source.updates.notes")); + myPanel.add(jBLabel1, new GridConstraints(9, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 3, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 5, new Insets(10, 0, 0, 0), -1, -1)); + panel1.setFocusable(true); + myPanel.add(panel1, new GridConstraints(11, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.auto.download")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDownloadSourcesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myDownloadSourcesCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.auto.download.sources")); + panel1.add(myDownloadSourcesCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDownloadDocsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myDownloadDocsCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.auto.download.documentation")); + panel1.add(myDownloadDocsCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myDownloadAnnotationsCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myDownloadAnnotationsCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.auto.download.annotations")); + panel1.add(myDownloadAnnotationsCheckBox, + new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAdditionalSettingsPanel = new JPanel(); + myAdditionalSettingsPanel.setLayout(new GridLayoutManager(1, 1, new Insets(15, 0, 0, 0), -1, -1)); + myPanel.add(myAdditionalSettingsPanel, new GridConstraints(20, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(11, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myPanel.add(spacer3, new GridConstraints(21, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myUpdateFoldersOnImportPhaseComboBox = new JComboBox(); + panel2.add(myUpdateFoldersOnImportPhaseComboBox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.phase.for.source.updates")); + panel2.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel2.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + myPanel.add(spacer5, new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + final Spacer spacer6 = new Spacer(); + myPanel.add(spacer6, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel3, new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.generated.source.folders")); + panel3.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer7 = new Spacer(); + panel3.add(spacer7, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myGeneratedSourcesComboBox = new JComboBox(); + panel3.add(myGeneratedSourcesComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myExcludeTargetFolderCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myExcludeTargetFolderCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.project.exclude.build.directory")); + myExcludeTargetFolderCheckBox.setToolTipText(this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.project.exclude.build.directory.tooltip")); + myPanel.add(myExcludeTargetFolderCheckBox, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.dependency.type")); + label4.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.dependency.type.tooltip")); + myPanel.add(label4, + new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDependencyTypes = new JTextField(); + myDependencyTypes.setColumns(0); + myDependencyTypes.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.dependency.type.tooltip")); + myPanel.add(myDependencyTypes, new GridConstraints(12, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(60, -1), null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + jBLabel2.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel2.setFontColor(UIUtil.FontColor.BRIGHTER); + jBLabel2.setHorizontalTextPosition(4); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.dependency.type.tooltip")); + myPanel.add(jBLabel2, new GridConstraints(13, 1, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer8 = new Spacer(); + myPanel.add(spacer8, new GridConstraints(14, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + final Spacer spacer9 = new Spacer(); + myPanel.add(spacer9, new GridConstraints(10, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 10), null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.vm.options")); + myPanel.add(jBLabel3, + new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myVMOptionsForImporter = new JBTextField(); + myPanel.add(myVMOptionsForImporter, new GridConstraints(15, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.jdk")); + myPanel.add(jBLabel4, + new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJdkForImporterComboBox = new ExternalSystemJdkComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + myJdkForImporterComboBox.setModel(defaultComboBoxModel1); + myPanel.add(myJdkForImporterComboBox, new GridConstraints(17, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myAutoDetectCompilerCheckBox = new JCheckBox(); + myAutoDetectCompilerCheckBox.setSelected(true); + this.$$$loadButtonText$$$(myAutoDetectCompilerCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.detect.compiler")); + myPanel.add(myAutoDetectCompilerCheckBox, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + jBLabel5.setComponentStyle(UIUtil.ComponentStyle.SMALL); + jBLabel5.setFontColor(UIUtil.FontColor.BRIGHTER); + jBLabel5.setHorizontalTextPosition(4); + this.$$$loadLabelText$$$(jBLabel5, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.vm.options.tooltip")); + myPanel.add(jBLabel5, new GridConstraints(16, 1, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myImporterJdkWarning = new JBLabel(); + myImporterJdkWarning.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myImporterJdkWarning.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(myImporterJdkWarning, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.jdk.fallback.warning")); + myPanel.add(myImporterJdkWarning, new GridConstraints(19, 1, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + runPluginsCompat = new JCheckBox(); + this.$$$loadButtonText$$$(runPluginsCompat, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.importing.use.plugin.compat")); + runPluginsCompat.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.importing.use.plugin.compat.tooltip")); + myPanel.add(runPluginsCompat, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label2.setLabelFor(myUpdateFoldersOnImportPhaseComboBox); + label4.setLabelFor(myDependencyTypes); + jBLabel2.setLabelFor(myDependencyTypes); + jBLabel5.setLabelFor(myDependencyTypes); + } myJdkForImporterComboBox.setProject(project); mySearchRecursivelyCheckBox.setVisible(project.isDefault()); @@ -99,6 +330,78 @@ public class MavenImportingSettingsForm { myImporterJdkWarning.setVisible(false); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateModuleDirControls() { validateImporterJDK(); } @@ -161,7 +464,8 @@ public class MavenImportingSettingsForm { myMuteJdkValidation = true; try { r.run(); - } finally { + } + finally { myMuteJdkValidation = false; validateImporterJDK(); } @@ -188,7 +492,8 @@ public class MavenImportingSettingsForm { myImporterJdkValidator.revalidate(); if (myImporterJdkValidator.getValidationInfo() == null) { myImporterJdkWarning.setVisible(false); - } else { + } + else { myImporterJdkWarning.setVisible(true); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenTestRunningConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenTestRunningConfigurable.java index f2f6cf63b9eb..4c654db0e060 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenTestRunningConfigurable.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenTestRunningConfigurable.java @@ -5,27 +5,115 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class MavenTestRunningConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myMainPanel; + private final JPanel myMainPanel; - private JBCheckBox myPassArgLineCB; - private JBCheckBox myPassSystemPropertiesCB; - private JBCheckBox myPassEnvironmentVariablesCB; + private final JBCheckBox myPassArgLineCB; + private final JBCheckBox myPassSystemPropertiesCB; + private final JBCheckBox myPassEnvironmentVariablesCB; private final Project myProject; public MavenTestRunningConfigurable(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 5, new Insets(0, 0, 0, 0), -1, -1)); + myPassArgLineCB = new JBCheckBox(); + this.$$$loadButtonText$$$(myPassArgLineCB, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.testrun.argline")); + myMainPanel.add(myPassArgLineCB, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.testrun.caption")); + myMainPanel.add(titledSeparator1, new GridConstraints(0, 0, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPassSystemPropertiesCB = new JBCheckBox(); + this.$$$loadButtonText$$$(myPassSystemPropertiesCB, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.testrun.system.property")); + myMainPanel.add(myPassSystemPropertiesCB, new GridConstraints(2, 0, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myPassEnvironmentVariablesCB = new JBCheckBox(); + this.$$$loadButtonText$$$(myPassEnvironmentVariablesCB, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.testrun.env.variables")); + myMainPanel.add(myPassEnvironmentVariablesCB, new GridConstraints(3, 0, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public @Nls String getDisplayName() { return MavenProjectBundle.message("maven.testRunning"); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenAddArchetypeDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenAddArchetypeDialog.java index 31218282f1cd..a435af56e8bb 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenAddArchetypeDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenAddArchetypeDialog.java @@ -4,28 +4,86 @@ package org.jetbrains.idea.maven.wizards; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.maven.model.MavenArchetype; import org.jetbrains.idea.maven.project.MavenConfigurableBundle; import org.jetbrains.idea.maven.project.MavenProjectBundle; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; public class MavenAddArchetypeDialog extends DialogWrapper { - private JPanel myMainPanel; - private JTextField myGroupIdField; - private JTextField myArtifactIdField; - private JTextField myVersionField; - private JTextField myRepositoryField; + private final JPanel myMainPanel; + private final JTextField myGroupIdField; + private final JTextField myArtifactIdField; + private final JTextField myVersionField; + private final JTextField myRepositoryField; public MavenAddArchetypeDialog(Component parent) { super(parent, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.archetype.add.groupid")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myGroupIdField = new JTextField(); + myMainPanel.add(myGroupIdField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.archetype.add.artifactid")); + myMainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myArtifactIdField = new JTextField(); + myMainPanel.add(myArtifactIdField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", "maven.settings.archetype.add.version")); + myMainPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myVersionField = new JTextField(); + myMainPanel.add(myVersionField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.archetype.add.repository")); + myMainPanel.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myRepositoryField = new JTextField(); + myMainPanel.add(myRepositoryField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } setTitle(MavenConfigurableBundle.message("maven.settings.archetype.add.title")); init(); @@ -45,6 +103,53 @@ public class MavenAddArchetypeDialog extends DialogWrapper { doValidateInput(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected JComponent createCenterPanel() { return myMainPanel; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenArchetypesStep.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenArchetypesStep.java index ea84cf4c3338..8d4722ccd2d3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenArchetypesStep.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenArchetypesStep.java @@ -14,8 +14,12 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.SpeedSearchComparator; import com.intellij.ui.TreeSpeedSearch; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.render.RenderingUtil; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.concurrency.ThreadingAssertions; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.UIUtil; @@ -26,6 +30,7 @@ import org.jetbrains.idea.maven.indices.MavenArchetypeManager; import org.jetbrains.idea.maven.indices.MavenIndicesManager; import org.jetbrains.idea.maven.model.MavenArchetype; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -47,13 +52,16 @@ import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; import java.util.TreeMap; @@ -61,13 +69,13 @@ import java.util.TreeMap; * @author Dmitry Avdeev */ public final class MavenArchetypesStep extends ModuleWizardStep implements Disposable { - private JCheckBox myUseArchetypeCheckBox; - private JButton myAddArchetypeButton; - private JPanel myArchetypesPanel; + private final JCheckBox myUseArchetypeCheckBox; + private final JButton myAddArchetypeButton; + private final JPanel myArchetypesPanel; private final Tree myArchetypesTree; - private JScrollPane myArchetypeDescriptionScrollPane; - private JPanel myMainPanel; - private JTextArea myArchetypeDescriptionField; + private final JScrollPane myArchetypeDescriptionScrollPane; + private final JPanel myMainPanel; + private final JTextArea myArchetypeDescriptionField; private Object myCurrentUpdaterMarker; private final AsyncProcessIcon myLoadingIcon = new AsyncProcessIcon.Big(getClass() + ".loading"); @@ -79,6 +87,42 @@ public final class MavenArchetypesStep extends ModuleWizardStep implements Dispo public MavenArchetypesStep(AbstractMavenModuleBuilder builder, @Nullable StepAdapter step) { myBuilder = builder; myStep = step; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myUseArchetypeCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseArchetypeCheckBox, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.archetype.create.from.archetype")); + myMainPanel.add(myUseArchetypeCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myAddArchetypeButton = new JButton(); + this.$$$loadButtonText$$$(myAddArchetypeButton, this.$$$getMessageFromBundle$$$("messages/MavenConfigurableBundle", + "maven.settings.archetype.add.archetype")); + myMainPanel.add(myAddArchetypeButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myArchetypesPanel = new JPanel(); + myArchetypesPanel.setLayout(new CardLayout(0, 0)); + myMainPanel.add(myArchetypesPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myArchetypeDescriptionScrollPane = new JBScrollPane(); + myMainPanel.add(myArchetypeDescriptionScrollPane, + new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myArchetypeDescriptionField = new JTextArea(); + myArchetypeDescriptionScrollPane.setViewportView(myArchetypeDescriptionField); + } Disposer.register(this, myLoadingIcon); myArchetypesTree = new Tree(); @@ -138,6 +182,53 @@ public final class MavenArchetypesStep extends ModuleWizardStep implements Dispo updateComponents(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + public JPanel getMainPanel() { return myMainPanel; } @@ -147,7 +238,6 @@ public final class MavenArchetypesStep extends ModuleWizardStep implements Dispo myAddArchetypeButton.setEnabled(archetypesEnabled); myArchetypesTree.setEnabled(archetypesEnabled); myArchetypesTree.setBackground(archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground()); - } public @Nullable MavenArchetype getSelectedArchetype() { @@ -345,5 +435,4 @@ public final class MavenArchetypesStep extends ModuleWizardStep implements Dispo } } } - } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java index 4c4f733af076..ebf390f443de 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java @@ -11,6 +11,8 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,6 +24,7 @@ import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectBundle; import org.jetbrains.idea.maven.project.MavenProjectsManager; +import javax.swing.AbstractButton; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -30,9 +33,13 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.nio.file.Path; +import java.util.ResourceBundle; /** * @deprecated use {@link MavenNewProjectWizardStep} instead @@ -57,25 +64,122 @@ public class MavenModuleWizardStep extends ModuleWizardStep { private String myInheritedGroupId; private String myInheritedVersion; - private JPanel myMainPanel; + private final JPanel myMainPanel; - private JLabel myAggregatorNameLabel; - private JButton mySelectAggregator; - private JLabel myParentNameLabel; - private JButton mySelectParent; + private final JLabel myAggregatorNameLabel; + private final JButton mySelectAggregator; + private final JLabel myParentNameLabel; + private final JButton mySelectParent; - private JTextField myGroupIdField; - private JCheckBox myInheritGroupIdCheckBox; - private JTextField myArtifactIdField; - private JTextField myVersionField; - private JCheckBox myInheritVersionCheckBox; + private final JTextField myGroupIdField; + private final JCheckBox myInheritGroupIdCheckBox; + private final JTextField myArtifactIdField; + private final JTextField myVersionField; + private final JCheckBox myInheritVersionCheckBox; - private JPanel myArchetypesPanel; - private JPanel myAddToPanel; + private final JPanel myArchetypesPanel; + private final JPanel myAddToPanel; private final @Nullable MavenArchetypesStep myArchetypes; public MavenModuleWizardStep(AbstractMavenModuleBuilder builder, WizardContext context, boolean includeArtifacts) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.groupid")); + myMainPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.artifactid")); + myMainPanel.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.version")); + myMainPanel.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myGroupIdField = new JTextField(); + myMainPanel.add(myGroupIdField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myArtifactIdField = new JTextField(); + myMainPanel.add(myArtifactIdField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myVersionField = new JTextField(); + myMainPanel.add(myVersionField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myInheritGroupIdCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myInheritGroupIdCheckBox, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.inherit")); + myMainPanel.add(myInheritGroupIdCheckBox, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myInheritVersionCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myInheritVersionCheckBox, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.inherit")); + myMainPanel.add(myInheritVersionCheckBox, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myArchetypesPanel = new JPanel(); + myArchetypesPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myArchetypesPanel, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myAddToPanel = new JPanel(); + myAddToPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myAddToPanel, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, true)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.add.to")); + myAddToPanel.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAggregatorNameLabel = new JLabel(); + myAggregatorNameLabel.setText("Label"); //NON-NLS + myAddToPanel.add(myAggregatorNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mySelectAggregator = new JButton(); + mySelectAggregator.setMargin(new Insets(0, 0, 0, 0)); + mySelectAggregator.setText("..."); + myAddToPanel.add(mySelectAggregator, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, + this.$$$getMessageFromBundle$$$("messages/MavenWizardBundle", "maven.structure.wizard.module.parent")); + myAddToPanel.add(label5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myParentNameLabel = new JLabel(); + myParentNameLabel.setText("Label"); //NON-NLS + myAddToPanel.add(myParentNameLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + mySelectParent = new JButton(); + mySelectParent.setMargin(new Insets(0, 0, 0, 0)); + mySelectParent.setText("..."); + myAddToPanel.add(mySelectParent, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } myProjectOrNull = context.getProject(); myBuilder = builder; myContext = context; @@ -94,6 +198,78 @@ public class MavenModuleWizardStep extends ModuleWizardStep { this((AbstractMavenModuleBuilder)builder, context, includeArtifacts); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void initComponents() { mySelectAggregator.addActionListener(new ActionListener() { @@ -213,7 +389,7 @@ public class MavenModuleWizardStep extends ModuleWizardStep { if (!MavenProjectsManager.getInstance(project).isMavenizedProject()) return null; VirtualFile parentPom = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(Path.of(myContext.getProjectFileDirectory(), - MavenConstants.POM_XML)); + MavenConstants.POM_XML)); if (parentPom == null) return null; return MavenProjectsManager.getInstance(project).findProject(parentPom); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectPropertiesStep.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectPropertiesStep.java index 550adad022d0..4bd60f8cca3e 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectPropertiesStep.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectPropertiesStep.java @@ -4,6 +4,10 @@ package org.jetbrains.idea.maven.wizards; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.execution.MavenPropertiesPanel; @@ -12,17 +16,24 @@ import org.jetbrains.idea.maven.model.MavenArchetype; import org.jetbrains.idea.maven.model.MavenId; import org.jetbrains.idea.maven.project.MavenEnvironmentForm; import org.jetbrains.idea.maven.project.MavenProjectsManager; +import org.jetbrains.idea.maven.wizards.archetype.MavenArchetypeNewProjectWizard; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import java.util.ResourceBundle; /** - * @deprecated use {@link org.jetbrains.idea.maven.wizards.archetype.MavenArchetypeNewProjectWizard} instead + * @deprecated use {@link MavenArchetypeNewProjectWizard} instead */ @Deprecated @SuppressWarnings("DeprecatedIsStillUsed") @@ -31,9 +42,9 @@ public class SelectPropertiesStep extends ModuleWizardStep { private final Project myProjectOrNull; private final AbstractMavenModuleBuilder myBuilder; - private JPanel myMainPanel; - private JPanel myEnvironmentPanel; - private JPanel myPropertiesPanel; + private final JPanel myMainPanel; + private final JPanel myEnvironmentPanel; + private final JPanel myPropertiesPanel; private MavenEnvironmentForm myEnvironmentForm; private MavenPropertiesPanel myMavenPropertiesPanel; @@ -43,6 +54,35 @@ public class SelectPropertiesStep extends ModuleWizardStep { public SelectPropertiesStep(@Nullable Project project, AbstractMavenModuleBuilder builder) { myProjectOrNull = project; myBuilder = builder; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myEnvironmentPanel = new JPanel(); + myEnvironmentPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myEnvironmentPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new BorderLayout(0, 0)); + myPropertiesPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myMainPanel.add(myPropertiesPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(-1, 300), null, 0, false)); + myPropertiesPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/MavenWizardBundle", + "maven.structure.wizard.properties"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } initComponents(); } @@ -51,6 +91,28 @@ public class SelectPropertiesStep extends ModuleWizardStep { this(project, (AbstractMavenModuleBuilder)builder); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void initComponents() { myEnvironmentForm = new MavenEnvironmentForm(); diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/ui/FinishScriptDialog.java b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/ui/FinishScriptDialog.java index 41699bde9f6c..7d4e70367d7a 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/ui/FinishScriptDialog.java +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/ui/FinishScriptDialog.java @@ -5,6 +5,7 @@ import com.intellij.ide.BrowserUtil; import com.intellij.ide.actions.RevealFileAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.ui.components.JBScrollPane; import com.intellij.util.PlatformUtils; import com.jetbrains.performancePlugin.PerformanceTestingBundle; import com.jetbrains.performancePlugin.profilers.Profiler; @@ -19,20 +20,41 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.BorderLayout; +import java.awt.Font; import java.awt.event.ActionEvent; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class FinishScriptDialog extends DialogWrapper { - private JPanel myMainPanel; - private JTextField snapshotLabel; - private JTextArea metricsPanel; + private final JPanel myMainPanel; + private final JTextField snapshotLabel; + private final JTextArea metricsPanel; private File snapshot = null; public FinishScriptDialog(@Nullable Project project) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new BorderLayout(0, 0)); + snapshotLabel = new JTextField(); + Font snapshotLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, snapshotLabel.getFont()); + if (snapshotLabelFont != null) snapshotLabel.setFont(snapshotLabelFont); + snapshotLabel.setText(""); + myMainPanel.add(snapshotLabel, BorderLayout.SOUTH); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMainPanel.add(jBScrollPane1, BorderLayout.CENTER); + metricsPanel = new JTextArea(); + jBScrollPane1.setViewportView(metricsPanel); + } if (ProfilersController.getInstance().isStoppedByScript()) { String path = ProfilersController.getInstance().getReportsPath(); try { @@ -56,6 +78,33 @@ public class FinishScriptDialog extends DialogWrapper { pack(); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected Action @NotNull [] createActions() { @@ -63,9 +112,10 @@ public class FinishScriptDialog extends DialogWrapper { dialogActions.add(new DialogWrapperAction(PerformanceTestingBundle.message("summary.action")) { @Override protected void doAction(ActionEvent e) { - if(!PlatformUtils.isRider()){ + if (!PlatformUtils.isRider()) { BrowserUtil.browse(PerformanceTestingBundle.message("summary.link")); - } else{ + } + else { BrowserUtil.browse(PerformanceTestingBundle.message("summary.link.rider")); } } diff --git a/plugins/performanceTesting/scripts-ui/src/com/jetbrains/performanceScripts/ui/ExecuteScriptDialog.java b/plugins/performanceTesting/scripts-ui/src/com/jetbrains/performanceScripts/ui/ExecuteScriptDialog.java index 194bbde0b233..ba076c48890b 100644 --- a/plugins/performanceTesting/scripts-ui/src/com/jetbrains/performanceScripts/ui/ExecuteScriptDialog.java +++ b/plugins/performanceTesting/scripts-ui/src/com/jetbrains/performanceScripts/ui/ExecuteScriptDialog.java @@ -7,6 +7,10 @@ import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorTextField; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.jetbrains.performancePlugin.utils.ScriptRunner; import com.jetbrains.performanceScripts.PerformanceScriptsBundle; import com.jetbrains.performanceScripts.lang.IJPerfFileType; @@ -16,16 +20,20 @@ import org.jetbrains.annotations.Nullable; import javax.swing.Action; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public final class ExecuteScriptDialog extends DialogWrapper { private final Project project; - private EditorTextField scriptText; - private JPanel myMainPanel; - private ComboBox scenarioComboBox; + private final EditorTextField scriptText; + private final JPanel myMainPanel; + private final ComboBox scenarioComboBox; private static String lastUsedText = null; private final ScriptRunner myScriptRunner; private final Action execute; @@ -33,12 +41,44 @@ public final class ExecuteScriptDialog extends DialogWrapper { public ExecuteScriptDialog(final @NotNull Project project) { super(project); this.project = project; + { + scriptText = new EditorTextField(project, IJPerfFileType.INSTANCE); + scriptText.setOneLineMode(false); + scriptText.setText(lastUsedText != null ? lastUsedText : + getCurrentFileCommand(project) + generateTestScript(PerformanceScriptType.TYPING)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + scenarioComboBox = new ComboBox(); + myMainPanel.add(scenarioComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PerformanceScriptsBundle", "select.scenario")); + myMainPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMainPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBScrollPane1.setViewportView(scriptText); + jBLabel1.setLabelFor(scenarioComboBox); + } myScriptRunner = new ScriptRunner(); execute = createExecuteAction(); setTitle(PerformanceScriptsBundle.message("executor.title")); - scenarioComboBox.addItem(new Scenario(PerformanceScriptsBundle.message("typing.scenario"), generateTestScript(PerformanceScriptType.TYPING))); - scenarioComboBox.addItem(new Scenario(PerformanceScriptsBundle.message("formatting.scenario"), generateTestScript(PerformanceScriptType.FORMATTING))); - scenarioComboBox.addItem(new Scenario(PerformanceScriptsBundle.message("local.inspection.scenario"), generateTestScript(PerformanceScriptType.INSPECTION))); + scenarioComboBox.addItem( + new Scenario(PerformanceScriptsBundle.message("typing.scenario"), generateTestScript(PerformanceScriptType.TYPING))); + scenarioComboBox.addItem( + new Scenario(PerformanceScriptsBundle.message("formatting.scenario"), generateTestScript(PerformanceScriptType.FORMATTING))); + scenarioComboBox.addItem( + new Scenario(PerformanceScriptsBundle.message("local.inspection.scenario"), generateTestScript(PerformanceScriptType.INSPECTION))); scenarioComboBox.setEditable(false); scenarioComboBox.setSelectedIndex(0); scenarioComboBox.addItemListener(new ItemListener() { @@ -52,13 +92,53 @@ public final class ExecuteScriptDialog extends DialogWrapper { init(); } - private void createUIComponents() { - scriptText = new EditorTextField(project, IJPerfFileType.INSTANCE); - scriptText.setOneLineMode(false); - scriptText.setText(lastUsedText != null ? lastUsedText : - getCurrentFileCommand(project) + generateTestScript(PerformanceScriptType.TYPING)); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private static String getCurrentFileCommand(Project project) { FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); String openFileCommand = ""; diff --git a/plugins/properties/src/com/intellij/lang/properties/create/CreateResourceBundleDialogComponent.java b/plugins/properties/src/com/intellij/lang/properties/create/CreateResourceBundleDialogComponent.java index 96b757d3e720..afd1cb3656de 100644 --- a/plugins/properties/src/com/intellij/lang/properties/create/CreateResourceBundleDialogComponent.java +++ b/plugins/properties/src/com/intellij/lang/properties/create/CreateResourceBundleDialogComponent.java @@ -40,26 +40,34 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBList; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.PathUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import javax.swing.AbstractButton; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ContainerAdapter; import java.awt.event.ContainerEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -89,14 +97,14 @@ public final class CreateResourceBundleDialogComponent { private final Project myProject; private final PsiDirectory myDirectory; private final ResourceBundle myResourceBundle; - private JPanel myPanel; - private JTextField myResourceBundleBaseNameTextField; - private JButton myAddLocaleFromExistButton; - private JPanel myNewBundleLocalesPanel; - private JPanel myProjectExistLocalesPanel; - private JButton myAddAllButton; - private JPanel myResourceBundleNamePanel; - private JCheckBox myUseXMLBasedPropertiesCheckBox; + private final JPanel myPanel; + private final JTextField myResourceBundleBaseNameTextField; + private final JButton myAddLocaleFromExistButton; + private final JPanel myNewBundleLocalesPanel; + private final JPanel myProjectExistLocalesPanel; + private final JButton myAddAllButton; + private final JPanel myResourceBundleNamePanel; + private final JCheckBox myUseXMLBasedPropertiesCheckBox; private CollectionListModel myLocalesModel; private final Map myLocaleSuffixes; // java.util.Locale is case insensitive @@ -104,11 +112,184 @@ public final class CreateResourceBundleDialogComponent { myProject = project; myDirectory = directory; myResourceBundle = resourceBundle; + { + final JBList projectExistLocalesList = new JBList<>(); + final MyExistLocalesListModel existLocalesListModel = new MyExistLocalesListModel(); + projectExistLocalesList.setModel(existLocalesListModel); + projectExistLocalesList.setCellRenderer(getLocaleRenderer()); + myProjectExistLocalesPanel = ToolbarDecorator.createDecorator(projectExistLocalesList) + .disableRemoveAction() + .disableUpDownActions() + .createPanel(); + myProjectExistLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( + PropertiesBundle.message("create.resource.bundle.project.locales.title"), false)); + + final JBList localesToAddList = new JBList(); + + final List locales; + final List restrictedLocales; + if (myResourceBundle == null) { + locales = Collections.singletonList(PropertiesUtil.DEFAULT_LOCALE); + restrictedLocales = Collections.emptyList(); + } + else { + locales = Collections.emptyList(); + restrictedLocales = ContainerUtil.map(myResourceBundle.getPropertiesFiles(), PropertiesFile::getLocale); + } + myLocalesModel = new CollectionListModel<>(locales) { + @Override + public void add(@NotNull List elements) { + final List currentItems = getItems(); + elements = ContainerUtil.filter(elements, + locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale)); + super.add(elements); + } + }; + localesToAddList.setModel(myLocalesModel); + localesToAddList.setCellRenderer(getLocaleRenderer()); + localesToAddList.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + projectExistLocalesList.clearSelection(); + } + }); + projectExistLocalesList.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + localesToAddList.clearSelection(); + } + }); + + myNewBundleLocalesPanel = ToolbarDecorator.createDecorator(localesToAddList).setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final String rawAddedLocales = Messages.showInputDialog(myProject, + PropertiesBundle.message( + "create.resource.bundle.dialog.add.locales.validator.message"), + PropertiesBundle.message( + "create.resource.bundle.dialog.add.locales.validator.title"), + null, null, new InputValidatorEx() { + @Override + public @Nullable String getErrorText(String inputString) { + return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); + } + + @Override + public boolean checkInput(String inputString) { + return extractLocalesFromString(inputString) != null; + } + + @Override + public boolean canClose(String inputString) { + return checkInput(inputString); + } + }); + if (rawAddedLocales != null) { + final Map locales = extractLocalesFromString(rawAddedLocales); + LOG.assertTrue(locales != null); + myLocaleSuffixes.putAll(locales); + myLocalesModel.add(new ArrayList<>(locales.keySet())); + } + } + }).setAddActionName(PropertiesBundle.message("create.resource.bundle.add.locales.by.suffix.action.text")) + .disableUpDownActions().createPanel(); + myNewBundleLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( + PropertiesBundle.message("create.resource.bundle.locales.to.add.chooser.title"), false)); + + myAddLocaleFromExistButton = new JButton(AllIcons.Actions.Forward); + new ClickListener() { + @Override + public boolean onClick(@NotNull MouseEvent event, int clickCount) { + if (clickCount == 1) { + myLocalesModel.add(projectExistLocalesList.getSelectedValuesList()); + return true; + } + return false; + } + }.installOn(myAddLocaleFromExistButton); + + projectExistLocalesList.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + final List currentItems = myLocalesModel.getItems(); + for (Locale l : projectExistLocalesList.getSelectedValuesList()) { + if (!restrictedLocales.contains(l) && !currentItems.contains(l)) { + myAddLocaleFromExistButton.setEnabled(true); + return; + } + } + myAddLocaleFromExistButton.setEnabled(false); + } + }); + myAddLocaleFromExistButton.setEnabled(false); + + myAddAllButton = new JButton(PropertiesBundle.message("create.resource.bundle.add.all.btn.text")); + new ClickListener() { + @Override + public boolean onClick(@NotNull MouseEvent event, int clickCount) { + if (clickCount == 1) { + myLocalesModel.add(existLocalesListModel.getLocales()); + } + return false; + } + }.installOn(myAddAllButton); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + myResourceBundleNamePanel = new JPanel(); + myResourceBundleNamePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myResourceBundleNamePanel, BorderLayout.NORTH); + myResourceBundleBaseNameTextField = new JTextField(); + myResourceBundleNamePanel.add(myResourceBundleBaseNameTextField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", "label.resource.bundle.base.name")); + myResourceBundleNamePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myUseXMLBasedPropertiesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseXMLBasedPropertiesCheckBox, + this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", "checkbox.use.xml.based.properties.files")); + myResourceBundleNamePanel.add(myUseXMLBasedPropertiesCheckBox, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, BorderLayout.CENTER); + myAddLocaleFromExistButton.setFocusable(false); + myAddLocaleFromExistButton.setText(""); + panel1.add(myAddLocaleFromExistButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + panel1.add(myNewBundleLocalesPanel, new GridConstraints(0, 2, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + panel1.add(myProjectExistLocalesPanel, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myAddAllButton.setFocusable(false); + this.$$$loadButtonText$$$(myAddAllButton, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", "button.add.all")); + panel1.add(myAddAllButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myLocaleSuffixes = new HashMap<>(); if (resourceBundle != null) { myResourceBundleNamePanel.setVisible(false); myUseXMLBasedPropertiesCheckBox.setVisible(false); - } else { + } + else { final String checkBoxSelectedStateKey = getClass() + ".useXmlPropertiesFiles"; myUseXMLBasedPropertiesCheckBox.setSelected(PropertiesComponent.getInstance().getBoolean(checkBoxSelectedStateKey)); myUseXMLBasedPropertiesCheckBox.addContainerListener(new ContainerAdapter() { @@ -120,6 +301,78 @@ public final class CreateResourceBundleDialogComponent { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + java.util.ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (java.util.ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = java.util.ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public static class Dialog extends DialogWrapper { private final @NotNull PsiDirectory myDirectory; private final CreateResourceBundleDialogComponent myComponent; @@ -136,7 +389,8 @@ public final class CreateResourceBundleDialogComponent { initValidation(); setTitle(resourceBundle == null ? PropertiesBundle.message("create.resource.bundle.action.text") : PropertiesBundle - .message("create.resource.bundle.add.locales.to.resource.bundle.title", resourceBundle.getBaseName())); + .message("create.resource.bundle.add.locales.to.resource.bundle.title", + resourceBundle.getBaseName())); } @Override @@ -144,7 +398,8 @@ public final class CreateResourceBundleDialogComponent { final String errorString = myComponent.canCreateAllFilesForAllLocales(); if (errorString != null) { Messages.showErrorDialog(getContentPanel(), errorString); - } else { + } + else { final List createFiles = myComponent.createPropertiesFiles(); myCreatedFiles = createFiles.toArray(PsiElement.EMPTY_ARRAY); super.doOKAction(); @@ -157,7 +412,8 @@ public final class CreateResourceBundleDialogComponent { if (!PathUtil.isValidFileName(fileName)) { return new ValidationInfo( PropertiesBundle.message("create.resource.bundle.file.name.for.properties.file.0.is.invalid.error", fileName)); - } else { + } + else { if (myDirectory.findFile(fileName) != null) { return new ValidationInfo(PropertiesBundle.message("create.resource.bundle.file.with.name.0.already.exist.error", fileName)); } @@ -185,22 +441,27 @@ public final class CreateResourceBundleDialogComponent { private List createPropertiesFiles() { final Set fileNames = getFileNamesToCreate(); final List createdFiles = WriteCommandAction.runWriteCommandAction(myProject, - (Computable>)() -> ReadAction.compute(() -> ContainerUtil.map(fileNames, n -> { - final boolean isXml = myResourceBundle == null - ? myUseXMLBasedPropertiesCheckBox.isSelected() - : myResourceBundle.getDefaultPropertiesFile() instanceof XmlPropertiesFile; - if (isXml) { - FileTemplate template = FileTemplateManager.getInstance(myProject).getInternalTemplate("XML Properties File.xml"); - try { - return (PsiFile)FileTemplateUtil.createFromTemplate(template, n, null, myDirectory); + (Computable>)() -> ReadAction.compute( + () -> ContainerUtil.map(fileNames, n -> { + final boolean isXml = myResourceBundle == null + ? myUseXMLBasedPropertiesCheckBox.isSelected() + : myResourceBundle.getDefaultPropertiesFile() instanceof XmlPropertiesFile; + if (isXml) { + FileTemplate template = + FileTemplateManager.getInstance(myProject) + .getInternalTemplate("XML Properties File.xml"); + try { + return (PsiFile)FileTemplateUtil.createFromTemplate( + template, n, null, myDirectory); + } + catch (Exception e) { + throw new RuntimeException(e); + } } - catch (Exception e) { - throw new RuntimeException(e); + else { + return myDirectory.createFile(n); } - } else { - return myDirectory.createFile(n); - } - }))); + }))); combineToResourceBundleIfNeeded(createdFiles); return createdFiles; } @@ -209,8 +470,11 @@ public final class CreateResourceBundleDialogComponent { final String name = getBaseName(); final String suffix = getPropertiesFileSuffix(); return ContainerUtil.map2Set(myLocalesModel.getItems(), - locale -> name + (locale == PropertiesUtil.DEFAULT_LOCALE ? "" : ("_" + myLocaleSuffixes - .getOrDefault(locale, locale.toString()))) + suffix); + locale -> name + + (locale == PropertiesUtil.DEFAULT_LOCALE ? "" : ("_" + myLocaleSuffixes + .getOrDefault(locale, + locale.toString()))) + + suffix); } private void combineToResourceBundleIfNeeded(Collection files) { @@ -305,127 +569,6 @@ public final class CreateResourceBundleDialogComponent { return locales; } - @SuppressWarnings("unchecked") - private void createUIComponents() { - final JBList projectExistLocalesList = new JBList<>(); - final MyExistLocalesListModel existLocalesListModel = new MyExistLocalesListModel(); - projectExistLocalesList.setModel(existLocalesListModel); - projectExistLocalesList.setCellRenderer(getLocaleRenderer()); - myProjectExistLocalesPanel = ToolbarDecorator.createDecorator(projectExistLocalesList) - .disableRemoveAction() - .disableUpDownActions() - .createPanel(); - myProjectExistLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( - PropertiesBundle.message("create.resource.bundle.project.locales.title"), false)); - - final JBList localesToAddList = new JBList(); - - final List locales; - final List restrictedLocales; - if (myResourceBundle == null) { - locales = Collections.singletonList(PropertiesUtil.DEFAULT_LOCALE); - restrictedLocales = Collections.emptyList(); - } else { - locales = Collections.emptyList(); - restrictedLocales = ContainerUtil.map(myResourceBundle.getPropertiesFiles(), PropertiesFile::getLocale); - } - myLocalesModel = new CollectionListModel<>(locales) { - @Override - public void add(@NotNull List elements) { - final List currentItems = getItems(); - elements = ContainerUtil.filter(elements, - locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale)); - super.add(elements); - } - }; - localesToAddList.setModel(myLocalesModel); - localesToAddList.setCellRenderer(getLocaleRenderer()); - localesToAddList.addFocusListener(new FocusAdapter() { - @Override - public void focusGained(FocusEvent e) { - projectExistLocalesList.clearSelection(); - } - }); - projectExistLocalesList.addFocusListener(new FocusAdapter() { - @Override - public void focusGained(FocusEvent e) { - localesToAddList.clearSelection(); - } - }); - - myNewBundleLocalesPanel = ToolbarDecorator.createDecorator(localesToAddList).setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - final String rawAddedLocales = Messages.showInputDialog(myProject, - PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.message"), - PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.title"), - null, null, new InputValidatorEx() { - @Override - public @Nullable String getErrorText(String inputString) { - return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); - } - - @Override - public boolean checkInput(String inputString) { - return extractLocalesFromString(inputString) != null; - } - - @Override - public boolean canClose(String inputString) { - return checkInput(inputString); - } - }); - if (rawAddedLocales != null) { - final Map locales = extractLocalesFromString(rawAddedLocales); - LOG.assertTrue(locales != null); - myLocaleSuffixes.putAll(locales); - myLocalesModel.add(new ArrayList<>(locales.keySet())); - } - } - }).setAddActionName(PropertiesBundle.message("create.resource.bundle.add.locales.by.suffix.action.text")) - .disableUpDownActions().createPanel(); - myNewBundleLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( - PropertiesBundle.message("create.resource.bundle.locales.to.add.chooser.title"), false)); - - myAddLocaleFromExistButton = new JButton(AllIcons.Actions.Forward); - new ClickListener(){ - @Override - public boolean onClick(@NotNull MouseEvent event, int clickCount) { - if (clickCount == 1) { - myLocalesModel.add(projectExistLocalesList.getSelectedValuesList()); - return true; - } - return false; - } - }.installOn(myAddLocaleFromExistButton); - - projectExistLocalesList.addListSelectionListener(new ListSelectionListener() { - @Override - public void valueChanged(ListSelectionEvent e) { - final List currentItems = myLocalesModel.getItems(); - for (Locale l : projectExistLocalesList.getSelectedValuesList()) { - if (!restrictedLocales.contains(l) && !currentItems.contains(l)) { - myAddLocaleFromExistButton.setEnabled(true); - return; - } - } - myAddLocaleFromExistButton.setEnabled(false); - } - }); - myAddLocaleFromExistButton.setEnabled(false); - - myAddAllButton = new JButton(PropertiesBundle.message("create.resource.bundle.add.all.btn.text")); - new ClickListener() { - @Override - public boolean onClick(@NotNull MouseEvent event, int clickCount) { - if (clickCount == 1) { - myLocalesModel.add(existLocalesListModel.getLocales()); - } - return false; - } - }.installOn(myAddAllButton); - } - private @NotNull ColoredListCellRenderer getLocaleRenderer() { return new ColoredListCellRenderer<>() { @Override @@ -450,7 +593,8 @@ public final class CreateResourceBundleDialogComponent { PropertiesReferenceManager.getInstance(myProject).processPropertiesFiles(GlobalSearchScope.projectScope(myProject), (baseName, propertiesFile) -> { final Locale locale = propertiesFile.getLocale(); - if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) { + if (locale != PropertiesUtil.DEFAULT_LOCALE && + !myLocales.contains(locale)) { myLocales.add(locale); } return true; @@ -478,7 +622,8 @@ public final class CreateResourceBundleDialogComponent { for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { if (containingDirectory == null) { containingDirectory = propertiesFile.getContainingFile().getContainingDirectory(); - } else if (!containingDirectory.isEquivalentTo(propertiesFile.getContainingFile().getContainingDirectory())) { + } + else if (!containingDirectory.isEquivalentTo(propertiesFile.getContainingFile().getContainingDirectory())) { return null; } } diff --git a/plugins/properties/src/com/intellij/lang/properties/references/I18nizeQuickFixDialog.java b/plugins/properties/src/com/intellij/lang/properties/references/I18nizeQuickFixDialog.java index 8e42ef3b4634..8b9b6c052000 100644 --- a/plugins/properties/src/com/intellij/lang/properties/references/I18nizeQuickFixDialog.java +++ b/plugins/properties/src/com/intellij/lang/properties/references/I18nizeQuickFixDialog.java @@ -44,8 +44,11 @@ import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.ComboboxSpeedSearch; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.GuiUtils; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TextFieldWithHistory; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.concurrency.annotations.RequiresBackgroundThread; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; @@ -53,18 +56,25 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import java.text.Normalizer; import java.util.ArrayList; import java.util.Collection; @@ -72,6 +82,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; import java.util.Set; import java.util.regex.Pattern; @@ -80,21 +91,21 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick private static final Pattern PATTERN = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); - private JTextField myValue; - private JTextField myKey; + private final JTextField myValue; + private final JTextField myKey; private final TextFieldWithHistory myPropertiesFile; - protected JPanel myPanel; - private JCheckBox myUseResourceBundle; + protected final JPanel myPanel; + private final JCheckBox myUseResourceBundle; protected final Project myProject; protected final PsiFile myContext; protected final Set myContextModules; - private JPanel myPropertiesFilePanel; - protected JPanel myExtensibilityPanel; - private ComboBox myExistingProperties; - private JBRadioButton myCreateNewPropertyRb; - private JPanel myNewPanel; - private JBRadioButton myUseExistingPropertyRb; + private final JPanel myPropertiesFilePanel; + protected final JPanel myExtensibilityPanel; + private final ComboBox myExistingProperties; + private final JBRadioButton myCreateNewPropertyRb; + private final JPanel myNewPanel; + private final JBRadioButton myUseExistingPropertyRb; protected final String myDefaultPropertyValue; protected final DialogCustomization myCustomization; @@ -129,7 +140,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick final @NotNull PsiFile context, @NotNull String defaultPropertyValue, DialogCustomization customization - ) { + ) { this(project, context, defaultPropertyValue, customization, false); } @@ -140,11 +151,100 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick boolean ancestorResponsible) { super(false); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setMinimumSize(new Dimension(-1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 2, new Insets(5, 5, 5, 5), 4, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", + "i18n.quickfix.property.panel.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myNewPanel = new JPanel(); + myNewPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(myNewPanel, new GridConstraints(1, 0, 4, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 2, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", + "i18n.quickfix.property.panel.property.key.label")); + myNewPanel.add(label1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", + "i18n.quickfix.property.panel.property.value.label")); + myNewPanel.add(label2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myValue = new JTextField(); + myNewPanel.add(myValue, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", + "i18n.quickfix.property.panel.properties.file.label")); + myNewPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myPropertiesFilePanel = new JPanel(); + myPropertiesFilePanel.setLayout(new BorderLayout(0, 0)); + myNewPanel.add(myPropertiesFilePanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseResourceBundle = new JCheckBox(); + this.$$$loadButtonText$$$(myUseResourceBundle, this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", + "i18n.quickfix.property.panel.update.all.files.in.bundle.checkbox")); + myNewPanel.add(myUseResourceBundle, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKey = new JTextField(); + myKey.setEditable(true); + myNewPanel.add(myKey, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false)); + myCreateNewPropertyRb = new JBRadioButton(); + myCreateNewPropertyRb.setSelected(true); + this.$$$loadButtonText$$$(myCreateNewPropertyRb, + this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", "radio.button.create.new.property")); + panel1.add(myCreateNewPropertyRb, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseExistingPropertyRb = new JBRadioButton(); + this.$$$loadButtonText$$$(myUseExistingPropertyRb, + this.$$$getMessageFromBundle$$$("messages/PropertiesBundle", "radio.button.use.existing.property")); + panel1.add(myUseExistingPropertyRb, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myExistingProperties = new ComboBox(); + panel1.add(myExistingProperties, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myExtensibilityPanel = new JPanel(); + myExtensibilityPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myExtensibilityPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + label1.setLabelFor(myKey); + label2.setLabelFor(myValue); + label3.setLabelFor(myPropertiesFilePanel); + } myContext = FileContextUtil.getContextFile(context); myContextModules = ContainerUtil.createMaybeSingletonSet(ModuleUtilCore.findModuleForFile(myContext)); myDefaultPropertyValue = escapeValue(defaultPropertyValue, context); - myCustomization = customization != null ? customization:new DialogCustomization(); + myCustomization = customization != null ? customization : new DialogCustomization(); setTitle(myCustomization.title != null ? myCustomization.title : PropertiesBundle.message("i18nize.dialog.title")); myPropertiesFile = new TextFieldWithHistory(); @@ -158,7 +258,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick TreeFileChooserFactory chooserFactory = TreeFileChooserFactory.getInstance(myProject); final PropertiesFile propertiesFile = getPropertiesFile(); TreeFileChooser fileChooser = chooserFactory.createFileChooser( - PropertiesBundle.message("i18nize.dialog.property.file.chooser.title"), + PropertiesBundle.message("i18nize.dialog.property.file.chooser.title"), propertiesFile != null ? propertiesFile.getContainingFile() : null, PropertiesFileType.INSTANCE, null); fileChooser.showDialog(); PsiFile selectedFile = fileChooser.getSelectedFile(); @@ -202,7 +302,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick PropertiesComponent.getInstance().setValue(KEY, Boolean.valueOf(myUseResourceBundle.isSelected()).toString()); } }); - + myExistingProperties.setRenderer(new ColoredListCellRenderer<>() { @Override protected void customizeCellRenderer(@NotNull JList list, @@ -225,7 +325,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick somethingChanged(); } }); - + ButtonGroup bg = new ButtonGroup(); bg.add(myCreateNewPropertyRb); bg.add(myUseExistingPropertyRb); @@ -240,10 +340,82 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick myCreateNewPropertyRb.addActionListener(listener); myUseExistingPropertyRb.addActionListener(listener); myExistingProperties.setEnabled(false); - + if (!ancestorResponsible) init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + protected String escapeValue(String value, @NotNull PsiFile context) { return value; } @@ -263,7 +435,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick } protected @NotNull List getExistingProperties(String value) { - if(!myCustomization.suggestExistingProperties) { + if (!myCustomization.suggestExistingProperties) { return Collections.emptyList(); } final ArrayList result = new ArrayList<>(); @@ -487,7 +659,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick } return false; } - + private boolean createPropertiesFileIfNotExists() { if (getPropertiesFile() != null) return true; final String path = getPropertiesFilePath(); @@ -541,7 +713,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick @Override public JComponent getPreferredFocusedComponent() { - return myCustomization.focusValueComponent ? myValue:myKey; + return myCustomization.focusValueComponent ? myValue : myKey; } @Override @@ -564,7 +736,8 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick PropertiesBundle.message("i18nize.dialog.searching.for.already.existing.properties"), true, myProject ); - } catch (ProcessCanceledException e) { + } + catch (ProcessCanceledException e) { super.doOKAction(); return; } @@ -573,7 +746,8 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick IProperty existingProperty = existingProperties.get(propertiesFile); final String propValue = getValue(); if (existingProperty != null && !Comparing.strEqual(existingProperty.getUnescapedValue(), propValue)) { - final String messageText = PropertiesBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName()); + final String messageText = + PropertiesBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName()); final boolean code = MessageDialogBuilder .yesNo(PropertiesBundle.message("i18nize.dialog.error.property.already.defined.title"), messageText) .ask(myProject); diff --git a/plugins/rareJavaRefactorings/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java b/plugins/rareJavaRefactorings/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java index c117df541f10..d14be1975638 100644 --- a/plugins/rareJavaRefactorings/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java +++ b/plugins/rareJavaRefactorings/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java @@ -32,51 +32,297 @@ import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; class WrapReturnValueDialog extends RefactoringDialog { private final PsiMethod sourceMethod; - private JTextField sourceMethodTextField; + private final JTextField sourceMethodTextField; - private JRadioButton createNewClassButton; - private JTextField classNameField; - private PackageNameReferenceEditorCombo packageTextField; - private JPanel myNewClassPanel; + private final JRadioButton createNewClassButton; + private final JTextField classNameField; + private final PackageNameReferenceEditorCombo packageTextField; + private final JPanel myNewClassPanel; - private ReferenceEditorComboWithBrowseButton existingClassField; - private JRadioButton useExistingClassButton; - private JComboBox myFieldsCombo; - private JPanel myExistingClassPanel; + private final ReferenceEditorComboWithBrowseButton existingClassField; + private final JRadioButton useExistingClassButton; + private final JComboBox myFieldsCombo; + private final JPanel myExistingClassPanel; - private JPanel myWholePanel; + private final JPanel myWholePanel; - private JRadioButton myCreateInnerClassButton; - private JTextField myInnerClassNameTextField; - private JPanel myCreateInnerPanel; - private ComboboxWithBrowseButton myDestinationCb; + private final JRadioButton myCreateInnerClassButton; + private final JTextField myInnerClassNameTextField; + private final JPanel myCreateInnerPanel; + private final ComboboxWithBrowseButton myDestinationCb; private static final String RECENT_KEYS = "WrapReturnValue.RECENT_KEYS"; WrapReturnValueDialog(PsiMethod sourceMethod) { super(sourceMethod.getProject(), true); this.sourceMethod = sourceMethod; + { + final com.intellij.openapi.editor.event.DocumentListener adapter = new com.intellij.openapi.editor.event.DocumentListener() { + @Override + public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { + validateButtons(); + } + }; + + packageTextField = + new PackageNameReferenceEditorCombo("", myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package")); + packageTextField.getChildComponent().getDocument().addDocumentListener(adapter); + + existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) + .createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), + null, null); + final String classText = existingClassField.getText(); + final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); + if (currentClass != null) { + chooser.select(currentClass); + } + chooser.showDialog(); + final PsiClass selectedClass = chooser.getSelected(); + if (selectedClass != null) { + existingClassField.setText(selectedClass.getQualifiedName()); + } + } + }, "", myProject, true, RECENT_KEYS); + existingClassField.getChildComponent().getDocument().addDocumentListener(adapter); + + myDestinationCb = new DestinationFolderComboBox() { + @Override + public String getTargetPackage() { + return getPackageName(); + } + }; + ((DestinationFolderComboBox)myDestinationCb).setData(myProject, sourceMethod.getContainingFile().getContainingDirectory(), + packageTextField.getChildComponent()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1)); + createNewClassButton = new JRadioButton(); + this.$$$loadButtonText$$$(createNewClassButton, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.create.new.class")); + myWholePanel.add(createNewClassButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + useExistingClassButton = new JRadioButton(); + this.$$$loadButtonText$$$(useExistingClassButton, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.use.existing.class")); + myWholePanel.add(useExistingClassButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myNewClassPanel = new JPanel(); + myNewClassPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myNewClassPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.new.class.name")); + myNewClassPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + classNameField = new JTextField(); + myNewClassPanel.add(classNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", + "wrap.return.value.new.class.package.name")); + myNewClassPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myNewClassPanel.add(packageTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "target.destination.folder")); + myNewClassPanel.add(label3, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myNewClassPanel.add(myDestinationCb, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myExistingClassPanel = new JPanel(); + myExistingClassPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myExistingClassPanel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.existing.class.name")); + myExistingClassPanel.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myExistingClassPanel.add(existingClassField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myFieldsCombo = new JComboBox(); + myExistingClassPanel.add(myFieldsCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.wrapper.field")); + myExistingClassPanel.add(label5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + sourceMethodTextField = new JTextField(); + myWholePanel.add(sourceMethodTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(400, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, + this.$$$getMessageFromBundle$$$("messages/JavaRareRefactoringsBundle", "method.to.wrap.returns.from.label")); + myWholePanel.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myCreateInnerClassButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCreateInnerClassButton, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.create.inner.class")); + myWholePanel.add(myCreateInnerClassButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCreateInnerPanel = new JPanel(); + myCreateInnerPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 20, 0, 0), -1, -1)); + myWholePanel.add(myCreateInnerPanel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, + this.$$$getMessageFromBundle$$$("messages/JavaRefactoringBundle", "wrap.return.value.inner.class.name")); + myCreateInnerPanel.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myInnerClassNameTextField = new JTextField(); + myCreateInnerPanel.add(myInnerClassNameTextField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(classNameField); + label3.setLabelFor(myDestinationCb); + label4.setLabelFor(myFieldsCombo); + label5.setLabelFor(myFieldsCombo); + label7.setLabelFor(myInnerClassNameTextField); + } setTitle(JavaRareRefactoringsBundle.message("wrap.return.value.title")); init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + @Override protected String getDimensionServiceKey() { return "RefactorJ.WrapReturnValue"; @@ -102,7 +348,8 @@ class WrapReturnValueDialog extends RefactoringDialog { packageName = getPackageName(); } invokeRefactoring( - new WrapReturnValueProcessor(className, packageName, ((DestinationFolderComboBox)myDestinationCb).selectDirectory(new PackageWrapper(sourceMethod.getManager(), packageName), false), + new WrapReturnValueProcessor(className, packageName, ((DestinationFolderComboBox)myDestinationCb).selectDirectory( + new PackageWrapper(sourceMethod.getManager(), packageName), false), sourceMethod, useExistingClass, createInnerClass, (PsiField)myFieldsCombo.getSelectedItem())); } @@ -112,22 +359,28 @@ class WrapReturnValueDialog extends RefactoringDialog { final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project); if (myCreateInnerClassButton.isSelected()) { final String innerClassName = getInnerClassName().trim(); - if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException( - JavaRareRefactoringsBundle.message("dialog.message.invalid.inner.class.name", innerClassName)); + if (!nameHelper.isIdentifier(innerClassName)) { + throw new ConfigurationException( + JavaRareRefactoringsBundle.message("dialog.message.invalid.inner.class.name", innerClassName)); + } final PsiClass containingClass = sourceMethod.getContainingClass(); if (containingClass != null && containingClass.findInnerClassByName(innerClassName, false) != null) { - throw new ConfigurationException(JavaRareRefactoringsBundle.message("dialog.message.inner.class.with.name.already.exist", innerClassName)); + throw new ConfigurationException( + JavaRareRefactoringsBundle.message("dialog.message.inner.class.with.name.already.exist", innerClassName)); } - } else if (useExistingClassButton.isSelected()) { + } + else if (useExistingClassButton.isSelected()) { final String className = existingClassField.getText().trim(); if (className.isEmpty() || !nameHelper.isQualifiedName(className)) { - throw new ConfigurationException(JavaRareRefactoringsBundle.message("dialog.message.invalid.qualified.wrapper.class.name", className)); + throw new ConfigurationException( + JavaRareRefactoringsBundle.message("dialog.message.invalid.qualified.wrapper.class.name", className)); } final Object item = myFieldsCombo.getSelectedItem(); if (item == null) { throw new ConfigurationException(JavaRareRefactoringsBundle.message("dialog.message.wrapper.field.not.found")); } - } else { + } + else { final String className = getClassName(); if (className.isEmpty() || !nameHelper.isIdentifier(className)) { throw new ConfigurationException(JavaRareRefactoringsBundle.message("dialog.message.invalid.wrapper.class.name", className)); @@ -135,7 +388,8 @@ class WrapReturnValueDialog extends RefactoringDialog { final String packageName = getPackageName(); if (packageName.isEmpty() || !nameHelper.isQualifiedName(packageName)) { - throw new ConfigurationException(JavaRareRefactoringsBundle.message("dialog.message.invalid.wrapper.class.package.name", packageName)); + throw new ConfigurationException( + JavaRareRefactoringsBundle.message("dialog.message.invalid.wrapper.class.package.name", packageName)); } } } @@ -263,44 +517,4 @@ class WrapReturnValueDialog extends RefactoringDialog { protected String getHelpId() { return HelpID.WrapReturnValue; } - - private void createUIComponents() { - final com.intellij.openapi.editor.event.DocumentListener adapter = new com.intellij.openapi.editor.event.DocumentListener() { - @Override - public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { - validateButtons(); - } - }; - - packageTextField = - new PackageNameReferenceEditorCombo("", myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package")); - packageTextField.getChildComponent().getDocument().addDocumentListener(adapter); - - existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) - .createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), null, null); - final String classText = existingClassField.getText(); - final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); - if (currentClass != null) { - chooser.select(currentClass); - } - chooser.showDialog(); - final PsiClass selectedClass = chooser.getSelected(); - if (selectedClass != null) { - existingClassField.setText(selectedClass.getQualifiedName()); - } - } - }, "", myProject, true, RECENT_KEYS); - existingClassField.getChildComponent().getDocument().addDocumentListener(adapter); - - myDestinationCb = new DestinationFolderComboBox() { - @Override - public String getTargetPackage() { - return getPackageName(); - } - }; - ((DestinationFolderComboBox)myDestinationCb).setData(myProject, sourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent()); - } } \ No newline at end of file diff --git a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckOptionsPanel.java b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckOptionsPanel.java index c94ebb0a6cf5..5494af6cd803 100644 --- a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckOptionsPanel.java +++ b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckOptionsPanel.java @@ -16,26 +16,37 @@ import com.intellij.ui.DocumentAdapter; import com.intellij.ui.EditorNotifications; import com.intellij.ui.JBColor; import com.intellij.ui.components.ActionLink; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import java.util.Set; import java.util.function.BiConsumer; public class ShellcheckOptionsPanel { - private JPanel myPanel; - private JPanel myWarningPanel; - private JLabel myWarningLabel; - private JLabel myErrorLabel; + private final JPanel myPanel; + private final JPanel myWarningPanel; + private final JLabel myWarningLabel; + private final JLabel myErrorLabel; @SuppressWarnings("unused") - private ActionLink myShellcheckDownloadLink; - private TextFieldWithBrowseButton myShellcheckSelector; - private MultipleCheckboxOptionsPanel myInspectionsCheckboxPanel; + private final ActionLink myShellcheckDownloadLink; + private final TextFieldWithBrowseButton myShellcheckSelector; + private final MultipleCheckboxOptionsPanel myInspectionsCheckboxPanel; private final BiConsumer myInspectionsChangeListener; private final Set myDisabledInspections; private final Project myProject; @@ -44,6 +55,82 @@ public class ShellcheckOptionsPanel { public ShellcheckOptionsPanel(Set disabledInspections, BiConsumer inspectionsChangeListener) { myInspectionsChangeListener = inspectionsChangeListener; myDisabledInspections = disabledInspections; + { + myShellcheckDownloadLink = new ActionLink(ShBundle.message("sh.shellcheck.download.label.text"), e -> { + ShShellcheckUtil.download(myProject, + () -> myShellcheckSelector.setText(ShSettings.getShellcheckPath(myProject)), + () -> myErrorLabel.setVisible(true)); + EditorNotifications.getInstance(myProject).updateAllNotifications(); + }); + + myInspectionsCheckboxPanel = new MultipleCheckboxOptionsPanel(new OptionAccessor() { + @Override + public boolean getOption(String optionName) { + return myDisabledInspections.contains(optionName); + } + + @Override + public void setOption(String optionName, boolean optionValue) { + myInspectionsChangeListener.accept(optionName, optionValue); + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 5), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.path.label")); + label1.setVerticalAlignment(0); + label1.setVerticalTextPosition(0); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShellcheckSelector = new TextFieldWithBrowseButton(); + myPanel.add(myShellcheckSelector, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myWarningPanel = new JPanel(); + myWarningPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + myWarningPanel.setEnabled(true); + myWarningPanel.setVisible(false); + myPanel.add(myWarningPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myWarningLabel = new JLabel(); + this.$$$loadLabelText$$$(myWarningLabel, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.invalid.path")); + myWarningPanel.add(myWarningLabel); + this.$$$loadButtonText$$$(myShellcheckDownloadLink, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.download")); + myWarningPanel.add(myShellcheckDownloadLink); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.shellcheck.missing")); + myWarningPanel.add(label2); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBScrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBScrollPane1.setViewportView(panel1); + panel1.add(myInspectionsCheckboxPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + myErrorLabel = new JBLabel(); + this.$$$loadLabelText$$$(myErrorLabel, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.shellcheck.cannot.download")); + myErrorLabel.setVisible(false); + myPanel.add(myErrorLabel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, + false)); + } myProject = ProjectUtil.getProject(getPanel()); myShellcheckSelector.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFileDescriptor() @@ -68,27 +155,78 @@ public class ShellcheckOptionsPanel { myWarningLabel.setIcon(AllIcons.General.Warning); } - private void createUIComponents() { - myShellcheckDownloadLink = new ActionLink(ShBundle.message("sh.shellcheck.download.label.text"), e -> { - ShShellcheckUtil.download(myProject, - () -> myShellcheckSelector.setText(ShSettings.getShellcheckPath(myProject)), - () -> myErrorLabel.setVisible(true)); - EditorNotifications.getInstance(myProject).updateAllNotifications(); - }); + private static Method $$$cachedGetBundleMethod$$$ = null; - myInspectionsCheckboxPanel = new MultipleCheckboxOptionsPanel(new OptionAccessor() { - @Override - public boolean getOption(String optionName) { - return myDisabledInspections.contains(optionName); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); } - - @Override - public void setOption(String optionName, boolean optionValue) { - myInspectionsChangeListener.accept(optionName, optionValue); - } - }); + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @ApiStatus.Internal public JComponent getPanel() { return myPanel; diff --git a/plugins/sh/core/src/com/intellij/sh/codeStyle/ShCodeStylePanel.java b/plugins/sh/core/src/com/intellij/sh/codeStyle/ShCodeStylePanel.java index cd5d55433d3d..48cee830fd3a 100644 --- a/plugins/sh/core/src/com/intellij/sh/codeStyle/ShCodeStylePanel.java +++ b/plugins/sh/core/src/com/intellij/sh/codeStyle/ShCodeStylePanel.java @@ -23,48 +23,227 @@ import com.intellij.sh.settings.ShSettings; import com.intellij.sh.utils.ProjectUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.JBColor; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.ActionLink; +import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.fields.IntegerField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ShCodeStylePanel extends CodeStyleAbstractPanel { - private JPanel myPanel; - private JPanel myRightPanel; - private JPanel myWarningPanel; + private final JPanel myPanel; + private final JPanel myRightPanel; + private final JPanel myWarningPanel; - private JCheckBox myTabCharacter; - private IntegerField myIndentField; - private IntegerField myTabField; - private JLabel myWarningLabel; - private JLabel myErrorLabel; + private final JCheckBox myTabCharacter; + private final IntegerField myIndentField; + private final IntegerField myTabField; + private final JLabel myWarningLabel; + private final JLabel myErrorLabel; - private JCheckBox myBinaryOpsStartLine; - private JCheckBox mySwitchCasesIndented; - private JCheckBox myRedirectFollowedBySpace; - private JCheckBox myKeepColumnAlignmentPadding; - private JCheckBox myMinifyProgram; - private JCheckBox myUnixLineSeparator; + private final JCheckBox myBinaryOpsStartLine; + private final JCheckBox mySwitchCasesIndented; + private final JCheckBox myRedirectFollowedBySpace; + private final JCheckBox myKeepColumnAlignmentPadding; + private final JCheckBox myMinifyProgram; + private final JCheckBox myUnixLineSeparator; private final Project myProject; @SuppressWarnings("unused") - private ActionLink myShfmtDownloadLink; - private TextFieldWithBrowseButton myShfmtPathSelector; + private final ActionLink myShfmtDownloadLink; + private final TextFieldWithBrowseButton myShfmtPathSelector; ShCodeStylePanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) { super(ShLanguage.INSTANCE, currentSettings, settings); + { + myIndentField = new IntegerField(null, CodeStyleConstraints.MIN_INDENT_SIZE, CodeStyleConstraints.MAX_INDENT_SIZE); + myTabField = new IntegerField(null, CodeStyleConstraints.MIN_TAB_SIZE, CodeStyleConstraints.MAX_TAB_SIZE); + myShfmtDownloadLink = new ActionLink(ShBundle.message("sh.code.style.download.link"), e -> { + ShFormatterDownloader.getInstance().download(myProject, + () -> myShfmtPathSelector.setText(ShSettings.getShfmtPath(myProject)), + () -> myErrorLabel.setVisible(true)); + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1)); + myPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.fmt.formatter")); + panel1.add(titledSeparator1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel2.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + jBScrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(8, 1, new Insets(10, 10, 10, 10), -1, -1)); + jBScrollPane1.setViewportView(panel3); + myBinaryOpsStartLine = new JCheckBox(); + panel3.add(myBinaryOpsStartLine, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySwitchCasesIndented = new JCheckBox(); + panel3.add(mySwitchCasesIndented, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRedirectFollowedBySpace = new JCheckBox(); + panel3.add(myRedirectFollowedBySpace, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepColumnAlignmentPadding = new JCheckBox(); + panel3.add(myKeepColumnAlignmentPadding, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myMinifyProgram = new JCheckBox(); + panel3.add(myMinifyProgram, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 100), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 2, new Insets(10, 0, 0, 0), 30, -1)); + panel3.add(panel4, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "editbox.indent.indent")); + panel4.add(label1, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel4.add(myIndentField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myTabCharacter = new JCheckBox(); + this.$$$loadButtonText$$$(myTabCharacter, + this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "checkbox.indent.use.tab.character")); + panel4.add(myTabCharacter, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator2 = new TitledSeparator(); + titledSeparator2.setText(this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.fmt.indent.label")); + panel4.add(titledSeparator2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "editbox.indent.tab.size")); + panel4.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel4.add(myTabField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUnixLineSeparator = new JBCheckBox(); + panel3.add(myUnixLineSeparator, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myRightPanel = new JPanel(); + myRightPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(myRightPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(-1, 0), null, 0, false)); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + myPanel.add(jBScrollPane2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBScrollPane2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 2, new Insets(0, 10, 0, 10), 30, -1)); + jBScrollPane2.setViewportView(panel5); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.path.label")); + panel5.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShfmtPathSelector = new TextFieldWithBrowseButton(); + panel5.add(myShfmtPathSelector, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myWarningPanel = new JPanel(); + myWarningPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + myWarningPanel.setEnabled(true); + myWarningPanel.setVisible(false); + panel5.add(myWarningPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myWarningLabel = new JLabel(); + this.$$$loadLabelText$$$(myWarningLabel, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.invalid.path")); + myWarningPanel.add(myWarningLabel); + myShfmtDownloadLink.setHorizontalTextPosition(0); + this.$$$loadButtonText$$$(myShfmtDownloadLink, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.download")); + myWarningPanel.add(myShfmtDownloadLink); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.fmt.missing.formatter")); + myWarningPanel.add(label4); + myErrorLabel = new JBLabel(); + this.$$$loadLabelText$$$(myErrorLabel, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.fmt.cannot.download")); + myErrorLabel.setVisible(false); + panel5.add(myErrorLabel, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final Spacer spacer3 = new Spacer(); + panel5.add(spacer3, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } installPreviewPanel(myRightPanel); myProject = ProjectUtil.getProject(getPanel()); - myShfmtPathSelector.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFileDescriptor().withTitle(ShBundle.message("sh.code.style.choose.path"))); + myShfmtPathSelector.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFileDescriptor() + .withTitle(ShBundle.message("sh.code.style.choose.path"))); myShfmtPathSelector.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent documentEvent) { @@ -85,16 +264,78 @@ public class ShCodeStylePanel extends CodeStyleAbstractPanel { addPanelToWatch(myPanel); } - private void createUIComponents() { - myIndentField = new IntegerField(null, CodeStyleConstraints.MIN_INDENT_SIZE, CodeStyleConstraints.MAX_INDENT_SIZE); - myTabField = new IntegerField(null, CodeStyleConstraints.MIN_TAB_SIZE, CodeStyleConstraints.MAX_TAB_SIZE); - myShfmtDownloadLink = new ActionLink(ShBundle.message("sh.code.style.download.link"), e -> { - ShFormatterDownloader.getInstance().download(myProject, - () -> myShfmtPathSelector.setText(ShSettings.getShfmtPath(myProject)), - () -> myErrorLabel.setVisible(true)); - }); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected int getRightMargin() { return 0; @@ -141,15 +382,15 @@ public class ShCodeStylePanel extends CodeStyleAbstractPanel { ShCodeStyleSettings shSettings = settings.getCustomSettings(ShCodeStyleSettings.class); return isFieldModified(myBinaryOpsStartLine, shSettings.BINARY_OPS_START_LINE) - || isFieldModified(mySwitchCasesIndented, shSettings.SWITCH_CASES_INDENTED) - || isFieldModified(myRedirectFollowedBySpace, shSettings.REDIRECT_FOLLOWED_BY_SPACE) - || isFieldModified(myKeepColumnAlignmentPadding, shSettings.KEEP_COLUMN_ALIGNMENT_PADDING) - || isFieldModified(myMinifyProgram, shSettings.MINIFY_PROGRAM) - || isFieldModified(myUnixLineSeparator, shSettings.USE_UNIX_LINE_SEPARATOR) - || isFieldModified(myTabCharacter, indentOptions.USE_TAB_CHARACTER) - || isFieldModified(myIndentField, indentOptions.INDENT_SIZE) - || isFieldModified(myTabField, indentOptions.TAB_SIZE) - || isFieldModified(myShfmtPathSelector, ShSettings.getShfmtPath(myProject)); + || isFieldModified(mySwitchCasesIndented, shSettings.SWITCH_CASES_INDENTED) + || isFieldModified(myRedirectFollowedBySpace, shSettings.REDIRECT_FOLLOWED_BY_SPACE) + || isFieldModified(myKeepColumnAlignmentPadding, shSettings.KEEP_COLUMN_ALIGNMENT_PADDING) + || isFieldModified(myMinifyProgram, shSettings.MINIFY_PROGRAM) + || isFieldModified(myUnixLineSeparator, shSettings.USE_UNIX_LINE_SEPARATOR) + || isFieldModified(myTabCharacter, indentOptions.USE_TAB_CHARACTER) + || isFieldModified(myIndentField, indentOptions.INDENT_SIZE) + || isFieldModified(myTabField, indentOptions.TAB_SIZE) + || isFieldModified(myShfmtPathSelector, ShSettings.getShfmtPath(myProject)); } @Override @@ -190,7 +431,7 @@ public class ShCodeStylePanel extends CodeStyleAbstractPanel { private static final @NonNls String GENERAL_CODE_SAMPLE = """ #!/usr/bin/env sh - + function foo() { if [ -x $file ]; then myArray=(item1 item2 item3) @@ -200,7 +441,7 @@ public class ShCodeStylePanel extends CodeStyleAbstractPanel { echo "Usage: $0 file ..." fi } - + for (( i = 0; i < 5; i++ )); do read -p r print -n $r diff --git a/plugins/sh/core/src/com/intellij/sh/run/ShRunConfigurationEditor.java b/plugins/sh/core/src/com/intellij/sh/run/ShRunConfigurationEditor.java index 071a065c8bba..735a52b285b4 100644 --- a/plugins/sh/core/src/com/intellij/sh/run/ShRunConfigurationEditor.java +++ b/plugins/sh/core/src/com/intellij/sh/run/ShRunConfigurationEditor.java @@ -8,34 +8,204 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.sh.ShBundle; import com.intellij.ui.RawCommandLineEditor; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ShRunConfigurationEditor extends SettingsEditor { - private JPanel myPanel; - private JPanel myScriptPathPanel; - private JPanel myScriptTextPanel; - private RawCommandLineEditor myScript; - private TextFieldWithBrowseButton myScriptSelector; - private RawCommandLineEditor myScriptOptions; - private TextFieldWithBrowseButton myScriptFileWorkingDirectory; - private TextFieldWithBrowseButton myScriptWorkingDirectory; - private TextFieldWithBrowseButton myInterpreterSelector; - private RawCommandLineEditor myInterpreterOptions; - private JBCheckBox myExecuteFileInTerminal; - private JBCheckBox myExecuteScriptInTerminal; - private EnvironmentVariablesComponent myEnvComponent; - private EnvironmentVariablesComponent myScriptEnvComponent; + private final JPanel myPanel; + private final JPanel myScriptPathPanel; + private final JPanel myScriptTextPanel; + private final RawCommandLineEditor myScript; + private final TextFieldWithBrowseButton myScriptSelector; + private final RawCommandLineEditor myScriptOptions; + private final TextFieldWithBrowseButton myScriptFileWorkingDirectory; + private final TextFieldWithBrowseButton myScriptWorkingDirectory; + private final TextFieldWithBrowseButton myInterpreterSelector; + private final RawCommandLineEditor myInterpreterOptions; + private final JBCheckBox myExecuteFileInTerminal; + private final JBCheckBox myExecuteScriptInTerminal; + private final EnvironmentVariablesComponent myEnvComponent; + private final EnvironmentVariablesComponent myScriptEnvComponent; private ButtonGroup myScriptGroup; - private JBRadioButton myScriptFileRadioButton; - private JBRadioButton myScriptTextRadioButton; + private final JBRadioButton myScriptFileRadioButton; + private final JBRadioButton myScriptTextRadioButton; ShRunConfigurationEditor(Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myScriptPathPanel = new JPanel(); + myScriptPathPanel.setLayout(new GridLayoutManager(8, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myScriptPathPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myScriptOptions = new RawCommandLineEditor(); + myScriptPathPanel.add(myScriptOptions, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.script.options")); + myScriptPathPanel.add(jBLabel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.working.dir")); + myScriptPathPanel.add(jBLabel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myEnvComponent = new EnvironmentVariablesComponent(); + myEnvComponent.setLabelLocation("East"); + myEnvComponent.setText(""); + myScriptPathPanel.add(myEnvComponent, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.environment.variables")); + myScriptPathPanel.add(label1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.interpreter")); + myScriptPathPanel.add(titledSeparator1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.interpreter.path")); + myScriptPathPanel.add(jBLabel3, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myInterpreterSelector = new TextFieldWithBrowseButton(); + myScriptPathPanel.add(myInterpreterSelector, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myInterpreterOptions = new RawCommandLineEditor(); + myScriptPathPanel.add(myInterpreterOptions, + new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.interpreter.options")); + myScriptPathPanel.add(jBLabel4, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel5, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.script.path")); + myScriptPathPanel.add(jBLabel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myScriptSelector = new TextFieldWithBrowseButton(); + myScriptPathPanel.add(myScriptSelector, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myExecuteFileInTerminal = new JBCheckBox(); + myExecuteFileInTerminal.setEnabled(true); + myExecuteFileInTerminal.setSelected(true); + this.$$$loadButtonText$$$(myExecuteFileInTerminal, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute.terminal")); + myScriptPathPanel.add(myExecuteFileInTerminal, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myScriptFileWorkingDirectory = new TextFieldWithBrowseButton(); + myScriptPathPanel.add(myScriptFileWorkingDirectory, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myScriptTextPanel = new JPanel(); + myScriptTextPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myScriptTextPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myScript = new RawCommandLineEditor(); + myScriptTextPanel.add(myScript, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel6 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel6, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute.script.text.title")); + myScriptTextPanel.add(jBLabel6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myExecuteScriptInTerminal = new JBCheckBox(); + myExecuteScriptInTerminal.setEnabled(true); + myExecuteScriptInTerminal.setSelected(true); + this.$$$loadButtonText$$$(myExecuteScriptInTerminal, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute.terminal")); + myScriptTextPanel.add(myExecuteScriptInTerminal, + new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBLabel jBLabel7 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel7, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.working.dir")); + myScriptTextPanel.add(jBLabel7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myScriptWorkingDirectory = new TextFieldWithBrowseButton(); + myScriptTextPanel.add(myScriptWorkingDirectory, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBLabel jBLabel8 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel8, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.environment.variables")); + myScriptTextPanel.add(jBLabel8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myScriptEnvComponent = new EnvironmentVariablesComponent(); + myScriptEnvComponent.setText(""); + myScriptTextPanel.add(myScriptEnvComponent, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JBLabel jBLabel9 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel9, this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute")); + panel1.add(jBLabel9, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(152, 16), null, 0, false)); + myScriptFileRadioButton = new JBRadioButton(); + myScriptFileRadioButton.setEnabled(true); + myScriptFileRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myScriptFileRadioButton, + this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute.script.file")); + panel1.add(myScriptFileRadioButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myScriptTextRadioButton = new JBRadioButton(); + this.$$$loadButtonText$$$(myScriptTextRadioButton, + this.$$$getMessageFromBundle$$$("messages/ShBundle", "sh.run.execute.script.text")); + panel1.add(myScriptTextRadioButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } myScriptSelector.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFileDescriptor() .withTitle(ShBundle.message("sh.label.choose.shell.script"))); myScriptFileWorkingDirectory.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFolderDescriptor() @@ -53,11 +223,84 @@ public class ShRunConfigurationEditor extends SettingsEditor selectMode(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void resetEditorFrom(@NotNull ShRunConfiguration configuration) { if (configuration.isExecuteScriptFile()) { myScriptFileRadioButton.setSelected(true); - } else { + } + else { myScriptTextRadioButton.setSelected(true); } selectMode(); @@ -86,7 +329,8 @@ public class ShRunConfigurationEditor extends SettingsEditor configuration.setExecuteInTerminal(myExecuteFileInTerminal.isSelected()); configuration.setEnvData(myEnvComponent.getEnvData()); configuration.setExecuteScriptFile(true); - } else { + } + else { configuration.setScriptWorkingDirectory(myScriptWorkingDirectory.getText()); configuration.setExecuteInTerminal(myExecuteScriptInTerminal.isSelected()); configuration.setEnvData(myScriptEnvComponent.getEnvData()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java index ba9e980b2e19..8b7788ca4db2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java @@ -15,6 +15,8 @@ import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.SortedListModel; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBList; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,10 +27,15 @@ import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.SelectLocationDialog; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.ListCellRenderer; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.ResourceBundle; import static com.intellij.util.ObjectUtils.notNull; import static com.intellij.vcsUtil.VcsUtil.getFilePath; @@ -41,11 +48,11 @@ import static org.jetbrains.idea.svn.SvnUtil.isAncestor; public class BranchConfigurationDialog extends DialogWrapper { public static final ListCellRenderer DECODED_URL_RENDERER = SimpleListCellRenderer.create("", Url::toDecodedString); - private JPanel myTopPanel; - private TextFieldWithBrowseButton myTrunkLocationTextField; + private final JPanel myTopPanel; + private final TextFieldWithBrowseButton myTrunkLocationTextField; private final JBList myBranchLocationsList; private final @NotNull SortedListModel myBranchLocationsModel = new SortedListModel<>(comparing(Url::toDecodedString)); - private JPanel myListPanel; + private final JPanel myListPanel; private final @NotNull NewRootBunch mySvnBranchConfigManager; private final @NotNull VirtualFile myRoot; private final @NotNull Url myRootUrl; @@ -61,6 +68,38 @@ public class BranchConfigurationDialog extends DialogWrapper { myRoot = root; myRootUrl = rootUrl; myConfiguration = configuration; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "configure.branches.branch.locations")); + myTopPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myListPanel = new JPanel(); + myListPanel.setLayout(new BorderLayout(0, 0)); + myTopPanel.add(myListPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "configure.branches.trunk.location")); + panel1.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTrunkLocationTextField = new TextFieldWithBrowseButton(); + panel1.add(myTrunkLocationTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } init(); setTitle(message("configure.branches.title")); @@ -86,6 +125,53 @@ public class BranchConfigurationDialog extends DialogWrapper { myListPanel.add(wrapLocationsWithToolbar(project, rootUrl), BorderLayout.CENTER); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + @Override protected @Nullable ValidationInfo doValidate() { try { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/CreateBranchOrTagDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/CreateBranchOrTagDialog.java index 18cc2495be24..9daff840f89d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/CreateBranchOrTagDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/CreateBranchOrTagDialog.java @@ -13,7 +13,13 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.NamedColorUtil; import com.intellij.util.ui.UIUtil; @@ -30,6 +36,8 @@ import org.jetbrains.idea.svn.dialogs.SelectLocationDialog; import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.update.SvnRevisionPanel; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; @@ -37,11 +45,17 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.openapi.ui.Messages.showErrorDialog; import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces; @@ -58,23 +72,23 @@ public class CreateBranchOrTagDialog extends DialogWrapper { private final @NotNull SvnVcs myVcs; private final @NotNull Project myProject; - private TextFieldWithBrowseButton myToURLText; + private final TextFieldWithBrowseButton myToURLText; - private JTextArea myCommentText; - private JPanel myTopPanel; - private JRadioButton myWorkingCopyRadioButton; - private JRadioButton myRepositoryRadioButton; - private TextFieldWithBrowseButton myWorkingCopyField; - private TextFieldWithBrowseButton myRepositoryField; - private SvnRevisionPanel myRevisionPanel; - private ComboboxWithBrowseButton myBranchTagBaseComboBox; + private final JTextArea myCommentText; + private final JPanel myTopPanel; + private final JRadioButton myWorkingCopyRadioButton; + private final JRadioButton myRepositoryRadioButton; + private final TextFieldWithBrowseButton myWorkingCopyField; + private final TextFieldWithBrowseButton myRepositoryField; + private final SvnRevisionPanel myRevisionPanel; + private final ComboboxWithBrowseButton myBranchTagBaseComboBox; private final @NotNull CollectionComboBoxModel myBranchTagBaseModel = new CollectionComboBoxModel<>(); - private JTextField myBranchTextField; - private JRadioButton myBranchOrTagRadioButton; - private JRadioButton myAnyLocationRadioButton; - private JButton myProjectButton; - private JLabel myUseThisVariantToLabel; - private JBCheckBox mySwitchOnCreate; + private final JTextField myBranchTextField; + private final JRadioButton myBranchOrTagRadioButton; + private final JRadioButton myAnyLocationRadioButton; + private final JButton myProjectButton; + private final JLabel myUseThisVariantToLabel; + private final JBCheckBox mySwitchOnCreate; private static final @NonNls String HELP_ID = "vcs.subversion.branch"; private SvnBranchConfigurationNew myBranchConfiguration; @@ -87,6 +101,163 @@ public class CreateBranchOrTagDialog extends DialogWrapper { super(vcs.getProject(), true); mySrcFile = file; myVcs = vcs; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridBagLayout()); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 3; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(2, 2, 2, 2); + myTopPanel.add(jBScrollPane1, gbc); + myCommentText = new JTextArea(); + myCommentText.setColumns(25); + myCommentText.setLineWrap(true); + myCommentText.setRows(4); + myCommentText.setWrapStyleWord(true); + jBScrollPane1.setViewportView(myCommentText); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 3; + gbc.fill = GridBagConstraints.BOTH; + myTopPanel.add(panel1, gbc); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "label.copy.from"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myWorkingCopyRadioButton = new JRadioButton(); + myWorkingCopyRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myWorkingCopyRadioButton, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.copy.working.copy")); + panel1.add(myWorkingCopyRadioButton, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWorkingCopyField = new TextFieldWithBrowseButton(); + panel1.add(myWorkingCopyField, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 2, false)); + myRepositoryRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myRepositoryRadioButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.copy.repository.location")); + panel1.add(myRepositoryRadioButton, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRepositoryField = new TextFieldWithBrowseButton(); + panel1.add(myRepositoryField, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 2, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.copy.from.revision")); + panel1.add(label1, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myRevisionPanel = new SvnRevisionPanel(); + panel1.add(myRevisionPanel.$$$getRootComponent$$$(), + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myProjectButton = new JButton(); + myProjectButton.setMargin(new Insets(2, 2, 2, 2)); + myProjectButton.setToolTipText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "tooltip.use.project.location")); + panel1.add(myProjectButton, new GridConstraints(4, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseThisVariantToLabel = new JLabel(); + this.$$$loadLabelText$$$(myUseThisVariantToLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.create.branch.or.tag.from.working.copy.warning")); + panel1.add(myUseThisVariantToLabel, + new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 3; + gbc.fill = GridBagConstraints.BOTH; + myTopPanel.add(panel2, gbc); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "label.copy.to"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myToURLText = new TextFieldWithBrowseButton(); + panel2.add(myToURLText, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 2, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.branch.base.url")); + panel2.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myBranchTagBaseComboBox = new ComboboxWithBrowseButton(); + panel2.add(myBranchTagBaseComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.branch.name")); + panel2.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + myBranchTextField = new JTextField(); + myBranchTextField.setColumns(25); + myBranchTextField.setText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "value.new.branch.name")); + panel2.add(myBranchTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(90, -1), null, 0, false)); + myBranchOrTagRadioButton = new JRadioButton(); + myBranchOrTagRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myBranchOrTagRadioButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.copy.to.branch.or.tag")); + panel2.add(myBranchOrTagRadioButton, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnyLocationRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myAnyLocationRadioButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.copy.to.any.location")); + panel2.add(myAnyLocationRadioButton, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final TitledSeparator titledSeparator1 = new TitledSeparator(); + titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.copy.comment")); + gbc = new GridBagConstraints(); + gbc.gridx = 2; + gbc.gridy = 2; + gbc.fill = GridBagConstraints.HORIZONTAL; + myTopPanel.add(titledSeparator1, gbc); + mySwitchOnCreate = new JBCheckBox(); + gbc = new GridBagConstraints(); + gbc.gridx = 2; + gbc.gridy = 4; + gbc.anchor = GridBagConstraints.WEST; + myTopPanel.add(mySwitchOnCreate, gbc); + label2.setLabelFor(myBranchTagBaseComboBox); + label3.setLabelFor(myBranchTextField); + titledSeparator1.setLabelFor(myCommentText); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myWorkingCopyRadioButton); + buttonGroup.add(myRepositoryRadioButton); + buttonGroup = new ButtonGroup(); + buttonGroup.add(myBranchOrTagRadioButton); + buttonGroup.add(myAnyLocationRadioButton); + } myProject = vcs.getProject(); setResizable(true); setTitle(message("dialog.title.branch")); @@ -185,6 +356,78 @@ public class CreateBranchOrTagDialog extends DialogWrapper { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private void updateBranchTagBases() { myBranchConfiguration = SvnBranchConfigurationManager.getInstance(myProject).get(mySrcVirtualFile); @@ -223,7 +466,8 @@ public class CreateBranchOrTagDialog extends DialogWrapper { myBranchTagBaseComboBox.setEnabled(myBranchOrTagRadioButton.isSelected()); myBranchTextField.setEnabled(myBranchOrTagRadioButton.isSelected()); myToURLText.setEnabled(myAnyLocationRadioButton.isSelected()); - myUseThisVariantToLabel.setForeground(myWorkingCopyRadioButton.isSelected() ? UIUtil.getActiveTextColor() : NamedColorUtil.getInactiveTextColor()); + myUseThisVariantToLabel.setForeground( + myWorkingCopyRadioButton.isSelected() ? UIUtil.getActiveTextColor() : NamedColorUtil.getInactiveTextColor()); } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/ConfigureProxiesOptionsPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/ConfigureProxiesOptionsPanel.java index 75978c122f4b..12e22e88bf7d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/ConfigureProxiesOptionsPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/ConfigureProxiesOptionsPanel.java @@ -5,14 +5,23 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.NlsSafe; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.InsertPathAction; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.DefaultListSelectionModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JPasswordField; @@ -20,32 +29,38 @@ import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.ListModel; import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; import javax.swing.text.JTextComponent; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import static org.jetbrains.idea.svn.SvnBundle.message; import static org.jetbrains.idea.svn.config.SvnIniFile.isTurned; public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { - private JPanel myMainPanel; - private JTextField myServerField; - private JTextField myUserField; - private JTextField myPortField; - private JPasswordField myPasswordField; - private JTextArea myUrlPatterns; - private JTextArea myExceptions; - private JTextField myTimeoutField; - private JCheckBox myTrustDefaultCAsCheckBox; - private JPasswordField myClientCertificatePasswordField; - private JButton myTestConnectionButton; - private JTextField myPathToCertificatesField; - private TextFieldWithBrowseButton myClientCertificatePathField; - private JList myRepositoriesList; + private final JPanel myMainPanel; + private final JTextField myServerField; + private final JTextField myUserField; + private final JTextField myPortField; + private final JPasswordField myPasswordField; + private final JTextArea myUrlPatterns; + private final JTextArea myExceptions; + private final JTextField myTimeoutField; + private final JCheckBox myTrustDefaultCAsCheckBox; + private final JPasswordField myClientCertificatePasswordField; + private final JButton myTestConnectionButton; + private final JTextField myPathToCertificatesField; + private final TextFieldWithBrowseButton myClientCertificatePathField; + private final JList myRepositoriesList; private boolean myIsDefault; private final Runnable myValidator; @@ -101,6 +116,200 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { public ConfigureProxiesOptionsPanel(final Runnable validator, final TestConnectionPerformer testConnectionPerformer) { myValidator = validator; myTestConnectionPerformer = testConnectionPerformer; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createLineBorder(Color.black), + this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.panel.proxy.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.patterns.text")); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.exceptions.text")); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.server.text")); + panel1.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myServerField = new JTextField(); + panel1.add(myServerField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.port.text")); + panel1.add(label4, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPortField = new JTextField(); + panel1.add(myPortField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setRequestFocusEnabled(false); + this.$$$loadLabelText$$$(label5, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.password.text")); + panel1.add(label5, + new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPasswordField = new JPasswordField(); + panel1.add(myPasswordField, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.user.text")); + panel1.add(label6, + new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUserField = new JTextField(); + panel1.add(myUserField, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.connection.timeout.text")); + panel1.add(label7, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTimeoutField = new JTextField(); + panel1.add(myTimeoutField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUrlPatterns = new JTextArea(); + myUrlPatterns.setRows(3); + jBScrollPane1.setViewportView(myUrlPatterns); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + panel1.add(jBScrollPane2, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myExceptions = new JTextArea(); + myExceptions.setLineWrap(true); + myExceptions.setRows(3); + jBScrollPane2.setViewportView(myExceptions); + final JLabel label8 = new JLabel(); + this.$$$loadLabelText$$$(label8, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "dialog.edit.http.proxies.settings.seconds.text")); + panel1.add(label8, + new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myMainPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createLineBorder(Color.black), + this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.panel.ssl.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label9 = new JLabel(); + this.$$$loadLabelText$$$(label9, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.paths.to.authority.certificates.text")); + panel2.add(label9, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label10 = new JLabel(); + this.$$$loadLabelText$$$(label10, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.ssl.client.certificate.file.text")); + panel2.add(label10, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + this.$$$loadLabelText$$$(label11, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.client.certificate.passphrase.text")); + panel2.add(label11, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClientCertificatePasswordField = new JPasswordField(); + panel2.add(myClientCertificatePasswordField, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), + null, 0, false)); + myTrustDefaultCAsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myTrustDefaultCAsCheckBox, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.trust.default.cas.text")); + panel2.add(myTrustDefaultCAsCheckBox, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myClientCertificatePathField = new TextFieldWithBrowseButton(); + panel2.add(myClientCertificatePathField, + new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPathToCertificatesField = new JTextField(); + panel2.add(myPathToCertificatesField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myMainPanel.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createLineBorder(Color.black), + this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.panel.repositories.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane3 = new JBScrollPane(); + panel3.add(jBScrollPane3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myRepositoriesList = new JBList(); + jBScrollPane3.setViewportView(myRepositoriesList); + myTestConnectionButton = new JButton(); + this.$$$loadButtonText$$$(myTestConnectionButton, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "dialog.edit.http.proxies.settings.test.connection.button.text")); + panel3.add(myTestConnectionButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myUrlPatterns); + label2.setLabelFor(myExceptions); + label3.setLabelFor(myServerField); + label4.setLabelFor(myPortField); + label5.setLabelFor(myPasswordField); + label6.setLabelFor(myUserField); + label7.setLabelFor(myTimeoutField); + label9.setLabelFor(myPathToCertificatesField); + label11.setLabelFor(myClientCertificatePasswordField); + } myComponent2Key = new HashMap<>(); myKey2Component = new HashMap<>(); @@ -119,6 +328,78 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void putPatternsListener() { final UrlsSetter urlsSetter = new UrlsSetter(); myUrlPatterns.addFocusListener(urlsSetter); @@ -175,7 +456,7 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { } private void repositoryUrlsRecalculation() { - if (! myIsDefault) { + if (!myIsDefault) { myPatternsListener.onChange(myUrlPatterns.getText(), myExceptions.getText()); } } @@ -231,8 +512,9 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { } else if (component instanceof TextFieldWithBrowseButton) { value = ((TextFieldWithBrowseButton)component).getTextField().getText(); - } else if (component instanceof JCheckBox) { - value = ((JCheckBox) component).isSelected() ? "yes" : "no"; + } + else if (component instanceof JCheckBox) { + value = ((JCheckBox)component).isSelected() ? "yes" : "no"; } if ((value != null) && (!value.isEmpty() || map.containsKey(entry.getKey()))) { @@ -247,7 +529,7 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener { public void setIsDefaultGroup(final boolean value) { myIsDefault = value; - myUrlPatterns.setEditable(! myIsDefault); + myUrlPatterns.setEditable(!myIsDefault); } public String getPatterns() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java index 80e1d6ae1d61..715f8fef976d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java @@ -21,6 +21,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTabbedPane; import java.awt.BorderLayout; +import java.awt.Dimension; import static com.intellij.openapi.ui.Messages.showErrorDialog; import static com.intellij.openapi.ui.Messages.showInfoMessage; @@ -32,13 +33,22 @@ import static org.jetbrains.idea.svn.config.SvnIniFile.SERVERS_FILE_NAME; public class SvnConfigureProxiesDialog extends DialogWrapper implements ValidationListener, TestConnectionPerformer { private final SvnConfigureProxiesComponent mySystemTab; private final SvnConfigureProxiesComponent myUserTab; - private JPanel myPanel; + private final JPanel myPanel; private JTabbedPane myTabbedPane; private final GroupsValidator myValidator; private final Project myProject; public SvnConfigureProxiesDialog(final Project project) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + myPanel.setAlignmentX(0.5f); + myPanel.setMinimumSize(new Dimension(820, 630)); + } valid = true; myProject = project; @@ -58,6 +68,9 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati myValidator.run(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public void onError(@NotNull String text, @NotNull JComponent component, boolean forbidSave) { myTabbedPane.setSelectedComponent(component); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RelocateDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RelocateDialog.java index 144328441317..65a6f4344b20 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RelocateDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RelocateDialog.java @@ -3,29 +3,115 @@ package org.jetbrains.idea.svn.dialogs; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.Url; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; + import static org.jetbrains.idea.svn.SvnBundle.message; public class RelocateDialog extends DialogWrapper { - private JPanel myMainPanel; - private JTextField myFromURLTextField; - private JTextField myToURLTextField; + private final JPanel myMainPanel; + private final JTextField myFromURLTextField; + private final JTextField myToURLTextField; public RelocateDialog(@NotNull Project project, @NotNull Url url) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.from.url")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.to.url")); + myMainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFromURLTextField = new JTextField(); + myMainPanel.add(myFromURLTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(300, -1), null, 0, false)); + myToURLTextField = new JTextField(); + myMainPanel.add(myToURLTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(300, -1), null, 0, false)); + label1.setLabelFor(myFromURLTextField); + label2.setLabelFor(myToURLTextField); + } init(); setTitle(message("dialog.title.relocate.working.copy")); myFromURLTextField.setText(url.toDecodedString()); myToURLTextField.setText(url.toDecodedString()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myMainPanel; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java index 6023935ec7fc..1b36d7abf3db 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java @@ -7,6 +7,7 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,18 +22,29 @@ import org.jetbrains.idea.svn.properties.PropertyConsumer; import org.jetbrains.idea.svn.properties.PropertyData; import org.jetbrains.idea.svn.properties.PropertyValue; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.JSeparator; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import java.awt.Component; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.io.File; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; import java.util.TreeSet; import static com.intellij.util.containers.ContainerUtil.addAll; @@ -51,22 +63,119 @@ public class SetPropertyDialog extends DialogWrapper { private final @NlsSafe @Nullable String myPropertyName; private final File[] myFiles; - private JComboBox myPropertyNameBox; - private JRadioButton mySetPropertyButton; - private JTextArea myValueText; - private JRadioButton myDeletePropertyButton; - private JCheckBox myRecursiveButton; + private final JComboBox myPropertyNameBox; + private final JRadioButton mySetPropertyButton; + private final JTextArea myValueText; + private final JRadioButton myDeletePropertyButton; + private final JCheckBox myRecursiveButton; private final boolean myIsRecursionAllowed; private final SvnVcs myVCS; private static final @NonNls String HELP_ID = "vcs.subversion.property"; - private JPanel myMainPanel; + private final JPanel myMainPanel; public SetPropertyDialog(Project project, File[] files, @NlsSafe @Nullable String name, boolean allowRecursion) { super(project, true); myFiles = files; myPropertyName = name; myIsRecursionAllowed = allowRecursion; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridBagLayout()); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.set.property.property.name")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(label1, gbc); + myPropertyNameBox = new JComboBox(); + myPropertyNameBox.setEditable(true); + myPropertyNameBox.setRequestFocusEnabled(false); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(myPropertyNameBox, gbc); + mySetPropertyButton = new JRadioButton(); + mySetPropertyButton.setSelected(true); + this.$$$loadButtonText$$$(mySetPropertyButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.set.property.set.property.value")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(mySetPropertyButton, gbc); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(jBScrollPane1, gbc); + myValueText = new JTextArea(); + myValueText.setColumns(25); + myValueText.setRows(7); + myValueText.setText(""); + jBScrollPane1.setViewportView(myValueText); + myDeletePropertyButton = new JRadioButton(); + this.$$$loadButtonText$$$(myDeletePropertyButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "radio.set.property.delete.property")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(myDeletePropertyButton, gbc); + final JSeparator separator1 = new JSeparator(); + Font separator1Font = UIManager.getFont("TextPane.font"); + if (separator1Font != null) separator1.setFont(separator1Font); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 4; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(separator1, gbc); + myRecursiveButton = new JCheckBox(); + this.$$$loadButtonText$$$(myRecursiveButton, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "checkbox.set.property.update.properties.recursively")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 5; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(myRecursiveButton, gbc); + label1.setLabelFor(myPropertyNameBox); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(mySetPropertyButton); + buttonGroup.add(myDeletePropertyButton); + } myVCS = SvnVcs.getInstance(project); setResizable(true); setTitle(SvnBundle.message("dialog.title.set.property")); @@ -74,6 +183,78 @@ public class SetPropertyDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected String getHelpId() { return HELP_ID; @@ -135,7 +316,6 @@ public class SetPropertyDialog extends DialogWrapper { getOKAction().setEnabled(name != null && !name.trim().isEmpty()); } }); - } getOKAction().setEnabled(myPropertyName != null && !myPropertyName.trim().isEmpty()); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java index bc8005293ec9..cb1ade522d29 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java @@ -10,7 +10,10 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.FixedSizeButton; import com.intellij.openapi.vcs.checkout.CheckoutStrategy; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,6 +24,7 @@ import org.jetbrains.idea.svn.api.Revision; import org.jetbrains.idea.svn.api.Url; import org.jetbrains.idea.svn.revision.SvnSelectRevisionPanel; +import javax.swing.AbstractButton; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -28,29 +32,96 @@ import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ScrollPaneConstants; +import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile; public class CheckoutOptionsDialog extends DialogWrapper { - private JCheckBox myExternalsCheckbox; - private JLabel myUrlLabel; - private JPanel myTopPanel; - private SvnSelectRevisionPanel svnSelectRevisionPanel; - private DepthCombo myDepthCombo; - private JLabel myDepthLabel; - private JList myLocalTargetList; - private FixedSizeButton mySelectTarget; - private JBScrollPane myScroll; + private final JCheckBox myExternalsCheckbox; + private final JLabel myUrlLabel; + private final JPanel myTopPanel; + private final SvnSelectRevisionPanel svnSelectRevisionPanel; + private final DepthCombo myDepthCombo; + private final JLabel myDepthLabel; + private final JList myLocalTargetList; + private final FixedSizeButton mySelectTarget; + private final JBScrollPane myScroll; private final String myRelativePath; public CheckoutOptionsDialog(final Project project, Url url, File target, final VirtualFile root, final String relativePath) { super(project, true); myRelativePath = relativePath; + { + mySelectTarget = new FixedSizeButton(20); + myDepthCombo = new DepthCombo(false); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new BorderLayout(0, 0)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1)); + myTopPanel.add(panel1, BorderLayout.CENTER); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkout.options.checkout.label")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.destination")); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myExternalsCheckbox = new JCheckBox(); + myExternalsCheckbox.setSelected(true); + this.$$$loadButtonText$$$(myExternalsCheckbox, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkbox.include.externals.locations")); + panel1.add(myExternalsCheckbox, + new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + svnSelectRevisionPanel = new SvnSelectRevisionPanel(); + panel1.add(svnSelectRevisionPanel.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + panel1.add(myDepthCombo, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myDepthLabel = new JLabel(); + this.$$$loadLabelText$$$(myDepthLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.text")); + myDepthLabel.setToolTipText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.description")); + panel1.add(myDepthLabel, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myScroll = new JBScrollPane(); + panel1.add(myScroll, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + myLocalTargetList = new JBList(); + myLocalTargetList.setSelectionMode(0); + myScroll.setViewportView(myLocalTargetList); + panel1.add(mySelectTarget, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUrlLabel = new JLabel(); + panel1.add(myUrlLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myUrlLabel.setText(url.toDecodedString()); fillTargetList(target); @@ -82,10 +153,82 @@ public class CheckoutOptionsDialog extends DialogWrapper { myScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + private void validateTargetSelected() { Object[] objects = myLocalTargetList.getSelectedValues(); boolean disable = objects == null || objects.length != 1; - setOKActionEnabled(! disable); + setOKActionEnabled(!disable); } private void fillTargetList(final File target) { @@ -96,7 +239,7 @@ public class CheckoutOptionsDialog extends DialogWrapper { final List targets = new ArrayList<>(5); for (CheckoutStrategy strategy : strategies) { final File result = strategy.getResult(); - if (result != null && (! targets.contains(result))) { + if (result != null && (!targets.contains(result))) { targets.add(result); } } @@ -109,7 +252,7 @@ public class CheckoutOptionsDialog extends DialogWrapper { myLocalTargetList.setPreferredSize(new Dimension(20, 80)); myLocalTargetList.setMinimumSize(new Dimension(20, 80)); myLocalTargetList.setSelectedValue(target, true); - if (myLocalTargetList.getSelectedValues() == null && (! targets.isEmpty())) { + if (myLocalTargetList.getSelectedValues() == null && (!targets.isEmpty())) { myLocalTargetList.setSelectedIndex(0); } } @@ -121,7 +264,7 @@ public class CheckoutOptionsDialog extends DialogWrapper { public @Nullable File getTarget() { Object[] objects = myLocalTargetList.getSelectedValues(); - return (objects == null) || (objects.length != 1) ? null : (File) objects[0]; + return (objects == null) || (objects.length != 1) ? null : (File)objects[0]; } public Depth getDepth() { @@ -138,11 +281,6 @@ public class CheckoutOptionsDialog extends DialogWrapper { } public @NotNull Revision getRevision() throws ConfigurationException { - return svnSelectRevisionPanel.getRevision(); - } - - private void createUIComponents() { - mySelectTarget = new FixedSizeButton(20); - myDepthCombo = new DepthCombo(false); + return svnSelectRevisionPanel.getRevision(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java index af3998b40248..e4f086901f40 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java @@ -11,6 +11,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,15 +20,28 @@ import org.jetbrains.idea.svn.api.Url; import org.jetbrains.idea.svn.dialogs.RepositoryBrowserComponent; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Color; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; import static com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile; import static org.jetbrains.idea.svn.SvnBundle.message; @@ -36,16 +50,16 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { private final Url myURL; private final Project myProject; - private RepositoryBrowserComponent myBrowser; + private final RepositoryBrowserComponent myBrowser; private final Url myRootURL; - private JRadioButton myUnifiedDiffButton; - private JRadioButton myUIDiffButton; - private TextFieldWithBrowseButton myFileBrowser; - private JCheckBox myReverseDiffButton; - private JLabel mySourceUrlLabel; - private JPanel myMainPanel; - private JLabel myErrorLabel; + private final JRadioButton myUnifiedDiffButton; + private final JRadioButton myUIDiffButton; + private final TextFieldWithBrowseButton myFileBrowser; + private final JCheckBox myReverseDiffButton; + private final JLabel mySourceUrlLabel; + private final JPanel myMainPanel; + private final JLabel myErrorLabel; private static final @NonNls String DEFAULT_PATCH_NAME = "diff.txt"; public DiffOptionsDialog(Project project, Url rootURL, Url url) { @@ -53,6 +67,129 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { myURL = url; myRootURL = rootURL; myProject = project; + { + myBrowser = new RepositoryBrowserComponent(SvnVcs.getInstance(myProject)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridBagLayout()); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "diff.options.label.compare")); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(label1, gbc); + mySourceUrlLabel = new JLabel(); + Font mySourceUrlLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, mySourceUrlLabel.getFont()); + if (mySourceUrlLabelFont != null) mySourceUrlLabel.setFont(mySourceUrlLabelFont); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(mySourceUrlLabel, gbc); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "diff.options.label.with")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(label2, gbc); + myReverseDiffButton = new JCheckBox(); + this.$$$loadButtonText$$$(myReverseDiffButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "diff.options.checkbox.reverse.diff")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 4; + gbc.gridwidth = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(myReverseDiffButton, gbc); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 5; + gbc.gridwidth = 3; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(2, 2, 2, 2); + myMainPanel.add(panel1, gbc); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "diff.options.label.compare.type"), + TitledBorder.LEADING, TitledBorder.TOP, + this.$$$getFont$$$("Tahoma", Font.PLAIN, 11, + panel1.getFont()), + new Color(-16777216))); + myUIDiffButton = new JRadioButton(); + myUIDiffButton.setSelected(true); + this.$$$loadButtonText$$$(myUIDiffButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "diff.options.radio.graphical.compare")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 3; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + panel1.add(myUIDiffButton, gbc); + myUnifiedDiffButton = new JRadioButton(); + this.$$$loadButtonText$$$(myUnifiedDiffButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "diff.options.radio.unified.diff")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 3; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + panel1.add(myUnifiedDiffButton, gbc); + myFileBrowser = new TextFieldWithBrowseButton(); + myFileBrowser.setEnabled(false); + myFileBrowser.setText(""); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 3; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(2, 2, 2, 2); + panel1.add(myFileBrowser, gbc); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 3; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + myMainPanel.add(myBrowser, gbc); + myErrorLabel = new JLabel(); + myErrorLabel.setForeground(Color.red); + myErrorLabel.setText(" "); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 6; + gbc.anchor = GridBagConstraints.WEST; + myMainPanel.add(myErrorLabel, gbc); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myUIDiffButton); + buttonGroup.add(myUnifiedDiffButton); + } setTitle(message("diff.options.title")); mySourceUrlLabel.setText(myURL.toDecodedString()); myBrowser.setRepositoryURL(myRootURL, false); @@ -83,6 +220,102 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { } } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected @NonNls String getDimensionServiceKey() { return "svn4idea.diff.options"; @@ -104,7 +337,7 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { public Url getTargetURL() { if (getOKAction().isEnabled() && myBrowser.getSelectedNode() != null) { - return myBrowser.getSelectedNode().getURL(); + return myBrowser.getSelectedNode().getURL(); } return null; } @@ -167,8 +400,4 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { myFileBrowser.setEnabled(myUnifiedDiffButton.isSelected()); update(); } - - private void createUIComponents() { - myBrowser = new RepositoryBrowserComponent(SvnVcs.getInstance(myProject)); - } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/MkdirOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/MkdirOptionsDialog.java index d81ff4311907..a425c1f6ea26 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/MkdirOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/MkdirOptionsDialog.java @@ -6,6 +6,9 @@ import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,6 +21,14 @@ import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; + +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; import static com.intellij.openapi.util.text.StringUtil.isEmpty; import static com.intellij.util.ObjectUtils.notNull; @@ -29,17 +40,68 @@ import static org.jetbrains.idea.svn.dialogs.browser.CopyOptionsDialog.configure public class MkdirOptionsDialog extends DialogWrapper { private Url myURL; - private JTextArea myCommitMessage; - private JTextField myNameField; - private JLabel myURLLabel; - private ComboBox myMessagesBox; - private JPanel myMainPanel; - private JLabel myRecentMessagesLabel; + private final JTextArea myCommitMessage; + private final JTextField myNameField; + private final JLabel myURLLabel; + private final ComboBox myMessagesBox; + private final JPanel myMainPanel; + private final JLabel myRecentMessagesLabel; private final @NotNull Url myOriginalURL; public MkdirOptionsDialog(Project project, @NotNull Url url) { super(project, true); myOriginalURL = url; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.remote.folder.url")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myURLLabel = new JLabel(); + Font myURLLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, myURLLabel.getFont()); + if (myURLLabelFont != null) myURLLabel.setFont(myURLLabelFont); + myMainPanel.add(myURLLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.remote.folder.name")); + myMainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myNameField = new JTextField(); + myMainPanel.add(myNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.commit.message")); + myMainPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMainPanel.add(jBScrollPane1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myCommitMessage = new JTextArea(); + myCommitMessage.setLineWrap(true); + myCommitMessage.setRows(10); + myCommitMessage.setText(""); + myCommitMessage.setWrapStyleWord(true); + jBScrollPane1.setViewportView(myCommitMessage); + myRecentMessagesLabel = new JLabel(); + this.$$$loadLabelText$$$(myRecentMessagesLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.recent.messages")); + myMainPanel.add(myRecentMessagesLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myMessagesBox = new ComboBox(); + myMainPanel.add(myMessagesBox, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } String newFolderName = message("value.new.folder.name"); try { @@ -81,6 +143,77 @@ public class MkdirOptionsDialog extends DialogWrapper { } } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected @NonNls String getDimensionServiceKey() { return "svn4idea.mkdir.options"; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnVersionFilterComponent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnVersionFilterComponent.java index aa00b17e798e..a25da3a3e330 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnVersionFilterComponent.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnVersionFilterComponent.java @@ -3,33 +3,116 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings; import com.intellij.openapi.vcs.versionBrowser.StandardVersionFilterComponent; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class SvnVersionFilterComponent extends StandardVersionFilterComponent { - private JCheckBox myUseAuthorFilter; - private JTextField myAuthorField; - private JPanel myPanel; - private JPanel myStandardPanel; - private JCheckBox myStopOnCopyCheckBox; + private final JCheckBox myUseAuthorFilter; + private final JTextField myAuthorField; + private final JPanel myPanel; + private final JPanel myStandardPanel; + private final JCheckBox myStopOnCopyCheckBox; public SvnVersionFilterComponent(boolean showDateFilter) { super(showDateFilter); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myUseAuthorFilter = new JCheckBox(); + this.$$$loadButtonText$$$(myUseAuthorFilter, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkbox.changes.filter.filter.by.author")); + myPanel.add(myUseAuthorFilter, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAuthorField = new JTextField(); + myPanel.add(myAuthorField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myStandardPanel = new JPanel(); + myPanel.add(myStandardPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myStopOnCopyCheckBox = new JCheckBox(); + myStopOnCopyCheckBox.setSelected(true); + this.$$$loadButtonText$$$(myStopOnCopyCheckBox, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "browse.changes.settings.stop.on.copy")); + myPanel.add(myStopOnCopyCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myStandardPanel.setLayout(new BorderLayout()); myStandardPanel.add(getStandardPanel(), BorderLayout.CENTER); init(new ChangeBrowserSettings()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void updateAllEnabled(@Nullable ActionEvent e) { super.updateAllEnabled(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java index 88ac881626c8..237a50e8f76e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java @@ -21,6 +21,11 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.NlsContexts.DialogTitle; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.IconUtil; import com.intellij.util.PlatformIcons; import com.intellij.util.ui.UIUtil; @@ -33,16 +38,21 @@ import org.jetbrains.idea.svn.api.Url; import org.jetbrains.idea.svn.branchConfig.SvnBranchMapperManager; import org.jetbrains.idea.svn.info.Info; +import javax.swing.AbstractButton; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import static com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile; @@ -51,14 +61,14 @@ import static org.jetbrains.idea.svn.SvnUtil.isAncestor; public class IntegratedSelectedOptionsDialog extends DialogWrapper { private final DefaultListModel myWorkingCopyInfoModel; - private JPanel contentPane; - private JCheckBox myDryRunCheckbox; - private JList myWorkingCopiesList; - private JComponent myToolbar; - private JLabel mySourceInfoLabel; - private JLabel myTargetInfoLabel; - private JLabel myWcListTitleLabel; - private JCheckBox myIgnoreWhitespacesCheckBox; + private final JPanel contentPane; + private final JCheckBox myDryRunCheckbox; + private final JList myWorkingCopiesList; + private final JComponent myToolbar; + private final JLabel mySourceInfoLabel; + private final JLabel myTargetInfoLabel; + private final JLabel myWcListTitleLabel; + private final JCheckBox myIgnoreWhitespacesCheckBox; private final Project myProject; private final @NotNull Url mySelectedBranchUrl; @@ -71,6 +81,81 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { public IntegratedSelectedOptionsDialog(final Project project, final Url currentBranch, @NotNull Url selectedBranchUrl) { super(project, true); + { + myGroup = new DefaultActionGroup(); + final ActionToolbar actionToolbar = + ActionManager.getInstance().createActionToolbar("SvnIntegratedSelectedOptionsDialog", myGroup, false); + myToolbar = actionToolbar.getComponent(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myWorkingCopiesList = new JBList(); + myWorkingCopiesList.setMinimumSize(new Dimension(100, 100)); + myWorkingCopiesList.setSelectionMode(0); + jBScrollPane1.setViewportView(myWorkingCopiesList); + myDryRunCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myDryRunCheckbox, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "checkbox.update.switch.configurable.try.merge.without.changes")); + panel1.add(myDryRunCheckbox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIgnoreWhitespacesCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myIgnoreWhitespacesCheckBox, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkbox.ignore.whitespace.when.merge.text")); + panel1.add(myIgnoreWhitespacesCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myWcListTitleLabel = new JLabel(); + this.$$$loadLabelText$$$(myWcListTitleLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "action.Subversion.integrate.changes.select.working.copy.text")); + contentPane.add(myWcListTitleLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + contentPane.add(myToolbar, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + mySourceInfoLabel = new JLabel(); + contentPane.add(mySourceInfoLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myTargetInfoLabel = new JLabel(); + contentPane.add(myTargetInfoLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(2, 3), + null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myMustSelectBeforeOk = true; myProject = project; mySelectedBranchUrl = selectedBranchUrl; @@ -85,7 +170,7 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { myWorkingCopiesList.setModel(myWorkingCopyInfoModel); myWorkingCopiesList .addListSelectionListener(e -> setOKActionEnabled((!myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1))); - setOKActionEnabled((! myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1)); + setOKActionEnabled((!myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1)); final List workingCopyInfoList = new ArrayList<>(); final Set workingCopies = SvnBranchMapperManager.getInstance().get(mySelectedBranchUrl); @@ -129,10 +214,12 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { final String repositoryUUID = SvnUtil.getRepositoryUUID(myVcs, file); // local not consistent copy can not prevent us from integration: only remote local copy is really involved - if ((mySelectedRepositoryUUID != null) && (! mySelectedRepositoryUUID.equals(repositoryUUID))) { - if (Messages.OK == Messages.showOkCancelDialog((repositoryUUID == null) ? message("action.Subversion.integrate.changes.message.not.under.control.text") - : message("action.Subversion.integrate.changes.message.another.wc.text"), - getTitle(), UIUtil.getWarningIcon())) { + if ((mySelectedRepositoryUUID != null) && (!mySelectedRepositoryUUID.equals(repositoryUUID))) { + if (Messages.OK == + Messages.showOkCancelDialog( + (repositoryUUID == null) ? message("action.Subversion.integrate.changes.message.not.under.control.text") + : message("action.Subversion.integrate.changes.message.another.wc.text"), + getTitle(), UIUtil.getWarningIcon())) { onOkToAdd(file); } } @@ -175,6 +262,78 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return contentPane; } + public void setSelectedWcPath(final String path) { final int size = myWorkingCopyInfoModel.getSize(); for (int i = 0; i < size; i++) { @@ -194,12 +353,6 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { myWcListTitleLabel.setText(message("dialog.Subversion.select.working.copy.wcopy.list.title")); } - private void createUIComponents() { - myGroup = new DefaultActionGroup(); - final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("SvnIntegratedSelectedOptionsDialog", myGroup, false); - myToolbar = actionToolbar.getComponent(); - } - private boolean hasDuplicate(final File file) { final String path = file.getAbsolutePath(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/QuickMergeWayOptionsPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/QuickMergeWayOptionsPanel.java index b0dd2ee80c19..71bf6229c307 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/QuickMergeWayOptionsPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/QuickMergeWayOptionsPanel.java @@ -3,28 +3,98 @@ package org.jetbrains.idea.svn.integrate; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.MultiLineLabelUI; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class QuickMergeWayOptionsPanel { - private JButton myMergeAllButton; - private JButton myQuickManualSelectButton; - private JButton mySelectWithPreFilterButton; - private JButton myCancelButton; - private JPanel myMainPanel; - private JLabel myAllNotMergedRevisionsLabel; - private JLabel myShowsAllRevisionsFromLabel; - private JLabel myFindsWhereOneOfLabel; + private final JButton myMergeAllButton; + private final JButton myQuickManualSelectButton; + private final JButton mySelectWithPreFilterButton; + private final JButton myCancelButton; + private final JPanel myMainPanel; + private final JLabel myAllNotMergedRevisionsLabel; + private final JLabel myShowsAllRevisionsFromLabel; + private final JLabel myFindsWhereOneOfLabel; private DialogWrapper myWrapper; private QuickMergeContentsVariants myVariant = QuickMergeContentsVariants.cancel; public QuickMergeWayOptionsPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(8, 4, new Insets(0, 0, 0, 0), -1, -1)); + myMergeAllButton = new JButton(); + this.$$$loadButtonText$$$(myMergeAllButton, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.merge.all")); + myMainPanel.add(myMergeAllButton, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myQuickManualSelectButton = new JButton(); + this.$$$loadButtonText$$$(myQuickManualSelectButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.quick.select")); + myMainPanel.add(myQuickManualSelectButton, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mySelectWithPreFilterButton = new JButton(); + this.$$$loadButtonText$$$(mySelectWithPreFilterButton, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.pre.select")); + myMainPanel.add(mySelectWithPreFilterButton, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCancelButton = new JButton(); + this.$$$loadButtonText$$$(myCancelButton, this.$$$getMessageFromBundle$$$("messages/CommonBundle", "button.cancel")); + myMainPanel.add(myCancelButton, new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myAllNotMergedRevisionsLabel = new JLabel(); + this.$$$loadLabelText$$$(myAllNotMergedRevisionsLabel, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.merge.all.explanation")); + myMainPanel.add(myAllNotMergedRevisionsLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myShowsAllRevisionsFromLabel = new JLabel(); + this.$$$loadLabelText$$$(myShowsAllRevisionsFromLabel, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.quick.select.explanation")); + myMainPanel.add(myShowsAllRevisionsFromLabel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myFindsWhereOneOfLabel = new JLabel(); + this.$$$loadLabelText$$$(myFindsWhereOneOfLabel, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "quick.merge.variants.pre.select.explanation")); + myMainPanel.add(myFindsWhereOneOfLabel, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myMainPanel.add(spacer3, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + myMainPanel.add(spacer4, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + myMainPanel.add(spacer5, new GridConstraints(5, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } myMergeAllButton.addActionListener(setCodeAndClose(QuickMergeContentsVariants.all)); myQuickManualSelectButton.addActionListener(setCodeAndClose(QuickMergeContentsVariants.showLatest)); mySelectWithPreFilterButton.addActionListener(setCodeAndClose(QuickMergeContentsVariants.select)); @@ -39,6 +109,78 @@ public class QuickMergeWayOptionsPanel { myFindsWhereOneOfLabel.setBorder(JBUI.Borders.emptyBottom(10)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private ActionListener setCodeAndClose(@NotNull QuickMergeContentsVariants variant) { return e -> { myVariant = variant; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revision/SvnSelectRevisionPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revision/SvnSelectRevisionPanel.java index 277f2512eb5f..4f2c8c625784 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revision/SvnSelectRevisionPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revision/SvnSelectRevisionPanel.java @@ -5,6 +5,8 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.Revision; @@ -12,17 +14,87 @@ import org.jetbrains.idea.svn.api.Url; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.update.SvnRevisionPanel; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class SvnSelectRevisionPanel extends JPanel { - private SvnRevisionPanel mySvnRevisionPanel; - private JPanel myPanel; + private final SvnRevisionPanel mySvnRevisionPanel; + private final JPanel myPanel; public SvnSelectRevisionPanel() { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + mySvnRevisionPanel = new SvnRevisionPanel(); + myPanel.add(mySvnRevisionPanel.$$$getRootComponent$$$(), + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.update.switch.to.revision")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public void setProject(final Project project) { mySvnRevisionPanel.setProject(project); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegratePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegratePanel.java index 8d948a6cb4ae..74f08db26c03 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegratePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegratePanel.java @@ -3,28 +3,91 @@ package org.jetbrains.idea.svn.update; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.vcs.FilePath; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; -public class SvnIntegratePanel extends AbstractSvnUpdatePanel{ +public class SvnIntegratePanel extends AbstractSvnUpdatePanel { - private JCheckBox myDryRunCheckbox; - private JPanel myRootOptionsPanel; - private JPanel myPanel; - private JCheckBox myUseAncestry; - private DepthCombo myDepthCombo; - private JLabel myDepthLabel; - private JPanel myAdditionalPanel; + private final JCheckBox myDryRunCheckbox; + private final JPanel myRootOptionsPanel; + private final JPanel myPanel; + private final JCheckBox myUseAncestry; + private final DepthCombo myDepthCombo; + private final JLabel myDepthLabel; + private final JPanel myAdditionalPanel; public SvnIntegratePanel(final SvnVcs vcs, Collection roots) { super(vcs); + { + myDepthCombo = new DepthCombo(true); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRootOptionsPanel = new JPanel(); + myPanel.add(myRootOptionsPanel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myAdditionalPanel = new JPanel(); + myAdditionalPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myAdditionalPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUseAncestry = new JCheckBox(); + this.$$$loadButtonText$$$(myUseAncestry, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "action.Subversion.integrate.difference.option.use.ancestry.text")); + myAdditionalPanel.add(myUseAncestry, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myAdditionalPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myDryRunCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myDryRunCheckbox, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "checkbox.update.switch.configurable.try.merge.without.changes")); + myAdditionalPanel.add(myDryRunCheckbox, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myDepthLabel = new JLabel(); + this.$$$loadLabelText$$$(myDepthLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.text")); + myDepthLabel.setToolTipText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.description")); + myAdditionalPanel.add(myDepthLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myAdditionalPanel.add(myDepthCombo, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myAdditionalPanel.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myAdditionalPanel.add(spacer3, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + myPanel.add(spacer4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } init(roots); boolean descend = false; @@ -39,6 +102,78 @@ public class SvnIntegratePanel extends AbstractSvnUpdatePanel{ myDepthLabel.setLabelFor(myDepthCombo); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected SvnPanel createRootPanel(final FilePath root, final SvnVcs p1, Collection roots) { return new SvnIntegrateRootOptionsPanel(myVCS, root); @@ -60,6 +195,7 @@ public class SvnIntegratePanel extends AbstractSvnUpdatePanel{ myDryRunCheckbox.setSelected(configuration.isMergeDryRun()); myUseAncestry.setSelected(configuration.isMergeDiffUseAncestry()); } + @Override public void apply(final SvnConfiguration configuration) throws ConfigurationException { super.apply(configuration); @@ -76,8 +212,4 @@ public class SvnIntegratePanel extends AbstractSvnUpdatePanel{ protected DepthCombo getDepthBox() { return myDepthCombo; } - - private void createUIComponents() { - myDepthCombo = new DepthCombo(true); - } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegrateRootOptionsPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegrateRootOptionsPanel.java index a5a95c232fc9..1b9b1a445b43 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegrateRootOptionsPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnIntegrateRootOptionsPanel.java @@ -4,26 +4,36 @@ package org.jetbrains.idea.svn.update; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vcs.FilePath; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.api.Url; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; + import static com.intellij.openapi.ui.Messages.showErrorDialog; import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces; import static org.jetbrains.idea.svn.SvnBundle.message; import static org.jetbrains.idea.svn.SvnUtil.createUrl; import static org.jetbrains.idea.svn.dialogs.SelectLocationDialog.selectLocation; -public class SvnIntegrateRootOptionsPanel implements SvnPanel{ - private TextFieldWithBrowseButton myMergeText1; - private TextFieldWithBrowseButton myMergeText2; - private JPanel myPanel; - private SvnRevisionPanel myRevision2; - private SvnRevisionPanel myRevision1; +public class SvnIntegrateRootOptionsPanel implements SvnPanel { + private final TextFieldWithBrowseButton myMergeText1; + private final TextFieldWithBrowseButton myMergeText2; + private final JPanel myPanel; + private final SvnRevisionPanel myRevision2; + private final SvnRevisionPanel myRevision1; private final @NotNull FilePath myRoot; private final @NotNull SvnVcs myVcs; @@ -31,6 +41,78 @@ public class SvnIntegrateRootOptionsPanel implements SvnPanel{ public SvnIntegrateRootOptionsPanel(@NotNull SvnVcs vcs, @NotNull FilePath root) { myRoot = root; myVcs = vcs; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "integrate.configuration.description.label")); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "integrate.configuration.source1.label")); + panel2.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMergeText1 = new TextFieldWithBrowseButton(); + panel2.add(myMergeText1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(250, -1), null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "integrate.configuration.revision1.label")); + panel2.add(label3, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRevision1 = new SvnRevisionPanel(); + panel2.add(myRevision1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "integrate.configuration.source2.label")); + panel3.add(label4, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMergeText2 = new TextFieldWithBrowseButton(); + panel3.add(myMergeText2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(250, -1), null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "integrate.configuration.revision2.label")); + panel3.add(label5, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRevision2 = new SvnRevisionPanel(); + panel3.add(myRevision2, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label2.setLabelFor(myMergeText1); + label4.setLabelFor(myMergeText2); + } setupUrlField(myMergeText1); setupUrlField(myMergeText2); @@ -38,6 +120,53 @@ public class SvnIntegrateRootOptionsPanel implements SvnPanel{ setupRevisionField(myRevision2, myMergeText2); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setupUrlField(@NotNull TextFieldWithBrowseButton textField) { textField.setEditable(true); textField.addActionListener(e -> { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnRevisionPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnRevisionPanel.java index b31ddc714011..1e5995e5dae0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnRevisionPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnRevisionPanel.java @@ -7,6 +7,8 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -16,6 +18,9 @@ import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; @@ -23,16 +28,19 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.openapi.ui.Messages.showErrorDialog; import static org.jetbrains.idea.svn.SvnBundle.message; public class SvnRevisionPanel extends JPanel { - private JRadioButton mySpecified; - private JRadioButton myHead; - private JPanel myPanel; - private TextFieldWithBrowseButton myRevisionField; + private final JRadioButton mySpecified; + private final JRadioButton myHead; + private final JPanel myPanel; + private final TextFieldWithBrowseButton myRevisionField; private Project myProject; private ThrowableComputable myUrlProvider; private final List myChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList(); @@ -40,11 +48,36 @@ public class SvnRevisionPanel extends JPanel { public SvnRevisionPanel() { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myHead = new JRadioButton(); + this.$$$loadButtonText$$$(myHead, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "configure.revision.head.radio")); + myPanel.add(myHead, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySpecified = new JRadioButton(); + this.$$$loadButtonText$$$(mySpecified, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "configure.revision.specified.radio")); + myPanel.add(mySpecified, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRevisionField = new TextFieldWithBrowseButton(); + myPanel.add(myRevisionField, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myHead); + buttonGroup.add(mySpecified); + } add(myPanel); myHead.setSelected(true); myRevisionField.addActionListener(e -> chooseRevision()); -// myRevisionField.setEditable(false); + // myRevisionField.setEditable(false); myRevisionField.setEnabled(false); mySpecified.addActionListener(e -> { @@ -74,6 +107,53 @@ public class SvnRevisionPanel extends JPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void chooseRevision() { if (myProject != null && myUrlProvider != null) { try { @@ -129,7 +209,8 @@ public class SvnRevisionPanel extends JPanel { if (revision == Revision.HEAD) { myHead.setSelected(true); myRevisionField.setEnabled(false); - } else { + } + else { myRevisionField.setText(String.valueOf(revision.getNumber())); mySpecified.setSelected(true); myRevisionField.setEnabled(true); @@ -160,7 +241,7 @@ public class SvnRevisionPanel extends JPanel { } private void notifyChangeListeners() { - for(ChangeListener listener: myChangeListeners) { + for (ChangeListener listener : myChangeListeners) { listener.stateChanged(new ChangeEvent(this)); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdatePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdatePanel.java index 36f1e5257de4..5edc9cc7c7c6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdatePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdatePanel.java @@ -2,27 +2,80 @@ package org.jetbrains.idea.svn.update; import com.intellij.openapi.vcs.FilePath; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; public class SvnUpdatePanel extends AbstractSvnUpdatePanel { - private JPanel myConfigureRootsPanel; - private JCheckBox myForceBox; - private JPanel myPanel; - private DepthCombo myDepthCombo; - private JLabel myDepthLabel; - private JPanel myAdditionalPanel; - private JCheckBox myIgnoreExternalsCheckBox; + private final JPanel myConfigureRootsPanel; + private final JCheckBox myForceBox; + private final JPanel myPanel; + private final DepthCombo myDepthCombo; + private final JLabel myDepthLabel; + private final JPanel myAdditionalPanel; + private final JCheckBox myIgnoreExternalsCheckBox; public SvnUpdatePanel(SvnVcs vcs, Collection roots) { super(vcs); + { + myDepthCombo = new DepthCombo(true); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new BorderLayout(0, 0)); + myPanel.add(panel1, BorderLayout.CENTER); + myAdditionalPanel = new JPanel(); + myAdditionalPanel.setLayout(new GridLayoutManager(4, 3, new Insets(10, 0, 0, 0), -1, -1)); + panel1.add(myAdditionalPanel, BorderLayout.CENTER); + final Spacer spacer1 = new Spacer(); + myAdditionalPanel.add(spacer1, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myDepthLabel = new JLabel(); + this.$$$loadLabelText$$$(myDepthLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.text")); + myDepthLabel.setToolTipText(this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.depth.description")); + myAdditionalPanel.add(myDepthLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 1, false)); + myForceBox = new JCheckBox(); + this.$$$loadButtonText$$$(myForceBox, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkbox.force.update")); + myAdditionalPanel.add(myForceBox, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIgnoreExternalsCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myIgnoreExternalsCheckBox, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "checkbox.ignore.externals")); + myIgnoreExternalsCheckBox.setVisible(true); + myAdditionalPanel.add(myIgnoreExternalsCheckBox, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAdditionalPanel.add(myDepthCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myConfigureRootsPanel = new JPanel(); + myConfigureRootsPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myConfigureRootsPanel, BorderLayout.NORTH); + } init(roots); boolean descend = false; @@ -43,6 +96,78 @@ public class SvnUpdatePanel extends AbstractSvnUpdatePanel { myIgnoreExternalsCheckBox.addActionListener(e -> svnConfiguration.setIgnoreExternals(myIgnoreExternalsCheckBox.isSelected())); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected JPanel getRootsPanel() { return myConfigureRootsPanel; @@ -67,8 +192,4 @@ public class SvnUpdatePanel extends AbstractSvnUpdatePanel { protected DepthCombo getDepthBox() { return myDepthCombo; } - - private void createUIComponents() { - myDepthCombo = new DepthCombo(true); - } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateRootOptionsPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateRootOptionsPanel.java index 085dee0f7fac..bd868ceff4c6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateRootOptionsPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateRootOptionsPanel.java @@ -6,6 +6,9 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.FilePathUtil; import org.jetbrains.idea.svn.NestedCopyType; @@ -23,35 +26,111 @@ import org.jetbrains.idea.svn.dialogs.SelectLocationDialog; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; import static com.intellij.openapi.ui.Messages.showErrorDialog; import static org.jetbrains.idea.svn.SvnBundle.message; import static org.jetbrains.idea.svn.SvnUtil.createUrl; -public class SvnUpdateRootOptionsPanel implements SvnPanel{ +public class SvnUpdateRootOptionsPanel implements SvnPanel { private static final Logger LOG = Logger.getInstance(SvnUpdateRootOptionsPanel.class); - private TextFieldWithBrowseButton myURLText; - private JCheckBox myRevisionBox; - private TextFieldWithBrowseButton myRevisionText; + private final TextFieldWithBrowseButton myURLText; + private final JCheckBox myRevisionBox; + private final TextFieldWithBrowseButton myRevisionText; private final SvnVcs myVcs; - private JPanel myPanel; + private final JPanel myPanel; private final FilePath myRoot; - private JCheckBox myUpdateToSpecificUrl; - private TextFieldWithBrowseButton myBranchField; - private JLabel myBranchLabel; - private JLabel myUrlLabel; - private JLabel myCopyType; + private final JCheckBox myUpdateToSpecificUrl; + private final TextFieldWithBrowseButton myBranchField; + private final JLabel myBranchLabel; + private final JLabel myUrlLabel; + private final JLabel myCopyType; private @Nullable Url mySourceUrl; public SvnUpdateRootOptionsPanel(FilePath root, final SvnVcs vcs, Collection roots) { myRoot = root; myVcs = vcs; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myUpdateToSpecificUrl = new JCheckBox(); + this.$$$loadButtonText$$$(myUpdateToSpecificUrl, + this.$$$getMessageFromBundle$$$("messages/SvnBundle", "update.configuration.specific.url")); + panel1.add(myUpdateToSpecificUrl, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCopyType = new JLabel(); + myCopyType.setText(""); + panel1.add(myCopyType, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myURLText = new TextFieldWithBrowseButton(); + panel2.add(myURLText, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBranchField = new TextFieldWithBrowseButton(); + panel2.add(myBranchField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUrlLabel = new JLabel(); + this.$$$loadLabelText$$$(myUrlLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "label.update.url")); + panel2.add(myUrlLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myBranchLabel = new JLabel(); + this.$$$loadLabelText$$$(myBranchLabel, this.$$$getMessageFromBundle$$$("messages/SvnBundle", "update.switch.to.branch.text")); + panel2.add(myBranchLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myRevisionBox = new JCheckBox(); + this.$$$loadButtonText$$$(myRevisionBox, this.$$$getMessageFromBundle$$$("messages/SvnBundle", + "checkbox.update.switch.configurable.to.specific.revision")); + panel3.add(myRevisionBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel3.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myRevisionText = new TextFieldWithBrowseButton(); + panel3.add(myRevisionText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(100, -1), new Dimension(100, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myURLText.setEditable(true); myURLText.addActionListener(e -> chooseUrl()); @@ -80,7 +159,8 @@ public class SvnUpdateRootOptionsPanel implements SvnPanel{ myRevisionText.setText("HEAD"); } myRevisionText.getTextField().selectAll(); - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myRevisionText, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myRevisionText, true)); } } }); @@ -109,11 +189,83 @@ public class SvnUpdateRootOptionsPanel implements SvnPanel{ final boolean revisionCanBeSpecifiedForRoot = !FilePathUtil.isNested(roots, myRoot) || isRevisionCanBeSpecifiedForRoot(); myRevisionBox.setEnabled(revisionCanBeSpecifiedForRoot); myRevisionText.setEnabled(revisionCanBeSpecifiedForRoot); - myCopyType.setVisible(! revisionCanBeSpecifiedForRoot); + myCopyType.setVisible(!revisionCanBeSpecifiedForRoot); myCopyType.setFont(myCopyType.getFont().deriveFont(Font.ITALIC)); myUpdateToSpecificUrl.setEnabled(revisionCanBeSpecifiedForRoot); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private boolean isRevisionCanBeSpecifiedForRoot() { final RootUrlInfo info = myVcs.getSvnFileUrlMapping().getWcRootForFilePath(myRoot); if (info == null) return true; @@ -215,8 +367,8 @@ public class SvnUpdateRootOptionsPanel implements SvnPanel{ rootInfo.setUpdateToRevision(myRevisionBox.isSelected()); final Revision revision = Revision.parse(myRevisionText.getText()); - if (!revision.isValid()) { - throw new ConfigurationException(message("error.invalid.svn.revision", myRevisionText.getText())); + if (!revision.isValid()) { + throw new ConfigurationException(message("error.invalid.svn.revision", myRevisionText.getText())); } rootInfo.setRevision(revision); } diff --git a/plugins/tasks/tasks-api/src/com/intellij/tasks/config/BaseRepositoryEditor.java b/plugins/tasks/tasks-api/src/com/intellij/tasks/config/BaseRepositoryEditor.java index 7fd1d201c6ce..c51b2f9922a4 100644 --- a/plugins/tasks/tasks-api/src/com/intellij/tasks/config/BaseRepositoryEditor.java +++ b/plugins/tasks/tasks-api/src/com/intellij/tasks/config/BaseRepositoryEditor.java @@ -20,53 +20,62 @@ import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTabbedPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Consumer; import com.intellij.util.net.HttpConfigurable; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.JTextPane; import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev */ public class BaseRepositoryEditor extends TaskRepositoryEditor implements PanelWithAnchor { - protected JBLabel myUrlLabel; - protected JTextField myURLText; - protected JTextField myUserNameText; - protected JBLabel myUsernameLabel; - protected JCheckBox myShareUrlCheckBox; - protected JPasswordField myPasswordText; - protected JBLabel myPasswordLabel; + protected final JBLabel myUrlLabel; + protected final JTextField myURLText; + protected final JTextField myUserNameText; + protected final JBLabel myUsernameLabel; + protected final JCheckBox myShareUrlCheckBox; + protected final JPasswordField myPasswordText; + protected final JBLabel myPasswordLabel; - protected JButton myTestButton; - private JPanel myPanel; - private JBCheckBox myUseProxy; - private JButton myProxySettingsButton; - protected JCheckBox myUseHttpAuthenticationCheckBox; + protected final JButton myTestButton; + private final JPanel myPanel; + private final JBCheckBox myUseProxy; + private final JButton myProxySettingsButton; + protected final JCheckBox myUseHttpAuthenticationCheckBox; - protected JPanel myCustomPanel; - private JBCheckBox myAddCommitMessage; - private JBLabel myComment; - private JPanel myEditorPanel; - protected JBCheckBox myLoginAnonymouslyJBCheckBox; - protected JBTabbedPane myTabbedPane; - private JTextPane myAdvertiser; + protected final JPanel myCustomPanel; + private final JBCheckBox myAddCommitMessage; + private final JBLabel myComment; + private final JPanel myEditorPanel; + protected final JBCheckBox myLoginAnonymouslyJBCheckBox; + protected final JBTabbedPane myTabbedPane; + private final JTextPane myAdvertiser; private boolean myApplying; protected Project myProject; @@ -80,6 +89,139 @@ public class BaseRepositoryEditor extends TaskReposito myProject = project; myRepository = repository; myChangeListener = changeListener; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setMaximumSize(new Dimension(-1, -1)); + myPanel.setMinimumSize(new Dimension(480, 265)); + myPanel.setPreferredSize(new Dimension(-1, -1)); + myTabbedPane = new JBTabbedPane(); + myPanel.add(myTabbedPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(9, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setMaximumSize(new Dimension(-1, -1)); + panel1.setMinimumSize(new Dimension(-1, -1)); + panel1.setPreferredSize(new Dimension(-1, -1)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "general"), panel1); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myUrlLabel = new JBLabel(); + myUrlLabel.setHorizontalAlignment(4); + this.$$$loadLabelText$$$(myUrlLabel, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "server.u.rl")); + panel1.add(myUrlLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myURLText = new JTextField(); + panel1.add(myURLText, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myCustomPanel = new JPanel(); + myCustomPanel.setLayout(new BorderLayout(0, 0)); + panel1.add(myCustomPanel, new GridConstraints(5, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUseProxy = new JBCheckBox(); + myUseProxy.setHorizontalAlignment(4); + this.$$$loadButtonText$$$(myUseProxy, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "use.prox.y")); + panel1.add(myUseProxy, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myProxySettingsButton = new JButton(); + this.$$$loadButtonText$$$(myProxySettingsButton, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "pr.oxy.settings")); + panel1.add(myProxySettingsButton, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseHttpAuthenticationCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseHttpAuthenticationCheckBox, + this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "use.http.authentication")); + panel1.add(myUseHttpAuthenticationCheckBox, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(6, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myTestButton = new JButton(); + this.$$$loadButtonText$$$(myTestButton, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "te.st")); + panel1.add(myTestButton, new GridConstraints(7, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShareUrlCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myShareUrlCheckBox, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "sh.are.url")); + panel1.add(myShareUrlCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLoginAnonymouslyJBCheckBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myLoginAnonymouslyJBCheckBox, + this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "lo.gin.anonymously")); + panel1.add(myLoginAnonymouslyJBCheckBox, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUsernameLabel = new JBLabel(); + myUsernameLabel.setHorizontalAlignment(4); + this.$$$loadLabelText$$$(myUsernameLabel, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "userna.me")); + panel1.add(myUsernameLabel, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUserNameText = new JTextField(); + myUserNameText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "use.domain.login.format.for.ntlm.authentication")); + panel1.add(myUserNameText, new GridConstraints(3, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myPasswordLabel = new JBLabel(); + myPasswordLabel.setHorizontalAlignment(4); + this.$$$loadLabelText$$$(myPasswordLabel, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "password")); + panel1.add(myPasswordLabel, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPasswordText = new JPasswordField(); + panel1.add(myPasswordText, new GridConstraints(4, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myAdvertiser = new JTextPane(); + myAdvertiser.setEditable(false); + myAdvertiser.setEnabled(true); + myAdvertiser.setText(this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "not.youtrack.customer.yet.get.youtrack")); + panel1.add(myAdvertiser, new GridConstraints(0, 2, 1, 2, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.setMaximumSize(new Dimension(-1, -1)); + panel2.setMinimumSize(new Dimension(-1, -1)); + panel2.setPreferredSize(new Dimension(-1, -1)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "commit.message"), panel2); + myComment = new JBLabel(); + myComment.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myComment.setFontColor(UIUtil.FontColor.BRIGHTER); + this.$$$loadLabelText$$$(myComment, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "use")); + panel2.add(myComment, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddCommitMessage = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddCommitMessage, this.$$$getMessageFromBundle$$$("messages/TaskApiBundle", "add.commit.message")); + panel2.add(myAddCommitMessage, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(myEditorPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUrlLabel.setLabelFor(myURLText); + myUsernameLabel.setLabelFor(myUserNameText); + myPasswordLabel.setLabelFor(myPasswordText); + } myTestButton.addActionListener(new ActionListener() { @Override @@ -156,6 +298,78 @@ public class BaseRepositoryEditor extends TaskReposito loginAnonymouslyChanged(!myLoginAnonymouslyJBCheckBox.isSelected()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setupPlaceholdersComment() { StringBuilder comment = new StringBuilder(); for (CommitPlaceholderProvider extension : CommitPlaceholderProvider.EXTENSION_POINT_NAME.getExtensionList()) { diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ChooseStacktraceDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ChooseStacktraceDialog.java index b9f45c475c4c..86b1e8d2e2b0 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ChooseStacktraceDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ChooseStacktraceDialog.java @@ -8,7 +8,11 @@ import com.intellij.tasks.Comment; import com.intellij.tasks.Task; import com.intellij.tasks.TaskBundle; import com.intellij.ui.CollectionListModel; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.dsl.listCellRenderer.BuilderKt; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.unscramble.AnalyzeStacktraceUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; @@ -20,6 +24,7 @@ import javax.swing.JPanel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; +import java.awt.Insets; import java.util.ArrayList; import java.util.Date; @@ -28,13 +33,34 @@ import java.util.Date; */ public class ChooseStacktraceDialog extends DialogWrapper { - private JList myList; - private JPanel myPanel; - private JPanel myEditorPanel; + private final JList myList; + private final JPanel myPanel; + private final JPanel myEditorPanel; private final AnalyzeStacktraceUtil.StacktraceEditorPanel myEditor; public ChooseStacktraceDialog(Project project, final Task issue) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myList = new JBList(); + myList.setVisibleRowCount(4); + jBScrollPane1.setViewportView(myList); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myEditorPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + } setTitle(TaskBundle.message("dialog.title.choose.stacktrace.to.analyze")); Comment[] comments = issue.getComments(); @@ -47,8 +73,8 @@ public class ChooseStacktraceDialog extends DialogWrapper { myList.setModel(new CollectionListModel<>(list)); myList.setCellRenderer(BuilderKt.textListCellRenderer(o -> - o instanceof Description ? TaskBundle.message("label.description") : - TaskBundle.message("label.commented.by", o.getAuthor(), o.getDate()))); + o instanceof Description ? TaskBundle.message("label.description") : + TaskBundle.message("label.commented.by", o.getAuthor(), o.getDate()))); myEditor = AnalyzeStacktraceUtil.createEditorPanel(project, myDisposable); myEditorPanel.add(myEditor, BorderLayout.CENTER); myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @@ -62,6 +88,9 @@ public class ChooseStacktraceDialog extends DialogWrapper { init(); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myList; diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/CloseTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/CloseTaskDialog.java index 899ec3759ffd..404115c46f51 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/CloseTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/CloseTaskDialog.java @@ -14,17 +14,25 @@ import com.intellij.tasks.impl.TaskUtil; import com.intellij.tasks.ui.TaskDialogPanel; import com.intellij.tasks.ui.TaskDialogPanelProvider; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -35,15 +43,68 @@ public class CloseTaskDialog extends DialogWrapper { private final Project myProject; private final List myPanels; - private JPanel myPanel; - private JLabel myTaskLabel; - private TaskStateCombo myStateCombo; - private JBCheckBox myUpdateState; - private JPanel myAdditionalPanel; + private final JPanel myPanel; + private final JLabel myTaskLabel; + private final TaskStateCombo myStateCombo; + private final JBCheckBox myUpdateState; + private final JPanel myAdditionalPanel; public CloseTaskDialog(Project project, final LocalTask task) { super(project, false); myProject = project; + { + myStateCombo = new TaskStateCombo() { + @Override + protected @Nullable CustomTaskState getPreferredState(@NotNull TaskRepository repository, + @NotNull Collection available) { + return repository.getPreferredCloseTaskState(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "close.task")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(35, 14), null, 0, false)); + myTaskLabel = new JLabel(); + this.$$$loadLabelText$$$(myTaskLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "task.description")); + myPanel.add(myTaskLabel, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + panel1.add(myStateCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myUpdateState = new JBCheckBox(); + this.$$$loadButtonText$$$(myUpdateState, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "update.issue.state")); + panel1.add(myUpdateState, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAdditionalPanel = new JPanel(); + myAdditionalPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myAdditionalPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + } myStateCombo.setProject(myProject); myStateCombo.setTask(task); @@ -85,6 +146,78 @@ public class CloseTaskDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void doOKAction() { for (TaskDialogPanel panel : myPanels) { @@ -107,13 +240,4 @@ public class CloseTaskDialog extends DialogWrapper { CustomTaskState getCloseIssueState() { return myUpdateState.isSelected() ? myStateCombo.getSelectedState() : null; } - - private void createUIComponents() { - myStateCombo = new TaskStateCombo() { - @Override - protected @Nullable CustomTaskState getPreferredState(@NotNull TaskRepository repository, @NotNull Collection available) { - return repository.getPreferredCloseTaskState(); - } - }; - } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/EditTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/EditTaskDialog.java index 396e45d551ce..06b0962554e3 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/EditTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/EditTaskDialog.java @@ -16,16 +16,24 @@ import com.intellij.tasks.impl.LocalTaskImpl; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.ComboboxSpeedSearch; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -34,12 +42,12 @@ public class EditTaskDialog extends DialogWrapper { private final LocalTaskImpl myTask; - private JPanel myPanel; - private JTextField mySummary; - private JBLabel myBranchLabel; - private ComboBox myBranch; - private JBLabel myChangelistLabel; - private ComboBox myChangelist; + private final JPanel myPanel; + private final JTextField mySummary; + private final JBLabel myBranchLabel; + private final ComboBox myBranch; + private final JBLabel myChangelistLabel; + private final ComboBox myChangelist; public static void editTask(LocalTaskImpl task, Project project) { new EditTaskDialog(project, task).show(); @@ -48,6 +56,46 @@ public class EditTaskDialog extends DialogWrapper { protected EditTaskDialog(Project project, LocalTaskImpl task) { super(project); myTask = task; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myBranchLabel = new JBLabel(); + this.$$$loadLabelText$$$(myBranchLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "associated.branch")); + myPanel.add(myBranchLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myBranch = new ComboBox(); + myPanel.add(myBranch, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myChangelistLabel = new JBLabel(); + this.$$$loadLabelText$$$(myChangelistLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "associated.change.list")); + myPanel.add(myChangelistLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myChangelist = new ComboBox(); + myPanel.add(myChangelist, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "label.summary")); + myPanel.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySummary = new JTextField(); + myPanel.add(mySummary, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + new Dimension(300, -1), null, null, 0, false)); + myBranchLabel.setLabelFor(myBranch); + myChangelistLabel.setLabelFor(myChangelist); + jBLabel1.setLabelFor(mySummary); + } setTitle(TaskBundle.message("dialog.title.edit.task.choice", task.getPresentableId(), task.isIssue() ? 0 : 1)); mySummary.setText(task.getSummary()); @@ -105,6 +153,53 @@ public class EditTaskDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void doOKAction() { myTask.setSummary(mySummary.getText()); //NON-NLS diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java index a1f74938013f..d1d910834a1a 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java @@ -24,19 +24,28 @@ import com.intellij.tasks.ui.TaskDialogPanelProvider; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Collection; import java.util.List; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev @@ -45,12 +54,12 @@ public class OpenTaskDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance(OpenTaskDialog.class); private static final String UPDATE_STATE_ENABLED = "tasks.open.task.update.state.enabled"; - private JPanel myPanel; - private JCheckBox myClearContext; - private JBCheckBox myUpdateState; - private TaskStateCombo myTaskStateCombo; - private JPanel myAdditionalPanel; - private JBTextField myNameField; + private final JPanel myPanel; + private final JCheckBox myClearContext; + private final JBCheckBox myUpdateState; + private final TaskStateCombo myTaskStateCombo; + private final JPanel myAdditionalPanel; + private final JBTextField myNameField; private final Project myProject; private final LocalTaskImpl myTask; @@ -59,6 +68,66 @@ public class OpenTaskDialog extends DialogWrapper { public OpenTaskDialog(final @NotNull Project project, final @NotNull Task task) { super(project, false); myProject = project; + { + myTaskStateCombo = new TaskStateCombo() { + @Override + protected @Nullable CustomTaskState getPreferredState(@NotNull TaskRepository repository, + @NotNull Collection available) { + return repository.getPreferredOpenTaskState(); + } + }; + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(5, 0, 10, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameField = new JBTextField(); + panel1.add(myNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myAdditionalPanel = new JPanel(); + myAdditionalPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + myPanel.add(myAdditionalPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + panel2.add(myTaskStateCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUpdateState = new JBCheckBox(); + this.$$$loadButtonText$$$(myUpdateState, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "update.issue.state1")); + panel2.add(myUpdateState, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(149, 24), null, 0, false)); + myClearContext = new JCheckBox(); + myClearContext.setFocusable(true); + myClearContext.setSelected(true); + this.$$$loadButtonText$$$(myClearContext, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "clear.current.context")); + panel2.add(myClearContext, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(149, 24), null, 0, false)); + label1.setLabelFor(myNameField); + } myTask = new LocalTaskImpl(task); myTaskStateCombo.setProject(myProject); myTaskStateCombo.setTask(myTask); @@ -116,6 +185,78 @@ public class OpenTaskDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateFields() { myTaskStateCombo.setEnabled(myUpdateState.isSelected()); } @@ -179,7 +320,7 @@ public class OpenTaskDialog extends DialogWrapper { return component; } } - if (myTaskStateCombo.isVisible() && myTaskStateCombo.isEnabled()){ + if (myTaskStateCombo.isVisible() && myTaskStateCombo.isEnabled()) { return myTaskStateCombo.getComboBox(); } return null; @@ -202,13 +343,4 @@ public class OpenTaskDialog extends DialogWrapper { protected JComponent createCenterPanel() { return myPanel; } - - private void createUIComponents() { - myTaskStateCombo = new TaskStateCombo() { - @Override - protected @Nullable CustomTaskState getPreferredState(@NotNull TaskRepository repository, @NotNull Collection available) { - return repository.getPreferredOpenTaskState(); - } - }; - } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsCloseTaskPanel.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsCloseTaskPanel.java index c7401eb7c040..832450bd5839 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsCloseTaskPanel.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsCloseTaskPanel.java @@ -10,23 +10,33 @@ import com.intellij.tasks.LocalTask; import com.intellij.tasks.TaskManager; import com.intellij.tasks.impl.TaskManagerImpl; import com.intellij.tasks.ui.TaskDialogPanel; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev */ public class VcsCloseTaskPanel extends TaskDialogPanel { - private JPanel myPanel; - private JPanel myVcsPanel; - private JCheckBox myCommitChanges; - private JBCheckBox myMergeBranches; + private final JPanel myPanel; + private final JPanel myVcsPanel; + private final JCheckBox myCommitChanges; + private final JBCheckBox myMergeBranches; private final Project myProject; private final LocalTask myTask; @@ -35,9 +45,41 @@ public class VcsCloseTaskPanel extends TaskDialogPanel { public VcsCloseTaskPanel(Project project, LocalTask task) { myProject = project; myTask = task; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myVcsPanel = new JPanel(); + myVcsPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myVcsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanel.add(myVcsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myVcsPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/TaskBundle", "vcs.operations"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCommitChanges = new JCheckBox(); + this.$$$loadButtonText$$$(myCommitChanges, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "commit.changes")); + myVcsPanel.add(myCommitChanges, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myVcsPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myMergeBranches = new JBCheckBox(); + this.$$$loadButtonText$$$(myMergeBranches, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "merge.branche.s")); + myVcsPanel.add(myMergeBranches, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + } myTaskManager = (TaskManagerImpl)TaskManager.getManager(project); - + boolean hasChanges = !task.getChangeLists().isEmpty(); myCommitChanges.setEnabled(hasChanges); myCommitChanges.setSelected(hasChanges && myTaskManager.getState().commitChanges); @@ -49,9 +91,55 @@ public class VcsCloseTaskPanel extends TaskDialogPanel { else { myMergeBranches.setVisible(false); } - } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @NotNull JComponent getPanel() { return myPanel; @@ -64,7 +152,7 @@ public class VcsCloseTaskPanel extends TaskDialogPanel { boolean isMergeBranch() { return myMergeBranches.isSelected(); } - + @Override public void commit() { @@ -74,7 +162,7 @@ public class VcsCloseTaskPanel extends TaskDialogPanel { if (myMergeBranches.isEnabled()) { myTaskManager.getState().mergeBranch = isMergeBranch(); } - + if (isCommitChanges()) { ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); for (ChangeListInfo info : myTask.getChangeLists()) { @@ -87,6 +175,5 @@ public class VcsCloseTaskPanel extends TaskDialogPanel { if (isMergeBranch()) { myTaskManager.mergeBranch(myTask); } - } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsOpenTaskPanel.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsOpenTaskPanel.java index bbfe25a4fa09..0b0fb8e9886c 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsOpenTaskPanel.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsOpenTaskPanel.java @@ -18,39 +18,52 @@ import com.intellij.tasks.impl.TaskManagerImpl; import com.intellij.tasks.impl.TaskUtil; import com.intellij.tasks.ui.TaskDialogPanel; import com.intellij.ui.ComboboxSpeedSearch; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; import com.intellij.ui.scale.JBUIScale; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; /** * @author Dmitry Avdeev */ public class VcsOpenTaskPanel extends TaskDialogPanel { - private JPanel myPanel; - private JTextField myBranchName; - private JTextField myChangelistName; - private JBRadioButton myCreateBranch; - private JBCheckBox myCreateChangelist; - private ComboBox myBranchFrom; - private JBLabel myFromLabel; - private JBRadioButton myUseBranch; - private ComboBox myUseBranchCombo; - private JBCheckBox myShelveChanges; - private JBRadioButton myDoNotAssociateBranch; + private final JPanel myPanel; + private final JTextField myBranchName; + private final JTextField myChangelistName; + private final JBRadioButton myCreateBranch; + private final JBCheckBox myCreateChangelist; + private final ComboBox myBranchFrom; + private final JBLabel myFromLabel; + private final JBRadioButton myUseBranch; + private final ComboBox myUseBranchCombo; + private final JBCheckBox myShelveChanges; + private final JBRadioButton myDoNotAssociateBranch; private VcsTaskHandler myVcsTaskHandler; private static final String START_FROM_BRANCH = "start.from.branch"; @@ -61,6 +74,84 @@ public class VcsOpenTaskPanel extends TaskDialogPanel { public VcsOpenTaskPanel(Project project, LocalTask task) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + panel1.add(myPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + myPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/TaskBundle", + "vcs.operations"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myBranchName = new JTextField(); + myBranchName.setEnabled(false); + myPanel.add(myBranchName, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myCreateBranch = new JBRadioButton(); + this.$$$loadButtonText$$$(myCreateBranch, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "create.branch")); + myPanel.add(myCreateBranch, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBranchFrom = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + myBranchFrom.setModel(defaultComboBoxModel1); + myPanel.add(myBranchFrom, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myFromLabel = new JBLabel(); + this.$$$loadLabelText$$$(myFromLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "from")); + myPanel.add(myFromLabel, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myUseBranch = new JBRadioButton(); + this.$$$loadButtonText$$$(myUseBranch, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "u.se.branch")); + myPanel.add(myUseBranch, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseBranchCombo = new ComboBox(); + myPanel.add(myUseBranchCombo, new GridConstraints(3, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCreateChangelist = new JBCheckBox(); + this.$$$loadButtonText$$$(myCreateChangelist, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "create.change.list")); + myPanel.add(myCreateChangelist, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myChangelistName = new JTextField(); + myChangelistName.setEnabled(false); + myPanel.add(myChangelistName, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myShelveChanges = new JBCheckBox(); + this.$$$loadButtonText$$$(myShelveChanges, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "s.helve.current.changes")); + myPanel.add(myShelveChanges, + new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myDoNotAssociateBranch = new JBRadioButton(); + myDoNotAssociateBranch.setSelected(true); + this.$$$loadButtonText$$$(myDoNotAssociateBranch, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "do.not.associate.branch")); + myPanel.add(myDoNotAssociateBranch, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFromLabel.setLabelFor(myBranchFrom); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myDoNotAssociateBranch); + buttonGroup.add(myUseBranch); + buttonGroup.add(myCreateBranch); + } myTaskManager = (TaskManagerImpl)TaskManager.getManager(project); myProject = project; myTask = task; @@ -170,14 +261,84 @@ public class VcsOpenTaskPanel extends TaskDialogPanel { updateFields(true); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + private String getChangelistName(Task task) { return myTaskManager.getChangelistName(task); } private @NotNull String getBranchName(Task task) { String branchName = myTaskManager.suggestBranchName(task, StringUtil.notNullize(TaskSettings.getInstance().REPLACE_SPACES)); - if (myVcsTaskHandler != null) + if (myVcsTaskHandler != null) { myVcsTaskHandler.cleanUpBranchName(branchName); + } return TaskSettings.getInstance().LOWER_CASE_BRANCH ? StringUtil.toLowerCase(branchName) : branchName; } @@ -221,7 +382,7 @@ public class VcsOpenTaskPanel extends TaskDialogPanel { VcsTaskHandler.TaskInfo branchFrom = (VcsTaskHandler.TaskInfo)myBranchFrom.getSelectedItem(); Runnable createBranch = () -> myTaskManager.createBranch(myTask, myPreviousTask, myBranchName.getText(), branchFrom); VcsTaskHandler.TaskInfo[] current = myVcsTaskHandler.getCurrentTasks(); - if (branchFrom != null && (current.length == 0 || !current[0].equals(branchFrom))) { + if (branchFrom != null && (current.length == 0 || !current[0].equals(branchFrom))) { myVcsTaskHandler.switchToTask(branchFrom, createBranch); } else { @@ -248,7 +409,8 @@ public class VcsOpenTaskPanel extends TaskDialogPanel { else if (myVcsTaskHandler != null) { return myVcsTaskHandler.isBranchNameValid(branchName) ? null - : new ValidationInfo(TaskBundle.message("dialog.message.branch.name.not.valid.check.your.vcs.branch.name.restrictions"), myBranchName); + : new ValidationInfo(TaskBundle.message("dialog.message.branch.name.not.valid.check.your.vcs.branch.name.restrictions"), + myBranchName); } else if (branchName.contains(" ")) { return new ValidationInfo(TaskBundle.message("dialog.message.branch.name.should.not.contain.spaces"), myBranchName); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java index 3ab172d39bc5..f30b6a0f199a 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java @@ -29,25 +29,33 @@ import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.Consumer; import com.intellij.util.containers.ConcurrentFactoryMap; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; /** @@ -58,15 +66,15 @@ public class TaskRepositoriesConfigurable implements Configurable.NoScroll, Sear public static final String ID = "tasks.servers"; private static final String EMPTY_PANEL = "empty.panel"; - private JPanel myPanel; - private JPanel myServersPanel; + private final JPanel myPanel; + private final JPanel myServersPanel; private final JBList myRepositoriesList; @SuppressWarnings("UnusedDeclaration") private JPanel myToolbarPanel; - private JPanel myRepositoryEditor; - private JBLabel myServersLabel; - private Splitter mySplitter; - private JPanel myEmptyPanel; + private final JPanel myRepositoryEditor; + private final JBLabel myServersLabel; + private final Splitter mySplitter; + private final JPanel myEmptyPanel; private final List myRepositories = new ArrayList<>(); private final List myEditors = new ArrayList<>(); @@ -80,6 +88,48 @@ public class TaskRepositoriesConfigurable implements Configurable.NoScroll, Sear public TaskRepositoriesConfigurable(final Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myServersLabel = new JBLabel(); + this.$$$loadLabelText$$$(myServersLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "settings.configured.servers")); + myPanel.add(myServersLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myServersPanel = new JPanel(); + myServersPanel.setLayout(new BorderLayout(0, 0)); + myPanel.add(myServersPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(0, 50), null, 0, false)); + myRepositoryEditor = new JPanel(); + myRepositoryEditor.setLayout(new CardLayout(0, 0)); + myPanel.add(myRepositoryEditor, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + null, null, null, 0, false)); + myEmptyPanel = new JPanel(); + myEmptyPanel.setLayout(new BorderLayout(0, 0)); + myRepositoryEditor.add(myEmptyPanel, "Card1"); + myEmptyPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(100, 220, 100, 220), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setHorizontalAlignment(0); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "settings.no.server.selected")); + myEmptyPanel.add(jBLabel1, BorderLayout.CENTER); + mySplitter = new Splitter(); + mySplitter.setOrientation(true); + myPanel.add(mySplitter, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + mySplitter.setFirstComponent(myServersPanel); + mySplitter.setSecondComponent(myRepositoryEditor); + } myManager = (TaskManagerImpl)TaskManager.getManager(project); myRepositoriesList = new JBList<>(); @@ -130,9 +180,10 @@ public class TaskRepositoriesConfigurable implements Configurable.NoScroll, Sear } JBPopupFactory.getInstance() - .createActionGroupPopup(TaskBundle.message("popup.title.add.server"), group, DataManager.getInstance().getDataContext(anActionButton.getContextComponent()), + .createActionGroupPopup(TaskBundle.message("popup.title.add.server"), group, + DataManager.getInstance().getDataContext(anActionButton.getContextComponent()), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show( - anActionButton.getPreferredPopupPoint()); + anActionButton.getPreferredPopupPoint()); } }); @@ -182,6 +233,53 @@ public class TaskRepositoriesConfigurable implements Configurable.NoScroll, Sear myChangeListener = repository -> getListModel().contentsChanged(repository); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private CollectionListModel getListModel() { return (CollectionListModel)myRepositoriesList.getModel(); } @@ -244,7 +342,7 @@ public class TaskRepositoriesConfigurable implements Configurable.NoScroll, Sear myRepoNames.clear(); myRepositoryEditor.removeAll(); myRepositoryEditor.add(myEmptyPanel, EMPTY_PANEL); -// ((CardLayout)myRepositoryEditor.getLayout()).show(myRepositoryEditor, ); + // ((CardLayout)myRepositoryEditor.getLayout()).show(myRepositoryEditor, ); myRepositories.clear(); CollectionListModel listModel = new CollectionListModel<>(new ArrayList<>()); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryEditor.java index 40fd2e3c7061..0f3e57d86793 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryEditor.java @@ -10,6 +10,9 @@ import com.intellij.ui.EditorTextField; import com.intellij.ui.TextFieldWithAutoCompletion; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.net.HTTPMethod; @@ -18,19 +21,27 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.SwingConstants; import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import static com.intellij.tasks.generic.GenericRepositoryUtil.concat; import static com.intellij.tasks.generic.GenericRepositoryUtil.createPlaceholdersList; @@ -43,23 +54,23 @@ import static com.intellij.ui.TextFieldWithAutoCompletion.StringsCompletionProvi */ public class GenericRepositoryEditor extends BaseRepositoryEditor { - protected EditorTextField myLoginURLText; - private EditorTextField myTasksListURLText; - private EditorTextField mySingleTaskURLText; - protected JBLabel myLoginURLLabel; - protected ComboBox myLoginMethodTypeComboBox; - private ComboBox myTasksListMethodTypeComboBox; - private ComboBox mySingleTaskMethodComboBox; - private JPanel myPanel; - private JRadioButton myXmlRadioButton; - private JRadioButton myTextRadioButton; - private JButton myTest2Button; - private JRadioButton myJsonRadioButton; - private JButton myManageTemplateVariablesButton; - private JButton myResetToDefaultsButton; - private JPanel myCardPanel; - private JBLabel mySingleTaskURLLabel; - private JBCheckBox myDownloadTasksInSeparateRequests; + protected final EditorTextField myLoginURLText; + private final EditorTextField myTasksListURLText; + private final EditorTextField mySingleTaskURLText; + protected final JBLabel myLoginURLLabel; + protected final ComboBox myLoginMethodTypeComboBox; + private final ComboBox myTasksListMethodTypeComboBox; + private final ComboBox mySingleTaskMethodComboBox; + private final JPanel myPanel; + private final JRadioButton myXmlRadioButton; + private final JRadioButton myTextRadioButton; + private final JButton myTest2Button; + private final JRadioButton myJsonRadioButton; + private final JButton myManageTemplateVariablesButton; + private final JButton myResetToDefaultsButton; + private final JPanel myCardPanel; + private final JBLabel mySingleTaskURLLabel; + private final JBCheckBox myDownloadTasksInSeparateRequests; private Map myField2Variable; private final Map myRadio2ResponseType; @@ -68,6 +79,150 @@ public class GenericRepositoryEditor extends BaseRe final T repository, final Consumer changeListener) { super(project, repository, changeListener); + { + List placeholders = createPlaceholdersList(myRepository); + myLoginURLText = createTextFieldWithCompletion(myRepository.getLoginUrl(), placeholders); + myTasksListURLText = createTextFieldWithCompletion(myRepository.getTasksListUrl(), concat(placeholders, "{max}", "{since}")); + mySingleTaskURLText = createTextFieldWithCompletion(myRepository.getSingleTaskUrl(), concat(placeholders, "{id}")); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 3, new Insets(0, 0, 0, 0), -1, 8)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "response.type")); + myPanel.add(jBLabel1, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myXmlRadioButton = new JRadioButton(); + myXmlRadioButton.setText("XML"); + myXmlRadioButton.setMnemonic('M'); + myXmlRadioButton.setDisplayedMnemonicIndex(1); + panel1.add(myXmlRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(49, 44), null, 0, false)); + myTextRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myTextRadioButton, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "text")); + panel1.add(myTextRadioButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(51, 44), null, 0, false)); + myJsonRadioButton = new JRadioButton(); + myJsonRadioButton.setText("JSON"); + myJsonRadioButton.setMnemonic('O'); + myJsonRadioButton.setDisplayedMnemonicIndex(2); + panel1.add(myJsonRadioButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(55, 44), null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setHorizontalTextPosition(4); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "each.task.in.separate.request")); + panel1.add(label1, + new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDownloadTasksInSeparateRequests = new JBCheckBox(); + panel1.add(myDownloadTasksInSeparateRequests, + new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myTest2Button = new JButton(); + this.$$$loadButtonText$$$(myTest2Button, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "test")); + panel2.add(myTest2Button, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myManageTemplateVariablesButton = new JButton(); + this.$$$loadButtonText$$$(myManageTemplateVariablesButton, + this.$$$getMessageFromBundle$$$("messages/TaskBundle", "manage.template.variables")); + panel2.add(myManageTemplateVariablesButton, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myResetToDefaultsButton = new JButton(); + this.$$$loadButtonText$$$(myResetToDefaultsButton, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "reset.to.defaults")); + panel2.add(myResetToDefaultsButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCardPanel = new JPanel(); + myCardPanel.setLayout(new CardLayout(0, 0)); + myPanel.add(myCardPanel, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + mySingleTaskURLLabel = new JBLabel(); + this.$$$loadLabelText$$$(mySingleTaskURLLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "single.task.url")); + myPanel.add(mySingleTaskURLLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPanel.add(mySingleTaskURLText, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(10, -1), null, 0, false)); + mySingleTaskMethodComboBox = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("GET"); + defaultComboBoxModel1.addElement("POST"); + mySingleTaskMethodComboBox.setModel(defaultComboBoxModel1); + myPanel.add(mySingleTaskMethodComboBox, + new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "tasks.list.url")); + myPanel.add(jBLabel2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPanel.add(myTasksListURLText, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(10, -1), null, 0, false)); + myTasksListMethodTypeComboBox = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); + defaultComboBoxModel2.addElement("GET"); + defaultComboBoxModel2.addElement("POST"); + myTasksListMethodTypeComboBox.setModel(defaultComboBoxModel2); + myPanel.add(myTasksListMethodTypeComboBox, + new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLoginURLLabel = new JBLabel(); + this.$$$loadLabelText$$$(myLoginURLLabel, this.$$$getMessageFromBundle$$$("messages/TaskBundle", "login.url")); + myPanel.add(myLoginURLLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPanel.add(myLoginURLText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(10, -1), null, 0, false)); + myLoginMethodTypeComboBox = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel3 = new DefaultComboBoxModel(); + defaultComboBoxModel3.addElement("GET"); + defaultComboBoxModel3.addElement("POST"); + myLoginMethodTypeComboBox.setModel(defaultComboBoxModel3); + myPanel.add(myLoginMethodTypeComboBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + mySingleTaskURLLabel.setLabelFor(mySingleTaskURLText); + jBLabel2.setLabelFor(myTasksListURLText); + myLoginURLLabel.setLabelFor(myLoginURLText); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myXmlRadioButton); + buttonGroup.add(myTextRadioButton); + buttonGroup.add(myJsonRadioButton); + } myTest2Button.addActionListener(new ActionListener() { @Override @@ -167,6 +322,78 @@ public class GenericRepositoryEditor extends BaseRe myDownloadTasksInSeparateRequests.setSelected(myRepository.getDownloadTasksInSeparateRequests()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void singleTaskUrlEnablingChanged() { boolean enabled = !myTextRadioButton.isSelected(); // single task URL doesn't make sense when legacy regex handler is used @@ -222,7 +449,7 @@ public class GenericRepositoryEditor extends BaseRe } private void selectCardByResponseType() { - CardLayout cardLayout = (CardLayout) myCardPanel.getLayout(); + CardLayout cardLayout = (CardLayout)myCardPanel.getLayout(); cardLayout.show(myCardPanel, myRepository.getResponseType().getMimeType()); } @@ -237,7 +464,7 @@ public class GenericRepositoryEditor extends BaseRe myRepository.setSingleTaskMethodType(HTTPMethod.valueOf((String)mySingleTaskMethodComboBox.getSelectedItem())); myRepository.setDownloadTasksInSeparateRequests(myDownloadTasksInSeparateRequests.isSelected()); - for (Map.Entry entry : myField2Variable.entrySet()) { + for (Map.Entry entry : myField2Variable.entrySet()) { TemplateVariable variable = entry.getValue(); JTextField field = entry.getKey(); variable.setValue(field.getText()); @@ -250,13 +477,6 @@ public class GenericRepositoryEditor extends BaseRe super.apply(); } - private void createUIComponents() { - List placeholders = createPlaceholdersList(myRepository); - myLoginURLText = createTextFieldWithCompletion(myRepository.getLoginUrl(), placeholders); - myTasksListURLText = createTextFieldWithCompletion(myRepository.getTasksListUrl(), concat(placeholders, "{max}", "{since}")); - mySingleTaskURLText = createTextFieldWithCompletion(myRepository.getSingleTaskUrl(), concat(placeholders, "{id}")); - } - private TextFieldWithAutoCompletion createTextFieldWithCompletion(String text, final List variants) { final StringsCompletionProvider provider = new StringsCompletionProvider(variants, null) { @Override diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java index dce82001d3ac..babf690d7b4b 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java @@ -47,11 +47,17 @@ import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBTabbedPane; import com.intellij.ui.components.fields.ExpandableTextField; import com.intellij.ui.table.TableView; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.IconUtil; import com.intellij.util.concurrency.NonUrgentExecutor; import com.intellij.util.containers.ContainerUtil; +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; import com.theoryinpractice.testng.MessageInfoException; import com.theoryinpractice.testng.TestngBundle; import com.theoryinpractice.testng.configuration.browser.GroupBrowser; @@ -68,10 +74,12 @@ import com.theoryinpractice.testng.util.TestNGUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -81,45 +89,49 @@ import javax.swing.event.ChangeListener; import javax.swing.text.Document; import javax.swing.text.PlainDocument; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Map; +import java.util.ResourceBundle; public class TestNGConfigurationEditor extends SettingsEditor implements PanelWithAnchor { //private static final Logger LOGGER = Logger.getInstance("TestNG Runner"); private final Project project; - private JPanel panel; + private final JPanel panel; - private LabeledComponentNoThrow classField; - private LabeledComponentNoThrow moduleClasspath; - private JrePathEditor alternateJDK; + private final LabeledComponentNoThrow classField; + private final LabeledComponentNoThrow moduleClasspath; + private final JrePathEditor alternateJDK; private final ConfigurationModuleSelector moduleSelector; - private JComboBox myTestKind; - private JBLabel myTestLabel; + private final JComboBox myTestKind; + private final JBLabel myTestLabel; private final TestNGConfigurationModel model; - private LabeledComponentNoThrow methodField; - private LabeledComponentNoThrow packageField; - private LabeledComponentNoThrow groupField; - private LabeledComponentNoThrow suiteField; + private final LabeledComponentNoThrow methodField; + private final LabeledComponentNoThrow packageField; + private final LabeledComponentNoThrow groupField; + private final LabeledComponentNoThrow suiteField; private JComponent anchor; - private JRadioButton packagesInProject; - private JRadioButton packagesInModule; - private JRadioButton packagesAcrossModules; - private JPanel packagePanel; + private final JRadioButton packagesInProject; + private final JRadioButton packagesInModule; + private final JRadioButton packagesAcrossModules; + private final JPanel packagePanel; private TestNGParametersTableModel propertiesTableModel; - private LabeledComponentNoThrow propertiesFile; - private LabeledComponentNoThrow outputDirectory; + private final LabeledComponentNoThrow propertiesFile; + private final LabeledComponentNoThrow outputDirectory; private TableView propertiesTableView; - private JPanel commonParametersPanel;//temp compilation problems + private final JPanel commonParametersPanel;//temp compilation problems private JList myListenersList; - private JCheckBox myUseDefaultReportersCheckBox; - private LabeledComponentNoThrow myPattern; - private JPanel myPropertiesPanel; - private JPanel myListenersPanel; - private LabeledComponentNoThrow myShortenCommandLineCombo; - private LabeledComponentNoThrow myUseModulePath; - private LabeledComponentNoThrow myAsyncStackTraceForExceptions; + private final JCheckBox myUseDefaultReportersCheckBox; + private final LabeledComponentNoThrow myPattern; + private final JPanel myPropertiesPanel; + private final JPanel myListenersPanel; + private final LabeledComponentNoThrow myShortenCommandLineCombo; + private final LabeledComponentNoThrow myUseModulePath; + private final LabeledComponentNoThrow myAsyncStackTraceForExceptions; TextFieldWithBrowseButton myPatternTextField; private final CommonJavaParametersPanel commonJavaParameters = new CommonJavaParametersPanel(); private final ArrayList> propertiesList = new ArrayList<>(); @@ -129,6 +141,189 @@ public class TestNGConfigurationEditor extends Se public TestNGConfigurationEditor(Project project) { this.project = project; + { + myShortenCommandLineCombo = new LabeledComponentNoThrow<>(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(8, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + methodField = new LabeledComponentNoThrow(); + methodField.setLabelLocation("West"); + methodField.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.method.label")); + panel1.add(methodField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + suiteField = new LabeledComponentNoThrow(); + suiteField.setLabelLocation("West"); + suiteField.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.suite.label")); + panel1.add(suiteField, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + packagePanel = new JPanel(); + packagePanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):grow", + "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow")); + panel1.add(packagePanel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + packageField = new LabeledComponentNoThrow(); + packageField.setLabelLocation("West"); + packageField.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.package.label")); + CellConstraints cc = new CellConstraints(); + packagePanel.add(packageField, cc.xyw(1, 1, 5)); + packagesInProject = new JRadioButton(); + this.$$$loadButtonText$$$(packagesInProject, + this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.in.whole.project.radio")); + packagePanel.add(packagesInProject, cc.xy(1, 3)); + packagesInModule = new JRadioButton(); + this.$$$loadButtonText$$$(packagesInModule, + this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.in.single.module.radio")); + packagePanel.add(packagesInModule, cc.xy(3, 3)); + packagesAcrossModules = new JRadioButton(); + this.$$$loadButtonText$$$(packagesAcrossModules, this.$$$getMessageFromBundle$$$("messages/TestngBundle", + "testng.configuration.across.module.dependencies.radio")); + packagePanel.add(packagesAcrossModules, cc.xy(5, 3)); + classField = new LabeledComponentNoThrow(); + classField.setLabelLocation("West"); + classField.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.class.label")); + panel1.add(classField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + outputDirectory = new LabeledComponentNoThrow(); + outputDirectory.setLabelLocation("West"); + outputDirectory.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.output.directory")); + panel1.add(outputDirectory, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + groupField = new LabeledComponentNoThrow(); + groupField.setLabelLocation("West"); + groupField.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.group.label")); + panel1.add(groupField, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPattern = new LabeledComponentNoThrow(); + myPattern.setComponentClass("javax.swing.JPanel"); + myPattern.setLabelLocation("West"); + myPattern.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.pattern.label")); + myPattern.setVisible(true); + panel1.add(myPattern, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAsyncStackTraceForExceptions = new LabeledComponentNoThrow(); + myAsyncStackTraceForExceptions.setComponentClass("javax.swing.JCheckBox"); + myAsyncStackTraceForExceptions.setLabelLocation("West"); + myAsyncStackTraceForExceptions.setText(""); + panel1.add(myAsyncStackTraceForExceptions, + new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JBTabbedPane jBTabbedPane1 = new JBTabbedPane(); + panel.add(jBTabbedPane1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, 200), null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.jdk.settings.pane"), panel2); + myShortenCommandLineCombo.setLabelLocation("West"); + myShortenCommandLineCombo.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.shorten.command.line.label")); + panel2.add(myShortenCommandLineCombo, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + commonParametersPanel = new JPanel(); + commonParametersPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(commonParametersPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 15), null, 0, false)); + alternateJDK = new JrePathEditor(); + panel2.add(alternateJDK, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + moduleClasspath = new LabeledComponentNoThrow(); + moduleClasspath.setComponentClass("com.intellij.application.options.ModuleDescriptionsComboBox"); + moduleClasspath.setLabelLocation("West"); + moduleClasspath.setText( + this.$$$getMessageFromBundle$$$("messages/ExecutionBundle", "application.configuration.use.classpath.and.jdk.of.module.label")); + panel2.add(moduleClasspath, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myUseModulePath = new LabeledComponentNoThrow(); + myUseModulePath.setComponentClass("javax.swing.JCheckBox"); + myUseModulePath.setLabelLocation("West"); + myUseModulePath.setText(""); + panel2.add(myUseModulePath, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new BorderLayout(0, 0)); + jBTabbedPane1.addTab(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.parameters.pane"), panel3); + propertiesFile = new LabeledComponentNoThrow(); + propertiesFile.setLabelLocation("West"); + propertiesFile.setText(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.properties.file")); + panel3.add(propertiesFile, BorderLayout.NORTH); + myPropertiesPanel = new JPanel(); + myPropertiesPanel.setLayout(new BorderLayout(0, 0)); + panel3.add(myPropertiesPanel, BorderLayout.CENTER); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + jBTabbedPane1.addTab(this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.listeners.pane"), panel4); + myListenersPanel = new JPanel(); + myListenersPanel.setLayout(new BorderLayout(0, 0)); + panel4.add(myListenersPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(-1, 100), null, 0, false)); + myUseDefaultReportersCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myUseDefaultReportersCheckBox, this.$$$getMessageFromBundle$$$("messages/TestngBundle", + "testng.configuration.use.default.reporters.option")); + panel4.add(myUseDefaultReportersCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel.add(spacer3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer4 = new Spacer(); + panel5.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myTestKind = new JComboBox(); + panel5.add(myTestKind, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myTestLabel = new JBLabel(); + this.$$$loadLabelText$$$(myTestLabel, + this.$$$getMessageFromBundle$$$("messages/TestngBundle", "testng.configuration.test.kind.label")); + panel5.add(myTestLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } BrowseModuleValueActionListener[] browseListeners = new BrowseModuleValueActionListener[]{new PackageBrowser(project), new TestClassBrowser(project, this), new TestNGMethodBrowser(project), new GroupBrowser(project, this), new SuiteBrowser(project), new TestClassBrowser(project, this) { @@ -220,6 +415,78 @@ public class TestNGConfigurationEditor extends Se myAsyncStackTraceForExceptions.getComponent().setSelected(true); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + private void evaluateModuleClassPath() { final boolean allPackagesInProject = packagesInProject.isSelected() && packagePanel.isVisible(); moduleClasspath.setEnabled(!allPackagesInProject); @@ -319,9 +586,12 @@ public class TestNGConfigurationEditor extends Se myAsyncStackTraceForExceptions.getComponent().setSelected(config.isPrintAsyncStackTraceForExceptions()); if (!project.isDefault()) { SwingUtilities.invokeLater(() -> - ReadAction.nonBlocking(() -> FilenameIndex.getFilesByName(project, PsiJavaModule.MODULE_INFO_FILE, GlobalSearchScope.projectScope(project)).length > 0) + ReadAction.nonBlocking(() -> FilenameIndex.getFilesByName(project, PsiJavaModule.MODULE_INFO_FILE, + GlobalSearchScope.projectScope( + project)).length > 0) .expireWith(this) - .finishOnUiThread(ModalityState.stateForComponent(myUseModulePath), visible -> myUseModulePath.setVisible(visible)) + .finishOnUiThread(ModalityState.stateForComponent(myUseModulePath), + visible -> myUseModulePath.setVisible(visible)) .submit(NonUrgentExecutor.getInstance())); } } @@ -391,10 +661,6 @@ public class TestNGConfigurationEditor extends Se myTestLabel.setAnchor(anchor); } - private void createUIComponents() { - myShortenCommandLineCombo = new LabeledComponentNoThrow<>(); - } - private static void registerListener(JRadioButton[] buttons, ChangeListener changelistener) { ButtonGroup buttongroup = new ButtonGroup(); for (JRadioButton button : buttons) { @@ -553,7 +819,8 @@ public class TestNGConfigurationEditor extends Se final TestListenerFilter filter = new TestListenerFilter(searchScope, project); TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project) - .createWithInnerClassesScopeChooser(TestngBundle.message("testng.config.editor.dialog.title.choose.listener.class"), filter.getScope(), filter, null); + .createWithInnerClassesScopeChooser(TestngBundle.message("testng.config.editor.dialog.title.choose.listener.class"), + filter.getScope(), filter, null); chooser.showDialog(); PsiClass psiclass = chooser.getSelected(); if (psiclass == null) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateDialogAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateDialogAction.java index 109b00375f94..10704337587e 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateDialogAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateDialogAction.java @@ -15,14 +15,23 @@ import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.uiDesigner.GuiDesignerConfiguration; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; final class CreateDialogAction extends AbstractCreateFormAction { private boolean myRecentGenerateOK; @@ -188,15 +197,128 @@ final class CreateDialogAction extends AbstractCreateFormAction { } private static final class MyContentPane { - private JPanel myPanel; - private JCheckBox myChkGenerateCancel; - private JCheckBox myChkGenerateOK; - private JCheckBox myChkGenerateMain; - private JTextField myTfClassName; + private final JPanel myPanel; + private final JCheckBox myChkGenerateCancel; + private final JCheckBox myChkGenerateOK; + private final JCheckBox myChkGenerateMain; + private final JTextField myTfClassName; MyContentPane() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "edit.dialog.class.name")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTfClassName = new JTextField(); + myPanel.add(myTfClassName, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myChkGenerateMain = new JCheckBox(); + myChkGenerateMain.setSelected(true); + this.$$$loadButtonText$$$(myChkGenerateMain, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.generate.main")); + myPanel.add(myChkGenerateMain, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myChkGenerateOK = new JCheckBox(); + myChkGenerateOK.setSelected(true); + this.$$$loadButtonText$$$(myChkGenerateOK, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.generate.ok")); + myPanel.add(myChkGenerateOK, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myChkGenerateCancel = new JCheckBox(); + myChkGenerateCancel.setFocusTraversalPolicyProvider(true); + myChkGenerateCancel.setSelected(true); + this.$$$loadButtonText$$$(myChkGenerateCancel, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.generate.cancel")); + myPanel.add(myChkGenerateCancel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public JPanel getPanel() { return myPanel; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateFormAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateFormAction.java index fc1d88f17651..fa37c7d6a201 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateFormAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/CreateFormAction.java @@ -17,12 +17,15 @@ import com.intellij.ui.DocumentAdapter; import com.intellij.uiDesigner.GuiDesignerConfiguration; import com.intellij.uiDesigner.GuiFormFileType; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.radComponents.LayoutManagerRegistry; import com.intellij.util.IncorrectOperationException; import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -31,6 +34,10 @@ import javax.swing.JTextField; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; final class CreateFormAction extends AbstractCreateFormAction { private static final Logger LOG = Logger.getInstance(CreateFormAction.class); @@ -92,12 +99,12 @@ final class CreateFormAction extends AbstractCreateFormAction { } private class MyDialog extends DialogWrapper { - private JPanel myTopPanel; - private JTextField myFormNameTextField; - private JCheckBox myCreateBoundClassCheckbox; - private JTextField myClassNameTextField; - private TemplateKindCombo myBaseLayoutManagerCombo; - private JLabel myUpDownHintForm; + private final JPanel myTopPanel; + private final JTextField myFormNameTextField; + private final JCheckBox myCreateBoundClassCheckbox; + private final JTextField myClassNameTextField; + private final TemplateKindCombo myBaseLayoutManagerCombo; + private final JLabel myUpDownHintForm; private boolean myAdjusting = false; private boolean myNeedAdjust = true; @@ -105,10 +112,67 @@ final class CreateFormAction extends AbstractCreateFormAction { private final MyInputValidator myValidator; MyDialog(final Project project, - final MyInputValidator validator) { + final MyInputValidator validator) { super(project, true); myProject = project; myValidator = validator; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myTopPanel = new JPanel(); + myTopPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "new.form.form.name.label")); + myTopPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFormNameTextField = new JTextField(); + myTopPanel.add(myFormNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, + new Dimension(150, -1), null, 0, false)); + myCreateBoundClassCheckbox = new JCheckBox(); + myCreateBoundClassCheckbox.setSelected(true); + this.$$$loadButtonText$$$(myCreateBoundClassCheckbox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.create.bound.class")); + myTopPanel.add(myCreateBoundClassCheckbox, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "new.form.class.name.label")); + myTopPanel.add(label2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 4, + false)); + myClassNameTextField = new JTextField(); + myTopPanel.add(myClassNameTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "new.form.base.layout.manager.label")); + myTopPanel.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myBaseLayoutManagerCombo = new TemplateKindCombo(); + myTopPanel.add(myBaseLayoutManagerCombo, + new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myUpDownHintForm = new JLabel(); + myUpDownHintForm.setText(""); + myUpDownHintForm.setToolTipText(this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", + "pressing.up.or.down.arrows.while.in.editor.changes.the.layout.manager")); + myTopPanel.add(myUpDownHintForm, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + label1.setLabelFor(myFormNameTextField); + label2.setLabelFor(myClassNameTextField); + label3.setLabelFor(myBaseLayoutManagerCombo); + } myBaseLayoutManagerCombo.registerUpDownHint(myFormNameTextField); myUpDownHintForm.setIcon(PlatformIcons.UP_DOWN_ARROWS); init(); @@ -143,13 +207,85 @@ final class CreateFormAction extends AbstractCreateFormAction { } }); - for (String layoutName: LayoutManagerRegistry.getNonDeprecatedLayoutManagerNames()) { + for (String layoutName : LayoutManagerRegistry.getNonDeprecatedLayoutManagerNames()) { String displayName = LayoutManagerRegistry.getLayoutManagerDisplayName(layoutName); myBaseLayoutManagerCombo.addItem(displayName, null, layoutName); } myBaseLayoutManagerCombo.setSelectedName(GuiDesignerConfiguration.getInstance(project).DEFAULT_LAYOUT_MANAGER); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myTopPanel; } + @Override protected JComponent createCenterPanel() { return myTopPanel; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/AddClientPropertyDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/AddClientPropertyDialog.java index 5b6ed089c907..98c63f04ee8e 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/AddClientPropertyDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/AddClientPropertyDialog.java @@ -5,30 +5,171 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.IdeBorderFactory; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class AddClientPropertyDialog extends DialogWrapper { - private JTextField myPropertyNameTextField; - private JRadioButton myStringRadioButton; - private JRadioButton myIntegerRadioButton; - private JRadioButton myDoubleRadioButton; - private JRadioButton myBooleanRadioButton; - private JPanel myRootPanel; - private JPanel myGroupPanel; + private final JTextField myPropertyNameTextField; + private final JRadioButton myStringRadioButton; + private final JRadioButton myIntegerRadioButton; + private final JRadioButton myDoubleRadioButton; + private final JRadioButton myBooleanRadioButton; + private final JPanel myRootPanel; + private final JPanel myGroupPanel; public AddClientPropertyDialog(Project project) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.property.name")); + myRootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myPropertyNameTextField = new JTextField(); + myRootPanel.add(myPropertyNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, new Dimension(150, -1), null, 0, false)); + myGroupPanel = new JPanel(); + myGroupPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(myGroupPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myStringRadioButton = new JRadioButton(); + myStringRadioButton.setSelected(true); + this.$$$loadButtonText$$$(myStringRadioButton, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.property.dialog.string")); + myGroupPanel.add(myStringRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIntegerRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myIntegerRadioButton, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.property.dialog.integer")); + myGroupPanel.add(myIntegerRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myDoubleRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myDoubleRadioButton, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.property.dialog.double")); + myGroupPanel.add(myDoubleRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myBooleanRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myBooleanRadioButton, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.property.dialog.boolean")); + myGroupPanel.add(myBooleanRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + label1.setLabelFor(myPropertyNameTextField); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myStringRadioButton); + buttonGroup.add(myIntegerRadioButton); + buttonGroup.add(myDoubleRadioButton); + buttonGroup.add(myBooleanRadioButton); + } init(); setTitle(UIDesignerBundle.message("client.property.add.title")); myGroupPanel.setBorder(IdeBorderFactory.createTitledBorder(UIDesignerBundle.message("client.properties.type.header"))); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myRootPanel; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ClassNameInputDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ClassNameInputDialog.java index c7b9ecae37ef..d23ae9120b57 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ClassNameInputDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ClassNameInputDialog.java @@ -12,33 +12,104 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiPackage; import com.intellij.ui.EditorTextField; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Component; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ClassNameInputDialog extends DialogWrapper { - private EditorTextField myEditorTextField1; - private JPanel myRootPanel; + private final EditorTextField myEditorTextField1; + private final JPanel myRootPanel; private final Project myProject; public ClassNameInputDialog(Project project, Component parent) { super(parent, false); myProject = project; + { + myEditorTextField1 = new EditorTextField("", myProject, JavaFileType.INSTANCE); + final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject); + PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage(""); + final PsiCodeFragment fragment = factory.createReferenceCodeFragment("", defaultPackage, true, true); + myEditorTextField1.setDocument(PsiDocumentManager.getInstance(myProject).getDocument(fragment)); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRootPanel.add(myEditorTextField1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "client.properties.class.prompt")); + myRootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } init(); setTitle(UIDesignerBundle.message("client.properties.title")); } - private void createUIComponents() { - myEditorTextField1 = new EditorTextField("", myProject, JavaFileType.INSTANCE); - final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject); - PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage(""); - final PsiCodeFragment fragment = factory.createReferenceCodeFragment("", defaultPackage, true, true); - myEditorTextField1.setDocument(PsiDocumentManager.getInstance(myProject).getDocument(fragment)); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myEditorTextField1; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java index bfb5fc2e823d..66d26d99566a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java @@ -32,17 +32,23 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.uiDesigner.FormEditingUtil; import com.intellij.uiDesigner.GuiFormFileType; import com.intellij.uiDesigner.ImageFileFilter; import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.uiDesigner.lw.LwRootContainer; import com.intellij.util.SlowOperations; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -50,43 +56,49 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public final class ComponentItemDialog extends DialogWrapper { - private JPanel myPanel; + private final JPanel myPanel; private final ComponentWithBrowseButton myTfClassName; private final Project myProject; private final ComponentItem myItemToBeEdited; private final boolean myOneOff; - private JLabel myLblIcon; - private TextFieldWithBrowseButton myTfIconPath; - private JCheckBox myChkHorCanShrink; - private JCheckBox myChkHorCanGrow; - private JCheckBox myChkHorWantGrow; - private JCheckBox myChkVerCanShrink; - private JCheckBox myChkVerCanGrow; - private JCheckBox myChkVerWantGrow; - private JPanel myClassNamePlaceholder; - private JRadioButton myClassRadioButton; - private JRadioButton myNestedFormRadioButton; - private TextFieldWithBrowseButton myTfNestedForm; - private JCheckBox myAutoCreateBindingCheckbox; - private JCheckBox myCanAttachLabelCheckbox; - private JPanel myHSizePolicyPanel; - private JPanel myVSizePolicyPanel; - private JComboBox myGroupComboBox; - private JLabel myGroupLabel; - private JCheckBox myIsContainerCheckBox; - private JLabel myErrorLabel; + private final JLabel myLblIcon; + private final TextFieldWithBrowseButton myTfIconPath; + private final JCheckBox myChkHorCanShrink; + private final JCheckBox myChkHorCanGrow; + private final JCheckBox myChkHorWantGrow; + private final JCheckBox myChkVerCanShrink; + private final JCheckBox myChkVerCanGrow; + private final JCheckBox myChkVerWantGrow; + private final JPanel myClassNamePlaceholder; + private final JRadioButton myClassRadioButton; + private final JRadioButton myNestedFormRadioButton; + private final TextFieldWithBrowseButton myTfNestedForm; + private final JCheckBox myAutoCreateBindingCheckbox; + private final JCheckBox myCanAttachLabelCheckbox; + private final JPanel myHSizePolicyPanel; + private final JPanel myVSizePolicyPanel; + private final JComboBox myGroupComboBox; + private final JLabel myGroupLabel; + private final JCheckBox myIsContainerCheckBox; + private final JLabel myErrorLabel; private final EditorTextField myEditorTextField; private Document myDocument; @@ -99,6 +111,163 @@ public final class ComponentItemDialog extends DialogWrapper { myItemToBeEdited = itemToBeEdited; myOneOff = oneOff; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myLblIcon = new JLabel(); + this.$$$loadLabelText$$$(myLblIcon, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "editbox.icon")); + myPanel.add(myLblIcon, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myVSizePolicyPanel = new JPanel(); + myVSizePolicyPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myVSizePolicyPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(myVSizePolicyPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myVSizePolicyPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/UIDesignerBundle", + "group.vertical.size.policy"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myChkVerCanShrink = new JCheckBox(); + this.$$$loadButtonText$$$(myChkVerCanShrink, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.can.shrink.vert")); + myVSizePolicyPanel.add(myChkVerCanShrink, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myChkVerCanGrow = new JCheckBox(); + this.$$$loadButtonText$$$(myChkVerCanGrow, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.can.grow.vert")); + myVSizePolicyPanel.add(myChkVerCanGrow, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myChkVerWantGrow = new JCheckBox(); + this.$$$loadButtonText$$$(myChkVerWantGrow, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.want.grow.vert")); + myVSizePolicyPanel.add(myChkVerWantGrow, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myHSizePolicyPanel = new JPanel(); + myHSizePolicyPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myHSizePolicyPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(myHSizePolicyPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myHSizePolicyPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/UIDesignerBundle", + "group.horizontal.size.policy"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myChkHorCanShrink = new JCheckBox(); + this.$$$loadButtonText$$$(myChkHorCanShrink, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.can.shrink.horz")); + myHSizePolicyPanel.add(myChkHorCanShrink, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myChkHorCanGrow = new JCheckBox(); + this.$$$loadButtonText$$$(myChkHorCanGrow, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.can.grow.horz")); + myHSizePolicyPanel.add(myChkHorCanGrow, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myChkHorWantGrow = new JCheckBox(); + this.$$$loadButtonText$$$(myChkHorWantGrow, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.want.grow.horz")); + myHSizePolicyPanel.add(myChkHorWantGrow, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myTfIconPath = new TextFieldWithBrowseButton(); + myPanel.add(myTfIconPath, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(333, -1), null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, true)); + myClassNamePlaceholder = new JPanel(); + myClassNamePlaceholder.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(myClassNamePlaceholder, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myClassRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myClassRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "add.component.class")); + panel2.add(myClassRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTfNestedForm = new TextFieldWithBrowseButton(); + panel2.add(myTfNestedForm, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myNestedFormRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myNestedFormRadioButton, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "add.component.form")); + panel2.add(myNestedFormRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAutoCreateBindingCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myAutoCreateBindingCheckbox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.auto.create.binding")); + myPanel.add(myAutoCreateBindingCheckbox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myCanAttachLabelCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myCanAttachLabelCheckbox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.can.attach.label")); + myPanel.add(myCanAttachLabelCheckbox, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGroupLabel = new JLabel(); + this.$$$loadLabelText$$$(myGroupLabel, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "combobox.group")); + myGroupLabel.setVisible(false); + myPanel.add(myGroupLabel, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGroupComboBox = new JComboBox(); + myGroupComboBox.setVisible(false); + myPanel.add(myGroupComboBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myIsContainerCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myIsContainerCheckBox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "checkbox.is.container")); + myPanel.add(myIsContainerCheckBox, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myErrorLabel = new JLabel(); + myErrorLabel.setForeground(Color.red); + myErrorLabel.setText(" "); + myPanel.add(myErrorLabel, + new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myGroupLabel.setLabelFor(myGroupComboBox); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myClassRadioButton); + buttonGroup.add(myNestedFormRadioButton); + } myEditorTextField = new EditorTextField("", project, JavaFileType.INSTANCE); myEditorTextField.setFontInheritedFromLAF(true); @@ -183,6 +352,78 @@ public final class ComponentItemDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + void showGroupChooser(GroupItem defaultGroup) { myGroupLabel.setVisible(true); myGroupComboBox.setVisible(true); @@ -199,7 +440,7 @@ public final class ComponentItemDialog extends DialogWrapper { } GroupItem getSelectedGroup() { - return (GroupItem) myGroupComboBox.getSelectedItem(); + return (GroupItem)myGroupComboBox.getSelectedItem(); } private void setEditorText(final String className) { @@ -266,7 +507,8 @@ public final class ComponentItemDialog extends DialogWrapper { private boolean saveNestedForm() { VirtualFile formFile = ResourceFileUtil.findResourceFileInProject(myProject, myTfNestedForm.getText()); if (formFile == null) { - Messages.showErrorDialog(getWindow(), UIDesignerBundle.message("add.component.cannot.load.form", myTfNestedForm.getText()), CommonBundle.getErrorTitle()); + Messages.showErrorDialog(getWindow(), UIDesignerBundle.message("add.component.cannot.load.form", myTfNestedForm.getText()), + CommonBundle.getErrorTitle()); return false; } LwRootContainer lwRootContainer; @@ -360,7 +602,7 @@ public final class ComponentItemDialog extends DialogWrapper { private static String getClassOrInnerName(final PsiClass aClass) { PsiClass parentClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true); - if(parentClass != null) { + if (parentClass != null) { return getClassOrInnerName(parentClass) + "$" + aClass.getName(); } return aClass.getQualifiedName(); @@ -399,9 +641,9 @@ public final class ComponentItemDialog extends DialogWrapper { private final @Nls String myTitle; MyChooseFileActionListener(final Project project, - final TreeFileChooser.PsiFileFilter filter, - final TextFieldWithBrowseButton textField, - final @Nls String title) { + final TreeFileChooser.PsiFileFilter filter, + final TextFieldWithBrowseButton textField, + final @Nls String title) { myProject = project; myFilter = filter; myTextField = textField; @@ -412,7 +654,8 @@ public final class ComponentItemDialog extends DialogWrapper { public void actionPerformed(ActionEvent e) { PsiFile formFile = null; if (!myTextField.getText().isEmpty()) { - VirtualFile formVFile = ResourceFileUtil.findResourceFileInScope(myTextField.getText(), myProject, ProjectScope.getAllScope(myProject)); + VirtualFile formVFile = + ResourceFileUtil.findResourceFileInScope(myTextField.getText(), myProject, ProjectScope.getAllScope(myProject)); if (formVFile != null) { formFile = PsiManager.getInstance(myProject).findFile(formVFile); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditorDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditorDialog.java index 3617dc54fba2..b059ba23497e 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditorDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditorDialog.java @@ -5,14 +5,21 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.NlsSafe; import com.intellij.ui.ColoredListCellRenderer; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.components.JBTabbedPane; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.lw.FontDescriptor; import com.intellij.uiDesigner.propertyInspector.properties.IntroFontProperty; import com.intellij.util.ui.FontInfo; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.AbstractListModel; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -25,46 +32,151 @@ import javax.swing.JTextField; import javax.swing.SpinnerNumberModel; import javax.swing.UIDefaults; import javax.swing.UIManager; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.awt.Dimension; import java.awt.Font; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Comparator; import java.util.Enumeration; import java.util.List; +import java.util.ResourceBundle; import static com.intellij.ui.render.RenderersKt.fontInfoRenderer; public class FontEditorDialog extends DialogWrapper { private final Model myModel = new Model(); - private JList myFontNameList; - private JList myFontStyleList; - private JList myFontSizeList; - private JPanel myRootPane; - private JLabel myPreviewTextLabel; - private JTextField myFontNameEdit; - private JTextField myFontStyleEdit; - private JSpinner myFontSizeEdit; - private JList mySwingFontList; - private JTabbedPane myTabbedPane; - private JCheckBox myFontNameCheckbox; - private JCheckBox myFontStyleCheckbox; - private JCheckBox myFontSizeCheckbox; + private final JList myFontNameList; + private final JList myFontStyleList; + private final JList myFontSizeList; + private final JPanel myRootPane; + private final JLabel myPreviewTextLabel; + private final JTextField myFontNameEdit; + private final JTextField myFontStyleEdit; + private final JSpinner myFontSizeEdit; + private final JList mySwingFontList; + private final JTabbedPane myTabbedPane; + private final JCheckBox myFontNameCheckbox; + private final JCheckBox myFontStyleCheckbox; + private final JCheckBox myFontSizeCheckbox; private FontDescriptor myValue; protected FontEditorDialog(final Project project, String propertyName) { super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPane = new JPanel(); + myRootPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTabbedPane = new JBTabbedPane(); + myRootPane.add(myTabbedPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(200, 200), null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "font.chooser.font.tab"), panel1); + myFontNameCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myFontNameCheckbox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "font.chooser.font")); + panel1.add(myFontNameCheckbox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFontStyleCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myFontStyleCheckbox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "font.chooser.style")); + panel1.add(myFontStyleCheckbox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFontSizeCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myFontSizeCheckbox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "font.chooser.size")); + panel1.add(myFontSizeCheckbox, + new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFontNameList = new JBList(); + myFontNameList.setEnabled(false); + myFontNameList.setSelectionMode(0); + jBScrollPane1.setViewportView(myFontNameList); + final JBScrollPane jBScrollPane2 = new JBScrollPane(); + panel1.add(jBScrollPane2, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFontStyleList = new JBList(); + myFontStyleList.setEnabled(false); + myFontStyleList.setSelectionMode(0); + jBScrollPane2.setViewportView(myFontStyleList); + final JBScrollPane jBScrollPane3 = new JBScrollPane(); + panel1.add(jBScrollPane3, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myFontSizeList = new JBList(); + myFontSizeList.setEnabled(false); + myFontSizeList.setSelectionMode(0); + jBScrollPane3.setViewportView(myFontSizeList); + myFontNameEdit = new JTextField(); + myFontNameEdit.setEnabled(false); + panel1.add(myFontNameEdit, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myFontStyleEdit = new JTextField(); + myFontStyleEdit.setEnabled(false); + panel1.add(myFontStyleEdit, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myFontSizeEdit = new JSpinner(); + myFontSizeEdit.setEnabled(false); + panel1.add(myFontSizeEdit, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTabbedPane.addTab(this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "font.chooser.swing.tab"), panel2); + final JBScrollPane jBScrollPane4 = new JBScrollPane(); + panel2.add(jBScrollPane4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + mySwingFontList = new JBList(); + mySwingFontList.setSelectionMode(0); + jBScrollPane4.setViewportView(mySwingFontList); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPane.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", + "font.chooser.preview.text"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myPreviewTextLabel = new JLabel(); + myPreviewTextLabel.setText(""); + panel3.add(myPreviewTextLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, 40), null, 0, false)); + } init(); setTitle(UIDesignerBundle.message("font.chooser.title", propertyName)); myFontNameList.setModel(myModel); myFontNameList.setCellRenderer(fontInfoRenderer(false)); myFontNameList.addListSelectionListener(new MyListSelectionListener(myFontNameEdit)); - myFontStyleList.setListData(new String[] { + myFontStyleList.setListData(new String[]{ UIDesignerBundle.message("font.chooser.regular"), UIDesignerBundle.message("font.chooser.bold"), UIDesignerBundle.message("font.chooser.italic"), @@ -93,7 +205,7 @@ public class FontEditorDialog extends DialogWrapper { mySwingFontList.setCellRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) { - FontDescriptor descriptor = (FontDescriptor) value; + FontDescriptor descriptor = (FontDescriptor)value; clear(); @NlsSafe String font = descriptor.getSwingFont(); append(font, selected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES); @@ -134,6 +246,53 @@ public class FontEditorDialog extends DialogWrapper { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPane; } + private static @NlsSafe String fontToString(final Font font) { StringBuilder result = new StringBuilder(font.getFamily()); result.append(" ").append(font.getSize()); @@ -149,12 +308,12 @@ public class FontEditorDialog extends DialogWrapper { private static FontDescriptor[] collectSwingFontDescriptors() { ArrayList result = new ArrayList<>(); UIDefaults defaults = UIManager.getDefaults(); - Enumeration e = defaults.keys (); - while(e.hasMoreElements()) { + Enumeration e = defaults.keys(); + while (e.hasMoreElements()) { Object key = e.nextElement(); Object value = defaults.get(key); if (key instanceof String && value instanceof Font) { - result.add(FontDescriptor.fromSwingFont((String) key)); + result.add(FontDescriptor.fromSwingFont((String)key)); } } result.sort(Comparator.comparing(FontDescriptor::getSwingFont)); @@ -217,7 +376,7 @@ public class FontEditorDialog extends DialogWrapper { @Override public void valueChanged(ListSelectionEvent e) { - JList sourceList = (JList) e.getSource(); + JList sourceList = (JList)e.getSource(); final Object selValue = sourceList.getSelectedValue(); if (selValue != null) { myTextField.setText(selValue.toString()); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ListEditorDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ListEditorDialog.java index 64b5d100aaef..8e8189448ab1 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ListEditorDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ListEditorDialog.java @@ -5,26 +5,101 @@ package com.intellij.uiDesigner.propertyInspector.editors; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.components.JBScrollPane; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class ListEditorDialog extends DialogWrapper { - private JPanel myRootPanel; - private JTextArea myLinesTextArea; + private final JPanel myRootPanel; + private final JTextArea myLinesTextArea; protected ListEditorDialog(final Project project, String propertyName) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myRootPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + new Dimension(200, 300), null, 0, false)); + myLinesTextArea = new JTextArea(); + jBScrollPane1.setViewportView(myLinesTextArea); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "list.editor.prompt")); + myRootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + label1.setLabelFor(myLinesTextArea); + } init(); setTitle(UIDesignerBundle.message("list.editor.title", propertyName)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myRootPanel; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/NewKeyDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/NewKeyDialog.java index 9ef50965c66a..9344b1373042 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/NewKeyDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/NewKeyDialog.java @@ -3,23 +3,60 @@ package com.intellij.uiDesigner.propertyInspector.editors.string; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.uiDesigner.UIDesignerBundle; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.jetbrains.annotations.NotNull; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class NewKeyDialog extends DialogWrapper { - private JTextField myKeyNameEdit; - private JTextField myKeyValueEdit; - private JPanel myPanel; + private final JTextField myKeyNameEdit; + private final JTextField myKeyValueEdit; + private final JPanel myPanel; public NewKeyDialog(Component parent) { super(parent, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new BorderLayout(0, 0)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, BorderLayout.NORTH); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "key.chooser.new.property.name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeyNameEdit = new JTextField(); + panel1.add(myKeyNameEdit, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myKeyValueEdit = new JTextField(); + myKeyValueEdit.setColumns(50); + panel1.add(myKeyValueEdit, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "key.chooser.new.property.value")); + panel1.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } setTitle(UIDesignerBundle.message("key.chooser.new.property.title")); init(); updateButton(); @@ -41,11 +78,59 @@ public class NewKeyDialog extends DialogWrapper { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateButton() { setOKActionEnabled(!myKeyNameEdit.getText().isEmpty()); } - @Override public JComponent getPreferredFocusedComponent() { + @Override + public JComponent getPreferredFocusedComponent() { return myKeyNameEdit; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java index 34b46bdf0a75..4485168bc03f 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java @@ -31,11 +31,15 @@ import com.intellij.psi.PsiReference; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.ui.components.JBScrollPane; import com.intellij.uiDesigner.FormEditingUtil; import com.intellij.uiDesigner.StringDescriptorManager; import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.binding.FormReferenceProvider; import com.intellij.uiDesigner.compiler.AsmCodeGenerator; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.uiDesigner.designSurface.GuiEditor; import com.intellij.uiDesigner.lw.StringDescriptor; import com.intellij.util.ArrayUtilRt; @@ -46,6 +50,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.AbstractAction; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -56,13 +62,17 @@ import javax.swing.JTextField; import javax.swing.KeyStroke; import java.awt.CardLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Locale; +import java.util.ResourceBundle; import java.util.Set; public final class StringEditorDialog extends DialogWrapper{ @@ -304,25 +314,126 @@ public final class StringEditorDialog extends DialogWrapper{ return myForm.myPanel; } - private final class MyForm{ - private JRadioButton myRbString; - private JRadioButton myRbResourceBundle; - private JPanel myCardHolder; - private JPanel myPanel; - private JTextArea myTfValue; - private JCheckBox myNoI18nCheckbox; - private TextFieldWithBrowseButton myTfBundleName; - private TextFieldWithBrowseButton myTfKey; - private JTextField myTfRbValue; - private JLabel myLblKey; - private JLabel myLblBundleName; + private final class MyForm { + private final JRadioButton myRbString; + private final JRadioButton myRbResourceBundle; + private final JPanel myCardHolder; + private final JPanel myPanel; + private final JTextArea myTfValue; + private final JCheckBox myNoI18nCheckbox; + private final TextFieldWithBrowseButton myTfBundleName; + private final TextFieldWithBrowseButton myTfKey; + private final JTextField myTfRbValue; + private final JLabel myLblKey; + private final JLabel myLblBundleName; MyForm() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRbString = new JRadioButton(); + myRbString.setMargin(new Insets(2, 0, 2, 2)); + this.$$$loadButtonText$$$(myRbString, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "radio.string")); + myPanel.add(myRbString, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRbResourceBundle = new JRadioButton(); + myRbResourceBundle.setMargin(new Insets(2, 0, 2, 2)); + this.$$$loadButtonText$$$(myRbResourceBundle, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "radio.resource.bundle")); + myPanel.add(myRbResourceBundle, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCardHolder = new JPanel(); + myCardHolder.setLayout(new CardLayout(0, 0)); + myPanel.add(myCardHolder, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCardHolder.add(panel1, "string"); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "editbox.value.2")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNoI18nCheckbox = new JCheckBox(); + myNoI18nCheckbox.setSelected(false); + this.$$$loadButtonText$$$(myNoI18nCheckbox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "uidesigner.string.no.i18n")); + panel1.add(myNoI18nCheckbox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myTfValue = new JTextArea(); + myTfValue.setLineWrap(true); + myTfValue.setWrapStyleWord(true); + jBScrollPane1.setViewportView(myTfValue); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCardHolder.add(panel2, "bundle"); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, + 0, false)); + myLblKey = new JLabel(); + this.$$$loadLabelText$$$(myLblKey, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "editbox.key")); + panel3.add(myLblKey, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "editbox.value")); + panel3.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLblBundleName = new JLabel(); + this.$$$loadLabelText$$$(myLblBundleName, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "editbox.bundle.name")); + panel3.add(myLblBundleName, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTfRbValue = new JTextField(); + myTfRbValue.setColumns(30); + panel3.add(myTfRbValue, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + myTfKey = new TextFieldWithBrowseButton(); + myTfKey.setEditable(false); + myTfKey.setEnabled(true); + panel3.add(myTfKey, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTfBundleName = new TextFieldWithBrowseButton(); + myTfBundleName.setEditable(false); + panel3.add(myTfBundleName, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label2.setLabelFor(myTfRbValue); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myRbString); + buttonGroup.add(myRbResourceBundle); + } myRbString.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - CardLayout cardLayout = (CardLayout) myCardHolder.getLayout(); + CardLayout cardLayout = (CardLayout)myCardHolder.getLayout(); cardLayout.show(myCardHolder, CARD_STRING); } } @@ -339,7 +450,7 @@ public final class StringEditorDialog extends DialogWrapper{ myTfBundleName.setText(ArrayUtilRt.toStringArray(bundleNames)[0]); } } - CardLayout cardLayout = (CardLayout) myCardHolder.getLayout(); + CardLayout cardLayout = (CardLayout)myCardHolder.getLayout(); cardLayout.show(myCardHolder, CARD_BUNDLE); } } @@ -348,6 +459,78 @@ public final class StringEditorDialog extends DialogWrapper{ setupResourceBundleCard(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void setupResourceBundleCard() { // Enable keyboard pressing myTfBundleName.registerKeyboardAction( @@ -370,14 +553,15 @@ public final class StringEditorDialog extends DialogWrapper{ PropertiesFile file = PropertiesUtilBase.getPropertiesFile(bundleNameText, myEditor.getModule(), myLocale); PsiFile initialPropertiesFile = file == null ? null : file.getContainingFile(); final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesScope(myEditor.getModule()); - TreeFileChooser fileChooser = TreeFileChooserFactory.getInstance(project).createFileChooser(UIDesignerBundle.message("title.choose.properties.file"), initialPropertiesFile, - PropertiesFileType.INSTANCE, new TreeFileChooser.PsiFileFilter() { - @Override - public boolean accept(PsiFile file) { - final VirtualFile virtualFile = file.getVirtualFile(); - return virtualFile != null && moduleScope.contains(virtualFile); - } - }); + TreeFileChooser fileChooser = TreeFileChooserFactory.getInstance(project) + .createFileChooser(UIDesignerBundle.message("title.choose.properties.file"), initialPropertiesFile, + PropertiesFileType.INSTANCE, new TreeFileChooser.PsiFileFilter() { + @Override + public boolean accept(PsiFile file) { + final VirtualFile virtualFile = file.getVirtualFile(); + return virtualFile != null && moduleScope.contains(virtualFile); + } + }); fileChooser.showDialog(); PsiFile selectedFile = fileChooser.getSelectedFile(); PropertiesFile propertiesFile = selectedFile instanceof PropertiesFile ? (PropertiesFile)selectedFile : null; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/ButtonGroupPropertiesPanel.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/ButtonGroupPropertiesPanel.java index f8bee03fed2e..894adcaf7dce 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/ButtonGroupPropertiesPanel.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/ButtonGroupPropertiesPanel.java @@ -3,27 +3,36 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.uiDesigner.FormEditingUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.uiDesigner.propertyInspector.properties.BindingProperty; import com.intellij.util.containers.ContainerUtil; +import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public class ButtonGroupPropertiesPanel implements CustomPropertiesPanel { - private JTextField myNameTextField; - private JCheckBox myBindToFieldCheckBox; - private JPanel myPanel; + private final JTextField myNameTextField; + private final JCheckBox myBindToFieldCheckBox; + private final JPanel myPanel; private final RadRootContainer myRootContainer; private final RadButtonGroup myGroup; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); @@ -31,6 +40,32 @@ public class ButtonGroupPropertiesPanel implements CustomPropertiesPanel { public ButtonGroupPropertiesPanel(final RadRootContainer rootContainer, final RadButtonGroup group) { myRootContainer = rootContainer; myGroup = group; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "button.group.name.label")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myNameTextField = new JTextField(); + myPanel.add(myNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myBindToFieldCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myBindToFieldCheckBox, + this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "button.group.bound.checkbox")); + myPanel.add(myBindToFieldCheckBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myNameTextField); + } myNameTextField.setText(group.getName()); myBindToFieldCheckBox.setSelected(group.isBound()); myBindToFieldCheckBox.addChangeListener(new ChangeListener() { @@ -53,6 +88,78 @@ public class ButtonGroupPropertiesPanel implements CustomPropertiesPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void saveButtonGroupIsBound() { if (myGroup.isBound() != myBindToFieldCheckBox.isSelected()) { myGroup.setBound(myBindToFieldCheckBox.isSelected()); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/FormLayoutColumnProperties.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/FormLayoutColumnProperties.java index df9691c9ed83..5610af75c9f3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/FormLayoutColumnProperties.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/FormLayoutColumnProperties.java @@ -8,6 +8,7 @@ import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.util.ArrayUtilRt; import com.intellij.util.containers.ContainerUtil; import com.jgoodies.forms.layout.BoundedSize; +import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.ColumnSpec; import com.jgoodies.forms.layout.ConstantSize; import com.jgoodies.forms.layout.FormLayout; @@ -19,29 +20,37 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.JSeparator; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; public class FormLayoutColumnProperties implements CustomPropertiesPanel { private static final Map UNITS_MAP; + static { UNITS_MAP = new LinkedHashMap<>(); UNITS_MAP.put("px", UIDesignerBundle.message("unit.pixels")); @@ -52,28 +61,28 @@ public class FormLayoutColumnProperties implements CustomPropertiesPanel { UNITS_MAP.put("mm", UIDesignerBundle.message("unit.millimeters")); } - private JPanel myRootPanel; - private JRadioButton myDefaultRadioButton; - private JRadioButton myPreferredRadioButton; - private JRadioButton myMinimumRadioButton; - private JRadioButton myConstantRadioButton; - private JComboBox myConstantSizeUnitsCombo; - private JCheckBox myMinimumCheckBox; - private JCheckBox myMaximumCheckBox; - private JSpinner myMaxSizeSpinner; - private JComboBox myMinSizeUnitsCombo; - private JComboBox myMaxSizeUnitsCombo; - private JSpinner myConstantSizeSpinner; - private JSpinner myMinSizeSpinner; - private JCheckBox myGrowCheckBox; - private JSpinner myGrowSpinner; - private JRadioButton myLeftRadioButton; - private JRadioButton myCenterRadioButton; - private JRadioButton myRightRadioButton; - private JRadioButton myFillRadioButton; - private JLabel myTitleLabel; - private JPanel myAlignmentPanel; - private JPanel mySizePanel; + private final JPanel myRootPanel; + private final JRadioButton myDefaultRadioButton; + private final JRadioButton myPreferredRadioButton; + private final JRadioButton myMinimumRadioButton; + private final JRadioButton myConstantRadioButton; + private final JComboBox myConstantSizeUnitsCombo; + private final JCheckBox myMinimumCheckBox; + private final JCheckBox myMaximumCheckBox; + private final JSpinner myMaxSizeSpinner; + private final JComboBox myMinSizeUnitsCombo; + private final JComboBox myMaxSizeUnitsCombo; + private final JSpinner myConstantSizeSpinner; + private final JSpinner myMinSizeSpinner; + private final JCheckBox myGrowCheckBox; + private final JSpinner myGrowSpinner; + private final JRadioButton myLeftRadioButton; + private final JRadioButton myCenterRadioButton; + private final JRadioButton myRightRadioButton; + private final JRadioButton myFillRadioButton; + private final JLabel myTitleLabel; + private final JPanel myAlignmentPanel; + private final JPanel mySizePanel; private FormLayout myLayout; private int myIndex; private boolean myIsRow; @@ -82,6 +91,106 @@ public class FormLayoutColumnProperties implements CustomPropertiesPanel { private boolean mySaving = false; public FormLayoutColumnProperties() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout( + new FormLayout("fill:d:noGrow", "center:d:noGrow,top:4dlu:noGrow,center:d:noGrow,top:4dlu:noGrow,center:d:noGrow")); + myRootPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myTitleLabel = new JLabel(); + this.$$$loadLabelText$$$(myTitleLabel, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "row.0.properties")); + CellConstraints cc = new CellConstraints(); + myRootPanel.add(myTitleLabel, cc.xy(1, 1)); + myAlignmentPanel = new JPanel(); + myAlignmentPanel.setLayout( + new FormLayout("fill:d:grow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,fill:d:grow", + "center:d:grow")); + myAlignmentPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(myAlignmentPanel, cc.xy(1, 3)); + myAlignmentPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/UIDesignerBundle", "title.default.alignment"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + myLeftRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myLeftRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "alignment.left")); + myAlignmentPanel.add(myLeftRadioButton, cc.xy(1, 1)); + myCenterRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myCenterRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "alignment.center")); + myAlignmentPanel.add(myCenterRadioButton, cc.xy(3, 1)); + myRightRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myRightRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "alignment.right")); + myAlignmentPanel.add(myRightRadioButton, cc.xy(5, 1)); + myFillRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myFillRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "alignment.fill")); + myAlignmentPanel.add(myFillRadioButton, cc.xy(7, 1)); + mySizePanel = new JPanel(); + mySizePanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:60px:noGrow,left:4dlu:noGrow,fill:max(d;60px):noGrow", + "center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:d:grow")); + mySizePanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(mySizePanel, cc.xy(1, 5)); + mySizePanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/UIDesignerBundle", "title.size"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + myPreferredRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myPreferredRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.preferred")); + mySizePanel.add(myPreferredRadioButton, cc.xyw(1, 3, 2)); + myMinimumRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myMinimumRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.minimum")); + mySizePanel.add(myMinimumRadioButton, cc.xyw(1, 5, 2)); + myConstantRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myConstantRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.constant")); + mySizePanel.add(myConstantRadioButton, cc.xy(1, 7)); + myConstantSizeSpinner = new JSpinner(); + myConstantSizeSpinner.setEnabled(false); + mySizePanel.add(myConstantSizeSpinner, cc.xy(3, 7)); + myMinSizeSpinner = new JSpinner(); + myMinSizeSpinner.setEnabled(false); + mySizePanel.add(myMinSizeSpinner, cc.xy(3, 11)); + myMaxSizeSpinner = new JSpinner(); + myMaxSizeSpinner.setEnabled(false); + mySizePanel.add(myMaxSizeSpinner, cc.xy(3, 13)); + myConstantSizeUnitsCombo = new JComboBox(); + myConstantSizeUnitsCombo.setEnabled(false); + mySizePanel.add(myConstantSizeUnitsCombo, cc.xy(5, 7)); + myMinSizeUnitsCombo = new JComboBox(); + myMinSizeUnitsCombo.setEnabled(false); + mySizePanel.add(myMinSizeUnitsCombo, cc.xy(5, 11)); + myMaxSizeUnitsCombo = new JComboBox(); + myMaxSizeUnitsCombo.setEnabled(false); + mySizePanel.add(myMaxSizeUnitsCombo, cc.xy(5, 13)); + myMinimumCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myMinimumCheckBox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.minimum.limit")); + mySizePanel.add(myMinimumCheckBox, cc.xy(1, 11)); + myMaximumCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myMaximumCheckBox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.maximum.limit")); + mySizePanel.add(myMaximumCheckBox, cc.xy(1, 13)); + myDefaultRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myDefaultRadioButton, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.default")); + mySizePanel.add(myDefaultRadioButton, cc.xyw(1, 1, 2)); + final JSeparator separator1 = new JSeparator(); + mySizePanel.add(separator1, cc.xyw(1, 9, 5, CellConstraints.DEFAULT, CellConstraints.CENTER)); + myGrowCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myGrowCheckBox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "size.grow")); + mySizePanel.add(myGrowCheckBox, cc.xy(1, 17)); + myGrowSpinner = new JSpinner(); + myGrowSpinner.setEnabled(false); + mySizePanel.add(myGrowSpinner, cc.xy(3, 17)); + final JSeparator separator2 = new JSeparator(); + mySizePanel.add(separator2, cc.xyw(1, 15, 5, CellConstraints.DEFAULT, CellConstraints.CENTER)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myDefaultRadioButton); + buttonGroup.add(myPreferredRadioButton); + buttonGroup.add(myMinimumRadioButton); + buttonGroup.add(myConstantRadioButton); + buttonGroup = new ButtonGroup(); + buttonGroup.add(myLeftRadioButton); + buttonGroup.add(myCenterRadioButton); + buttonGroup.add(myRightRadioButton); + buttonGroup.add(myFillRadioButton); + } String[] unitNames = ArrayUtilRt.toStringArray(UNITS_MAP.keySet()); myConstantSizeUnitsCombo.setModel(new DefaultComboBoxModel<>(unitNames)); myConstantSizeUnitsCombo.setRenderer(new UnitListCellRenderer()); @@ -125,6 +234,78 @@ public class FormLayoutColumnProperties implements CustomPropertiesPanel { myConstantSizeUnitsCombo.addItemListener(itemListener); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override public JPanel getComponent() { return myRootPanel; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/GridLayoutColumnProperties.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/GridLayoutColumnProperties.java index 9a0ad397687b..dd6fc1e0e5b4 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/GridLayoutColumnProperties.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/GridLayoutColumnProperties.java @@ -5,36 +5,61 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.uiDesigner.propertyInspector.Property; import com.intellij.uiDesigner.propertyInspector.properties.HSizePolicyProperty; import com.intellij.uiDesigner.propertyInspector.properties.VSizePolicyProperty; import com.intellij.util.containers.ContainerUtil; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public class GridLayoutColumnProperties implements CustomPropertiesPanel { - private JPanel myRootPanel; - private JCheckBox myWantGrowCheckBox; - private JLabel myTitleLabel; + private final JPanel myRootPanel; + private final JCheckBox myWantGrowCheckBox; + private final JLabel myTitleLabel; private RadContainer myContainer; private boolean myRow; private int mySelectedIndex; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); public GridLayoutColumnProperties() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myTitleLabel = new JLabel(); + this.$$$loadLabelText$$$(myTitleLabel, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "grid.layout.column.properties")); + myRootPanel.add(myTitleLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myWantGrowCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myWantGrowCheckBox, this.$$$getMessageFromBundle$$$("messages/UIDesignerBundle", "grid.layout.want.grow")); + myRootPanel.add(myWantGrowCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myWantGrowCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - for(RadComponent c: myContainer.getComponents()) { + for (RadComponent c : myContainer.getComponents()) { if (c.getConstraints().getCell(myRow) == mySelectedIndex) { Property property = myRow ? VSizePolicyProperty.getInstance(c.getProject()) @@ -51,13 +76,85 @@ public class GridLayoutColumnProperties implements CustomPropertiesPanel { } } } - for(ChangeListener listener: myListeners) { + for (ChangeListener listener : myListeners) { listener.stateChanged(new ChangeEvent(this)); } } }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override public JComponent getComponent() { return myRootPanel; @@ -71,12 +168,12 @@ public class GridLayoutColumnProperties implements CustomPropertiesPanel { myWantGrowCheckBox.setEnabled(false); } else { - mySelectedIndex = selectedIndices [0]; - myTitleLabel.setText(UIDesignerBundle.message("grid.layout.column.property", isRow ? 0 : 1, selectedIndices [0])); + mySelectedIndex = selectedIndices[0]; + myTitleLabel.setText(UIDesignerBundle.message("grid.layout.column.property", isRow ? 0 : 1, selectedIndices[0])); myWantGrowCheckBox.setEnabled(true); - GridLayoutManager layout = (GridLayoutManager) container.getLayout(); - int sizePolicy = layout.getCellSizePolicy(isRow, selectedIndices [0]); + GridLayoutManager layout = (GridLayoutManager)container.getLayout(); + int sizePolicy = layout.getCellSizePolicy(isRow, selectedIndices[0]); myWantGrowCheckBox.setSelected((sizePolicy & GridConstraints.SIZEPOLICY_WANT_GROW) != 0); } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceForm.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceForm.java index 97c404804b16..2099d9b8e0ca 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceForm.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceForm.java @@ -16,16 +16,132 @@ package org.intellij.lang.xpath.xslt.refactoring; import com.intellij.ui.TextFieldWithHistory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class BaseIntroduceForm { - JPanel myContentPane; - TextFieldWithHistory myNameField; - JLabel myTypeLabel; - JCheckBox myReplaceAll; + final JPanel myContentPane; + final TextFieldWithHistory myNameField; + final JLabel myTypeLabel; + final JCheckBox myReplaceAll; - public boolean isReplaceAll() { return myReplaceAll.isSelected(); } + public BaseIntroduceForm() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), 0, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.name1")); + myContentPane.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myNameField = new TextFieldWithHistory(); + myContentPane.add(myNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.expression.is.of.type")); + myContentPane.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myTypeLabel = new JLabel(); + myTypeLabel.setText(""); //NON-NLS + myContentPane.add(myTypeLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myReplaceAll = new JCheckBox(); + this.$$$loadButtonText$$$(myReplaceAll, this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "checkbox.replace.all.occurrences.of.expression.0.occurrences")); + myContentPane.add(myReplaceAll, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myNameField); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + + public boolean isReplaceAll() { return myReplaceAll.isSelected(); } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceParameter/IntroduceParameterDialog.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceParameter/IntroduceParameterDialog.java index f82316f5eac9..8c37d524ff0d 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceParameter/IntroduceParameterDialog.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceParameter/IntroduceParameterDialog.java @@ -16,6 +16,9 @@ package org.intellij.lang.xpath.xslt.refactoring.introduceParameter; import com.intellij.lang.LanguageNamesValidation; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.lang.xpath.psi.XPathExpression; import org.intellij.lang.xpath.xslt.refactoring.BaseIntroduceDialog; import org.intellij.lang.xpath.xslt.refactoring.BaseIntroduceForm; @@ -23,97 +26,176 @@ import org.intellij.plugins.xpathView.XPathBundle; import org.jetbrains.annotations.NotNull; import javax.swing.AbstractAction; +import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class IntroduceParameterDialog extends BaseIntroduceDialog implements IntroduceParameterOptions { - private JPanel myContentPane; - private JCheckBox myCreateWithDefault; - private BaseIntroduceForm myForm; + private final JPanel myContentPane; + private final JCheckBox myCreateWithDefault; + private final BaseIntroduceForm myForm; - private boolean myIsPreview; - private final boolean myForceDefault; - private final MyPreviewAction myPreviewAction = new MyPreviewAction(); + private boolean myIsPreview; + private final boolean myForceDefault; + private final MyPreviewAction myPreviewAction = new MyPreviewAction(); - public IntroduceParameterDialog(XPathExpression expression, int numberOfExpressions, boolean forceDefault) { - super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage())); - myForceDefault = forceDefault; - init(expression, numberOfExpressions, XPathBundle.message("dialog.title.xslt.introduce.parameter")); + public IntroduceParameterDialog(XPathExpression expression, int numberOfExpressions, boolean forceDefault) { + super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage())); + myForceDefault = forceDefault; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myCreateWithDefault = new JCheckBox(); + this.$$$loadButtonText$$$(myCreateWithDefault, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.create.with.default.value")); + myCreateWithDefault.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "assign.the.extracted.expression.to.the.new.parameter.s.default.value")); + myContentPane.add(myCreateWithDefault, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myForm = new BaseIntroduceForm(); + myContentPane.add(myForm.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + } + init(expression, numberOfExpressions, XPathBundle.message("dialog.title.xslt.introduce.parameter")); - getOKAction().addPropertyChangeListener(new PropertyChangeListener() { - @Override - @SuppressWarnings({"AutoUnboxing"}) - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals("enabled")) { - myPreviewAction.setEnabled(((Boolean)evt.getNewValue()) && !myCreateWithDefault.isSelected()); - } - } - }); - if (forceDefault) { - myCreateWithDefault.setSelected(true); - myCreateWithDefault.setVisible(false); - } else { - myCreateWithDefault.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - myPreviewAction.setEnabled(getOKAction().isEnabled() && !myCreateWithDefault.isSelected()); - } - }); + getOKAction().addPropertyChangeListener(new PropertyChangeListener() { + @Override + @SuppressWarnings({"AutoUnboxing"}) + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("enabled")) { + myPreviewAction.setEnabled(((Boolean)evt.getNewValue()) && !myCreateWithDefault.isSelected()); } - myPreviewAction.setEnabled(false); + } + }); + if (forceDefault) { + myCreateWithDefault.setSelected(true); + myCreateWithDefault.setVisible(false); } - - @Override - protected Action @NotNull [] createActions() { - return myForceDefault ? super.createActions() : new Action[]{ getOKAction(), getPreviewAction(), getCancelAction() }; - } - - private Action getPreviewAction() { - return myPreviewAction; - } - - @Override - protected JComponent createCenterPanel() { - return myContentPane; - } - - @Override - public boolean isCreateDefault() { - return myCreateWithDefault.isSelected(); - } - - @Override - public boolean isReplaceAll() { - return myForm.isReplaceAll(); - } - - @Override - public boolean isPreview() { - return myIsPreview; - } - - @Override - protected BaseIntroduceForm getForm() { - return myForm; - } - - private class MyPreviewAction extends AbstractAction { - MyPreviewAction() { - super(XPathBundle.message("action.preview.text")); - } - + else { + myCreateWithDefault.addItemListener(new ItemListener() { @Override - public void actionPerformed(ActionEvent e) { - myIsPreview = true; - doOKAction(); + public void itemStateChanged(ItemEvent e) { + myPreviewAction.setEnabled(getOKAction().isEnabled() && !myCreateWithDefault.isSelected()); } + }); } + myPreviewAction.setEnabled(false); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + + @Override + protected Action @NotNull [] createActions() { + return myForceDefault ? super.createActions() : new Action[]{getOKAction(), getPreviewAction(), getCancelAction()}; + } + + private Action getPreviewAction() { + return myPreviewAction; + } + + @Override + protected JComponent createCenterPanel() { + return myContentPane; + } + + @Override + public boolean isCreateDefault() { + return myCreateWithDefault.isSelected(); + } + + @Override + public boolean isReplaceAll() { + return myForm.isReplaceAll(); + } + + @Override + public boolean isPreview() { + return myIsPreview; + } + + @Override + protected BaseIntroduceForm getForm() { + return myForm; + } + + private class MyPreviewAction extends AbstractAction { + MyPreviewAction() { + super(XPathBundle.message("action.preview.text")); + } + + @Override + public void actionPerformed(ActionEvent e) { + myIsPreview = true; + doOKAction(); + } + } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceVariable/IntroduceVariableDialog.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceVariable/IntroduceVariableDialog.java index d888f6929808..447179a889f5 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceVariable/IntroduceVariableDialog.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/introduceVariable/IntroduceVariableDialog.java @@ -16,6 +16,9 @@ package org.intellij.lang.xpath.xslt.refactoring.introduceVariable; import com.intellij.lang.LanguageNamesValidation; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.lang.xpath.psi.XPathExpression; import org.intellij.lang.xpath.xslt.refactoring.BaseIntroduceDialog; import org.intellij.lang.xpath.xslt.refactoring.BaseIntroduceForm; @@ -23,29 +26,51 @@ import org.intellij.plugins.xpathView.XPathBundle; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; public class IntroduceVariableDialog extends BaseIntroduceDialog implements IntroduceVariableOptions { - private JPanel myContentPane; - private BaseIntroduceForm myForm; + private final JPanel myContentPane; + private final BaseIntroduceForm myForm; - public IntroduceVariableDialog(XPathExpression expression, int numberOfExpressions) { - super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage())); - init(expression, numberOfExpressions, XPathBundle.message("dialog.title.xslt.introduce.variable")); + public IntroduceVariableDialog(XPathExpression expression, int numberOfExpressions) { + super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage())); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(2, 1, new Insets(5, 5, 5, 5), -1, -1)); + final Spacer spacer1 = new Spacer(); + myContentPane.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myForm = new BaseIntroduceForm(); + myContentPane.add(myForm.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); } + init(expression, numberOfExpressions, XPathBundle.message("dialog.title.xslt.introduce.variable")); + } - @Override - protected JComponent createCenterPanel() { - return myContentPane; - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } - @Override - public boolean isReplaceAll() { - return myForm.isReplaceAll(); - } + @Override + protected JComponent createCenterPanel() { + return myContentPane; + } - @Override - protected BaseIntroduceForm getForm() { - return myForm; - } + @Override + public boolean isReplaceAll() { + return myForm.isReplaceAll(); + } + + @Override + protected BaseIntroduceForm getForm() { + return myForm; + } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java index bc7d5e2c9360..4eee4e240588 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java @@ -58,14 +58,18 @@ import com.intellij.ui.AnActionButton; import com.intellij.ui.AnActionButtonRunnable; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; +import com.intellij.ui.components.JBTabbedPane; import com.intellij.ui.table.JBTable; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import com.intellij.util.ArrayUtilRt; import com.intellij.util.ui.PlatformColors; @@ -77,6 +81,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.ButtonModel; import javax.swing.ComboBoxModel; @@ -84,6 +89,7 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -91,18 +97,23 @@ import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.File; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Comparator; import java.util.Enumeration; import java.util.List; +import java.util.ResourceBundle; import java.util.Vector; class XsltRunSettingsEditor extends SettingsEditor @@ -118,41 +129,239 @@ class XsltRunSettingsEditor extends SettingsEditor } static class Editor implements PanelWithAnchor { - private JTabbedPane myComponent; + private final JTabbedPane myComponent; - private TextFieldWithBrowseButton myXsltFile; - private ComboboxWithBrowseButton myXmlInputFile; - private TextFieldWithBrowseButton myOutputFile; - private JCheckBox myOpenOutputFile; - private JCheckBox myOpenInBrowser; + private final TextFieldWithBrowseButton myXsltFile; + private final ComboboxWithBrowseButton myXmlInputFile; + private final TextFieldWithBrowseButton myOutputFile; + private final JCheckBox myOpenOutputFile; + private final JCheckBox myOpenInBrowser; private final JBTable myParameters; - private ButtonGroup myOutputOptions; - private JBRadioButton myShowInConsole; - private JCheckBox mySaveToFile; - private JRadioButton myShowInStdout; + private final ButtonGroup myOutputOptions; + private final JBRadioButton myShowInConsole; + private final JCheckBox mySaveToFile; + private final JRadioButton myShowInStdout; - private RawCommandLineEditor myVmArguments; - private JCheckBox mySmartErrorHandling; - private TextFieldWithBrowseButton myWorkingDirectory; + private final RawCommandLineEditor myVmArguments; + private final JCheckBox mySmartErrorHandling; + private final TextFieldWithBrowseButton myWorkingDirectory; - private ButtonGroup myJdkOptions; - private JRadioButton myJdkChoice; - private JRadioButton myModuleChoice; - private ComboBox myModule; + private final ButtonGroup myJdkOptions; + private final JRadioButton myJdkChoice; + private final JRadioButton myModuleChoice; + private final ComboBox myModule; private SdkComboBox myJDK; - private ComboBox myFileType; - private JPanel myClasspathAndJDKPanel; - private JPanel myPanelSettings; - private JPanel myPanelAdvanced; - private JBLabel myXSLTScriptFileLabel; - private JPanel myParametersPanel; + private final ComboBox myFileType; + private final JPanel myClasspathAndJDKPanel; + private final JPanel myPanelSettings; + private final JPanel myPanelAdvanced; + private final JBLabel myXSLTScriptFileLabel; + private final JPanel myParametersPanel; private JComponent anchor; private final FileChooserDescriptor myXmlDescriptor; private final FileChooserDescriptor myXsltDescriptor; Editor(Project project) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myComponent = new JBTabbedPane(); + myPanelSettings = new JPanel(); + myPanelSettings.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myComponent.addTab(this.$$$getMessageFromBundle$$$("messages/XPathBundle", "tab.title.settings"), myPanelSettings); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanelSettings.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "border.title.output"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySaveToFile = new JCheckBox(); + this.$$$loadButtonText$$$(mySaveToFile, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.save.to.file")); + mySaveToFile.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "html.save.xslt.output.to.specified.file.br.em.warning.em.this.file.will.be.overwritten.without.confirmation.html")); + panel1.add(mySaveToFile, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputFile = new TextFieldWithBrowseButton(); + panel1.add(myOutputFile, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOpenOutputFile = new JCheckBox(); + this.$$$loadButtonText$$$(myOpenOutputFile, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.open.file.in.editor.after.execution")); + panel1.add(myOpenOutputFile, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myShowInConsole = new JBRadioButton(); + this.$$$loadButtonText$$$(myShowInConsole, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.show.in.extra.console.tab")); + myShowInConsole.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "show.xslt.output.in.separate.tab.stdout.will.just.receive.xslt.error.messages")); + panel1.add(myShowInConsole, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowInStdout = new JRadioButton(); + this.$$$loadButtonText$$$(myShowInStdout, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.show.in.default.console")); + myShowInStdout.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "show.xslt.output.in.standard.run.console.mixed.with.other.error.messages")); + panel1.add(myShowInStdout, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 4, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.highlight.output.as")); + panel2.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFileType = new ComboBox(); + myFileType.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "output.highlighting.is.experimental.please.turn.it.off.if.it.s.causing.trouble")); + panel2.add(myFileType, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myOpenInBrowser = new JCheckBox(); + this.$$$loadButtonText$$$(myOpenInBrowser, this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "checkbox.open.file.in.web.browser.after.execution")); + panel1.add(myOpenInBrowser, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanelSettings.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "border.title.input"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.choose.xml.input.file")); + panel3.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myXSLTScriptFileLabel = new JBLabel(); + myXSLTScriptFileLabel.setEnabled(true); + this.$$$loadLabelText$$$(myXSLTScriptFileLabel, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.xslt.script.file")); + myXSLTScriptFileLabel.setVerticalAlignment(0); + panel3.add(myXSLTScriptFileLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myXsltFile = new TextFieldWithBrowseButton(); + panel3.add(myXsltFile, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myXmlInputFile = new ComboboxWithBrowseButton(); + panel3.add(myXmlInputFile, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myParametersPanel = new JPanel(); + myParametersPanel.setLayout(new BorderLayout(0, 0)); + myParametersPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanelSettings.add(myParametersPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 150), null, + 0, false)); + myParametersPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/XPathBundle", "border.title.parameters"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + myPanelAdvanced = new JPanel(); + myPanelAdvanced.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + myComponent.addTab(this.$$$getMessageFromBundle$$$("messages/XPathBundle", "tab.title.advanced"), myPanelAdvanced); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.vm.arguments")); + myPanelAdvanced.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + final Spacer spacer1 = new Spacer(); + myPanelAdvanced.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + mySmartErrorHandling = new JCheckBox(); + this.$$$loadButtonText$$$(mySmartErrorHandling, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.smart.error.handling")); + myPanelAdvanced.add(mySmartErrorHandling, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myClasspathAndJDKPanel = new JPanel(); + myClasspathAndJDKPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + myClasspathAndJDKPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanelAdvanced.add(myClasspathAndJDKPanel, + new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, true)); + myModuleChoice = new JRadioButton(); + this.$$$loadButtonText$$$(myModuleChoice, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.from.module")); + myClasspathAndJDKPanel.add(myModuleChoice, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myModule = new ComboBox(); + myClasspathAndJDKPanel.add(myModule, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myJdkChoice = new JRadioButton(); + this.$$$loadButtonText$$$(myJdkChoice, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.use.jdk")); + myClasspathAndJDKPanel.add(myJdkChoice, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.classpath.and.jdk")); + myClasspathAndJDKPanel.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, + null, 0, false)); + myVmArguments = new RawCommandLineEditor(); + myPanelAdvanced.add(myVmArguments, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWorkingDirectory = new TextFieldWithBrowseButton(); + myPanelAdvanced.add(myWorkingDirectory, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.working.directory")); + myPanelAdvanced.add(label5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + label2.setLabelFor(myXmlInputFile); + myXSLTScriptFileLabel.setLabelFor(myXsltFile); + label3.setLabelFor(myVmArguments); + label5.setLabelFor(myWorkingDirectory); + myOutputOptions = new ButtonGroup(); + myOutputOptions.add(myShowInConsole); + myOutputOptions.add(myShowInStdout); + myJdkOptions = new ButtonGroup(); + myJdkOptions.add(myModuleChoice); + myJdkOptions.add(myJdkChoice); + } var psiManager = PsiManager.getInstance(project); myXsltDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(XmlFileType.INSTANCE) .withFileFilter(file -> { @@ -362,6 +571,78 @@ class XsltRunSettingsEditor extends SettingsEditor setAnchor(myShowInConsole); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myComponent; } + @Override public JComponent getAnchor() { return anchor; diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/eval/EvalFormPanel.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/eval/EvalFormPanel.java index 611d72611b8c..530755c272f1 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/eval/EvalFormPanel.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/eval/EvalFormPanel.java @@ -15,60 +15,160 @@ */ package org.intellij.plugins.xpathView.eval; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.intellij.plugins.xpathView.ui.InputForm; import org.intellij.plugins.xpathView.ui.InputFormPanel; +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class EvalFormPanel extends JPanel implements InputForm { - @SuppressWarnings({ "UNUSED_SYMBOL"}) - private JPanel myRoot; - private InputFormPanel myInputPanel; + @SuppressWarnings({"UNUSED_SYMBOL"}) + private final JPanel myRoot; + private final InputFormPanel myInputPanel; - private JCheckBox myNewTabCheckbox; - private JCheckBox myHighlightCheckbox; - private JCheckBox myUsageViewCheckbox; + private final JCheckBox myNewTabCheckbox; + private final JCheckBox myHighlightCheckbox; + private final JCheckBox myUsageViewCheckbox; - private void createUIComponents() { - myRoot = this; + public EvalFormPanel() { + { + myRoot = this; } - - @Override - public JComponent getComponent() { - return this; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), 2, 2)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "border.title.options"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myUsageViewCheckbox = new JCheckBox(); + myUsageViewCheckbox.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myUsageViewCheckbox, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.show.results.in.usage.view")); + panel1.add(myUsageViewCheckbox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHighlightCheckbox = new JCheckBox(); + myHighlightCheckbox.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myHighlightCheckbox, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.highlight.results.in.editor")); + panel1.add(myHighlightCheckbox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInputPanel = new InputFormPanel(); + myRoot.add(myInputPanel.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myNewTabCheckbox = new JCheckBox(); + myNewTabCheckbox.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myNewTabCheckbox, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.open.in.new.tab1")); + myRoot.add(myNewTabCheckbox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); } + } - @Override - public JLabel getIcon() { - return myInputPanel.getIcon(); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - @Override - public JButton getEditContextButton() { - return myInputPanel.getEditContextButton(); + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - @Override - public JPanel getEditorPanel() { - return myInputPanel.getEditorPanel(); + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); } - - public JCheckBox getNewTabCheckbox() { - return myNewTabCheckbox; + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); } + } - public JCheckBox getHighlightCheckbox() { - return myHighlightCheckbox; - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } - public JCheckBox getUsageViewCheckbox() { - return myUsageViewCheckbox; - } + @Override + public JComponent getComponent() { + return this; + } - @Override - public void dispose() {} + @Override + public JLabel getIcon() { + return myInputPanel.getIcon(); + } + + @Override + public JButton getEditContextButton() { + return myInputPanel.getEditContextButton(); + } + + @Override + public JPanel getEditorPanel() { + return myInputPanel.getEditorPanel(); + } + + public JCheckBox getNewTabCheckbox() { + return myNewTabCheckbox; + } + + public JCheckBox getHighlightCheckbox() { + return myHighlightCheckbox; + } + + public JCheckBox getUsageViewCheckbox() { + return myUsageViewCheckbox; + } + + @Override + public void dispose() { } } diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/FindFormPanel.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/FindFormPanel.java index 79772e500da8..bddccd67c84a 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/FindFormPanel.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/FindFormPanel.java @@ -18,82 +18,186 @@ package org.intellij.plugins.xpathView.search; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.intellij.plugins.xpathView.ui.InputForm; import org.intellij.plugins.xpathView.ui.InputFormPanel; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class FindFormPanel extends JPanel implements InputForm { - @SuppressWarnings({"UnusedDeclaration" }) - private JPanel myRoot; + @SuppressWarnings({"UnusedDeclaration"}) + private final JPanel myRoot; - private final Project myProject; + private final Project myProject; - private InputFormPanel myInputPanel; - private JCheckBox myNewTabCheckbox; - private JRadioButton myMatchRootNode; - private JRadioButton myMatchEachNode; - private JPanel myOptionsPanel; - private ScopePanel myScopePanel; + private final InputFormPanel myInputPanel; + private final JCheckBox myNewTabCheckbox; + private final JRadioButton myMatchRootNode; + private final JRadioButton myMatchEachNode; + private final JPanel myOptionsPanel; + private final ScopePanel myScopePanel; - public FindFormPanel(Project project, Module module, SearchScope searchScope) { - myProject = project; - myScopePanel.initComponent(module, searchScope); + public FindFormPanel(Project project, Module module, SearchScope searchScope) { + myProject = project; + { + myRoot = this; + myScopePanel = new ScopePanel(myProject); } - - private void createUIComponents() { - myRoot = this; - myScopePanel = new ScopePanel(myProject); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + myInputPanel = new InputFormPanel(); + myRoot.add(myInputPanel.$$$getRootComponent$$$(), + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myNewTabCheckbox = new JCheckBox(); + this.$$$loadButtonText$$$(myNewTabCheckbox, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.open.in.new.tab")); + myRoot.add(myNewTabCheckbox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), 2, 2)); + myOptionsPanel.setVisible(true); + myOptionsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(myOptionsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, + null, null, 0, false)); + myOptionsPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/XPathBundle", "border.title.match.options"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + myMatchRootNode = new JRadioButton(); + this.$$$loadButtonText$$$(myMatchRootNode, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.evaluate.expression.on.document")); + myOptionsPanel.add(myMatchRootNode, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myMatchEachNode = new JRadioButton(); + this.$$$loadButtonText$$$(myMatchEachNode, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.match.pattern.on.each.node")); + myMatchEachNode.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XPathBundle", "entered.expression.is.treated.as.an.xslt.pattern")); + myOptionsPanel.add(myMatchEachNode, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRoot.add(myScopePanel.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, + false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myMatchRootNode); + buttonGroup.add(myMatchEachNode); } + myScopePanel.initComponent(module, searchScope); + } - @Override - public JComponent getComponent() { - return this; - } + private static Method $$$cachedGetBundleMethod$$$ = null; - public SearchScope getScope() { - return myScopePanel.getSearchScope(); + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } - @Override - public JLabel getIcon() { - return myInputPanel.getIcon(); + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } - @Override - public JButton getEditContextButton() { - return myInputPanel.getEditContextButton(); - } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } - @Override - public JPanel getEditorPanel() { - return myInputPanel.getEditorPanel(); - } + @Override + public JComponent getComponent() { + return this; + } - public JCheckBox getNewTabCheckbox() { - return myNewTabCheckbox; - } + public SearchScope getScope() { + return myScopePanel.getSearchScope(); + } - public JRadioButton getMatchRootNode() { - return myMatchRootNode; - } + @Override + public JLabel getIcon() { + return myInputPanel.getIcon(); + } - public JRadioButton getMatchEachNode() { - return myMatchEachNode; - } + @Override + public JButton getEditContextButton() { + return myInputPanel.getEditContextButton(); + } - public ScopePanel getScopePanel() { - return myScopePanel; - } + @Override + public JPanel getEditorPanel() { + return myInputPanel.getEditorPanel(); + } - public JPanel getOptionsPanel() { - return myOptionsPanel; - } + public JCheckBox getNewTabCheckbox() { + return myNewTabCheckbox; + } + + public JRadioButton getMatchRootNode() { + return myMatchRootNode; + } + + public JRadioButton getMatchEachNode() { + return myMatchEachNode; + } + + public ScopePanel getScopePanel() { + return myScopePanel; + } + + public JPanel getOptionsPanel() { + return myOptionsPanel; + } @Override public void dispose() { diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/ScopePanel.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/ScopePanel.java index 2eb1bd1bac23..41379f3f6859 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/ScopePanel.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/search/ScopePanel.java @@ -27,152 +27,280 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.NlsSafe; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import org.intellij.plugins.xpathView.XPathBundle; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; import java.util.Vector; -public class ScopePanel extends JPanel implements Disposable{ +public class ScopePanel extends JPanel implements Disposable { - @SuppressWarnings({"UnusedDeclaration" }) - private JPanel myRoot; + @SuppressWarnings({"UnusedDeclaration"}) + private final JPanel myRoot; - private JRadioButton myWholeProjectScope; + private final JRadioButton myWholeProjectScope; - private JRadioButton myModuleScope; - private ModulesComboBox myModuleSelection; + private final JRadioButton myModuleScope; + private final ModulesComboBox myModuleSelection; - private JRadioButton myDirectoryScope; - private TextFieldWithBrowseButton myDirectory; - private JCheckBox myRecursive; + private final JRadioButton myDirectoryScope; + private final TextFieldWithBrowseButton myDirectory; + private final JCheckBox myRecursive; - private JRadioButton myCustomScope; - private ComboboxWithBrowseButton myCustomScopeSelection; + private final JRadioButton myCustomScope; + private final ComboboxWithBrowseButton myCustomScopeSelection; - private final Project myProject; + private final Project myProject; - public ScopePanel(@NotNull Project project) { - myProject = project; + public ScopePanel(@NotNull Project project) { + myProject = project; + { + myRoot = this; + myCustomScopeSelection = new ScopeChooserCombo(); } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), 2, 2)); + panel1.setVisible(true); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "border.title.scope"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myWholeProjectScope = new JRadioButton(); + myWholeProjectScope.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myWholeProjectScope, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.whole.project")); + panel1.add(myWholeProjectScope, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDirectoryScope = new JRadioButton(); + myDirectoryScope.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myDirectoryScope, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.directory")); + panel1.add(myDirectoryScope, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myModuleScope = new JRadioButton(); + myModuleScope.setContentAreaFilled(true); + myModuleScope.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myModuleScope, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.module")); + myModuleScope.setVerticalAlignment(0); + myModuleScope.setVerticalTextPosition(0); + myModuleScope.setVisible(true); + panel1.add(myModuleScope, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDirectory = new TextFieldWithBrowseButton(); + panel1.add(myDirectory, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myModuleSelection = new ModulesComboBox(); + panel1.add(myModuleSelection, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCustomScope = new JRadioButton(); + myCustomScope.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myCustomScope, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "radio.button.custom")); + myCustomScope.setVisible(true); + panel1.add(myCustomScope, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCustomScopeSelection.setVisible(true); + panel1.add(myCustomScopeSelection, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRecursive = new JCheckBox(); + myRecursive.setMargin(new Insets(0, 3, 0, 3)); + this.$$$loadButtonText$$$(myRecursive, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "checkbox.recursively")); + panel1.add(myRecursive, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myWholeProjectScope); + buttonGroup.add(myDirectoryScope); + buttonGroup.add(myModuleScope); + buttonGroup.add(myCustomScope); + } + } - public void initComponent(@Nullable Module currentModule, final SearchScope scope) { - final ItemListener stateListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - myModuleSelection.setEnabled(myModuleScope.isSelected()); - myDirectory.setEnabled(myDirectoryScope.isSelected()); - myRecursive.setEnabled(myDirectoryScope.isSelected()); - myCustomScopeSelection.setEnabled(myCustomScope.isSelected()); + private static Method $$$cachedGetBundleMethod$$$ = null; - if (e.getStateChange() == ItemEvent.SELECTED) { - firePropertyChange("scope", null, getSelectedScope()); - } - } - }; - final ItemListener scopeListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - firePropertyChange("scope", null, getSelectedScope()); - } - } - }; + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } - myWholeProjectScope.addItemListener(stateListener); - myWholeProjectScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.PROJECT); - myModuleScope.addItemListener(stateListener); - myModuleScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.MODULE); - myDirectoryScope.addItemListener(stateListener); - myDirectoryScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.DIRECTORY); - myCustomScope.addItemListener(stateListener); - myCustomScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.CUSTOM); - - myModuleSelection.fillModules(myProject); - - Module m; - if (scope.getModuleName() != null) { - if ((m = ModuleManager.getInstance(myProject).findModuleByName(scope.getModuleName())) == null) { - m = currentModule; - } - } else { - m = currentModule; + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - if (m != null) { - myModuleSelection.setSelectedModule(m); + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + + public void initComponent(@Nullable Module currentModule, final SearchScope scope) { + final ItemListener stateListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + myModuleSelection.setEnabled(myModuleScope.isSelected()); + myDirectory.setEnabled(myDirectoryScope.isSelected()); + myRecursive.setEnabled(myDirectoryScope.isSelected()); + myCustomScopeSelection.setEnabled(myCustomScope.isSelected()); + + if (e.getStateChange() == ItemEvent.SELECTED) { + firePropertyChange("scope", null, getSelectedScope()); } + } + }; + final ItemListener scopeListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + firePropertyChange("scope", null, getSelectedScope()); + } + } + }; - myModuleSelection.addItemListener(scopeListener); + myWholeProjectScope.addItemListener(stateListener); + myWholeProjectScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.PROJECT); + myModuleScope.addItemListener(stateListener); + myModuleScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.MODULE); + myDirectoryScope.addItemListener(stateListener); + myDirectoryScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.DIRECTORY); + myCustomScope.addItemListener(stateListener); + myCustomScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.CUSTOM); - ((ScopeChooserCombo)myCustomScopeSelection).init(myProject, true, true, scope.getScopeName(), null); - myCustomScopeSelection.getComboBox().addItemListener(scopeListener); + myModuleSelection.fillModules(myProject); - myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { - @Override - protected void textChanged(@NotNull DocumentEvent e) { - firePropertyChange("scope", null, getSelectedScope()); - } - }); - final @NlsSafe String path = scope.getPath(); - myDirectory.setText(path); - myDirectory.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor() - .withTitle(XPathBundle.message("dialog.title.select.path")) - .withDescription(XPathBundle.message("label.select.path"))); - - myRecursive.setSelected(scope.isRecursive()); + Module m; + if (scope.getModuleName() != null) { + if ((m = ModuleManager.getInstance(myProject).findModuleByName(scope.getModuleName())) == null) { + m = currentModule; + } + } + else { + m = currentModule; + } + if (m != null) { + myModuleSelection.setSelectedModule(m); } - @SuppressWarnings({"unchecked", "UseOfObsoleteCollectionType"}) - private static ComboBoxModel createModel(Object[] elements) { - return new DefaultComboBoxModel(new Vector(Arrays.asList(elements))); - } + myModuleSelection.addItemListener(scopeListener); - private void createUIComponents() { - myRoot = this; - myCustomScopeSelection = new ScopeChooserCombo(); - } + ((ScopeChooserCombo)myCustomScopeSelection).init(myProject, true, true, scope.getScopeName(), null); + myCustomScopeSelection.getComboBox().addItemListener(scopeListener); - private @Nullable String getDirectoryName() { - final String s = myDirectory.getText(); - return !s.isEmpty() ? s : null; - } + myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + @Override + protected void textChanged(@NotNull DocumentEvent e) { + firePropertyChange("scope", null, getSelectedScope()); + } + }); + final @NlsSafe String path = scope.getPath(); + myDirectory.setText(path); + myDirectory.addBrowseFolderListener(myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor() + .withTitle(XPathBundle.message("dialog.title.select.path")) + .withDescription(XPathBundle.message("label.select.path"))); - private @Nullable String getModuleName() { - final Module module = myModuleSelection.getSelectedModule(); - return module != null ? module.getName() : null; - } + myRecursive.setSelected(scope.isRecursive()); + } - private @NotNull SearchScope.ScopeType getScopeType() { - if (myWholeProjectScope.isSelected()) return SearchScope.ScopeType.PROJECT; - if (myModuleScope.isSelected()) return SearchScope.ScopeType.MODULE; - if (myDirectoryScope.isSelected()) return SearchScope.ScopeType.DIRECTORY; - if (myCustomScope.isSelected()) return SearchScope.ScopeType.CUSTOM; + @SuppressWarnings({"unchecked", "UseOfObsoleteCollectionType"}) + private static ComboBoxModel createModel(Object[] elements) { + return new DefaultComboBoxModel(new Vector(Arrays.asList(elements))); + } - assert false : "Unknown Scope"; - return null; - } + private @Nullable String getDirectoryName() { + final String s = myDirectory.getText(); + return !s.isEmpty() ? s : null; + } - public SearchScope getSearchScope() { - final SearchScope scope = getSelectedScope(); - scope.setCustomScope(((ScopeChooserCombo)myCustomScopeSelection).getSelectedScope()); - return scope; - } + private @Nullable String getModuleName() { + final Module module = myModuleSelection.getSelectedModule(); + return module != null ? module.getName() : null; + } - SearchScope getSelectedScope() { - return new SearchScope(getScopeType(), - getDirectoryName(), myRecursive.isSelected(), - getModuleName(), - ((ScopeChooserCombo)myCustomScopeSelection).getSelectedScopeName()); - } + private @NotNull SearchScope.ScopeType getScopeType() { + if (myWholeProjectScope.isSelected()) return SearchScope.ScopeType.PROJECT; + if (myModuleScope.isSelected()) return SearchScope.ScopeType.MODULE; + if (myDirectoryScope.isSelected()) return SearchScope.ScopeType.DIRECTORY; + if (myCustomScope.isSelected()) return SearchScope.ScopeType.CUSTOM; + + assert false : "Unknown Scope"; + return null; + } + + public SearchScope getSearchScope() { + final SearchScope scope = getSelectedScope(); + scope.setCustomScope(((ScopeChooserCombo)myCustomScopeSelection).getSelectedScope()); + return scope; + } + + SearchScope getSelectedScope() { + return new SearchScope(getScopeType(), + getDirectoryName(), myRecursive.isSelected(), + getModuleName(), + ((ScopeChooserCombo)myCustomScopeSelection).getSelectedScopeName()); + } @Override public void dispose() { diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/AddNamespaceDialog.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/AddNamespaceDialog.java index f8c98b2abe0f..d366d3bd62b1 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/AddNamespaceDialog.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/AddNamespaceDialog.java @@ -20,6 +20,9 @@ import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.ui.DocumentAdapter; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import org.jetbrains.annotations.NotNull; @@ -31,82 +34,185 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.ResourceBundle; import java.util.Set; public class AddNamespaceDialog extends DialogWrapper { - public enum Mode { - EDITABLE, PREFIX_EDITABLE, URI_EDITABLE, FIXED + public enum Mode { + EDITABLE, PREFIX_EDITABLE, URI_EDITABLE, FIXED + } + + private final JPanel myRoot; + private final JLabel myIcon; + + private final ComboBox myPrefix; + private final ComboBox myURI; + + public AddNamespaceDialog(Project project, Set unresolvedPrefixes, Collection uriList, Mode mode) { + super(project, false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 10, 10), -1, -1)); + myIcon = new JLabel(); + myIcon.setText("Icon"); //NON-NLS + myRoot.add(myIcon, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XPathBundle", + "label.enter.the.prefix.and.uri.of.the.namespace.to.add")); + myRoot.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 3, new Insets(5, 0, 10, 0), -1, -1)); + myRoot.add(panel1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.prefix1")); + panel1.add(label2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.uri")); + panel1.add(label3, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPrefix = new ComboBox(); + myPrefix.setEditable(true); + panel1.add(myPrefix, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(75, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myURI = new ComboBox(); + myURI.setEditable(true); + panel1.add(myURI, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label2.setLabelFor(myPrefix); + label3.setLabelFor(myURI); } - private JPanel myRoot; - private JLabel myIcon; + myIcon.setText(null); + myIcon.setIcon(Messages.getQuestionIcon()); - private ComboBox myPrefix; - private ComboBox myURI; + myURI.setModel(new DefaultComboBoxModel<>(ArrayUtilRt.toStringArray(uriList))); + myURI.setSelectedItem(""); + myURI.setEditable(mode == Mode.EDITABLE || mode == Mode.URI_EDITABLE); + addUpdateListener(myURI); - public AddNamespaceDialog(Project project, Set unresolvedPrefixes, Collection uriList, Mode mode) { - super(project, false); - - myIcon.setText(null); - myIcon.setIcon(Messages.getQuestionIcon()); - - myURI.setModel(new DefaultComboBoxModel<>(ArrayUtilRt.toStringArray(uriList))); - myURI.setSelectedItem(""); - myURI.setEditable(mode == Mode.EDITABLE || mode == Mode.URI_EDITABLE); - addUpdateListener(myURI); - - myPrefix.setModel(new DefaultComboBoxModel<>(ArrayUtilRt.toStringArray(unresolvedPrefixes))); - myPrefix.setEditable(mode == Mode.EDITABLE || mode == Mode.PREFIX_EDITABLE); - if (unresolvedPrefixes.size() == 1) { - final String next = unresolvedPrefixes.iterator().next(); //NON-NLS - myPrefix.setSelectedItem(next); - } - addUpdateListener(myPrefix); - - updateOkAction(); - init(); + myPrefix.setModel(new DefaultComboBoxModel<>(ArrayUtilRt.toStringArray(unresolvedPrefixes))); + myPrefix.setEditable(mode == Mode.EDITABLE || mode == Mode.PREFIX_EDITABLE); + if (unresolvedPrefixes.size() == 1) { + final String next = unresolvedPrefixes.iterator().next(); //NON-NLS + myPrefix.setSelectedItem(next); } + addUpdateListener(myPrefix); - private void addUpdateListener(ComboBox comboBox) { - final ComboBoxEditor boxEditor = comboBox.getEditor(); - if (boxEditor != null) { - final Component component = boxEditor.getEditorComponent(); - if (component instanceof JTextField) { - ((JTextField)component).getDocument().addDocumentListener(new DocumentAdapter() { - @Override - protected void textChanged(@NotNull DocumentEvent e) { - updateOkAction(); - } - }); - } + updateOkAction(); + init(); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); } - comboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - updateOkAction(); - } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + + private void addUpdateListener(ComboBox comboBox) { + final ComboBoxEditor boxEditor = comboBox.getEditor(); + if (boxEditor != null) { + final Component component = boxEditor.getEditorComponent(); + if (component instanceof JTextField) { + ((JTextField)component).getDocument().addDocumentListener(new DocumentAdapter() { + @Override + protected void textChanged(@NotNull DocumentEvent e) { + updateOkAction(); + } }); + } } + comboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + updateOkAction(); + } + }); + } - private void updateOkAction() { - getOKAction().setEnabled(!getURI().isEmpty() && !getPrefix().isEmpty()); - } + private void updateOkAction() { + getOKAction().setEnabled(!getURI().isEmpty() && !getPrefix().isEmpty()); + } - @Override - protected JComponent createCenterPanel() { - return myRoot; - } + @Override + protected JComponent createCenterPanel() { + return myRoot; + } - public String getPrefix() { - final Object item = (myPrefix.isEditable() ? myPrefix.getEditor().getItem() : myPrefix.getSelectedItem()); - return ((String)item).trim(); - } + public String getPrefix() { + final Object item = (myPrefix.isEditable() ? myPrefix.getEditor().getItem() : myPrefix.getSelectedItem()); + return ((String)item).trim(); + } - public String getURI() { - final Object item = (myURI.isEditable() ? myURI.getEditor().getItem() : myURI.getSelectedItem()); - return ((String)item).trim(); - } + public String getURI() { + final Object item = (myURI.isEditable() ? myURI.getEditor().getItem() : myURI.getSelectedItem()); + return ((String)item).trim(); + } } diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputFormPanel.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputFormPanel.java index cfeed197ccd3..1d5f45111984 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputFormPanel.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputFormPanel.java @@ -15,46 +15,179 @@ */ package org.intellij.plugins.xpathView.ui; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + +import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class InputFormPanel extends JPanel implements InputForm { - @SuppressWarnings({ "UNUSED_SYMBOL"}) - private JPanel myRoot; + @SuppressWarnings({"UNUSED_SYMBOL"}) + private final JPanel myRoot; - private JLabel myIcon; - private JButton myEditContextButton; - private JPanel myEditorPanel; + private final JLabel myIcon; + private final JButton myEditContextButton; + private final JPanel myEditorPanel; - private JButton mySaveTemplate; - private JButton myOpenTemplate; + private final JButton mySaveTemplate; + private final JButton myOpenTemplate; - private void createUIComponents() { - myRoot = this; + public InputFormPanel() { + { + myRoot = this; } - - @Override - public JComponent getComponent() { - return this; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "label.enter.an.xpath.expression")); + myRoot.add(label1, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myIcon = new JLabel(); + myIcon.setText("Icon"); //NON-NLS + myRoot.add(myIcon, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(15, 0, 0, 0), -1, -1)); + myRoot.add(panel1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), 10, -1)); + panel1.add(panel2, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, 1, 1, null, null, null, 0, false)); + myEditContextButton = new JButton(); + this.$$$loadButtonText$$$(myEditContextButton, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "button.edit.context")); + panel2.add(myEditContextButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, new Dimension(20, -1), null, null, 0, false)); + mySaveTemplate = new JButton(); + this.$$$loadButtonText$$$(mySaveTemplate, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "button.save.template")); + mySaveTemplate.setVisible(false); + panel2.add(mySaveTemplate, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOpenTemplate = new JButton(); + this.$$$loadButtonText$$$(myOpenTemplate, this.$$$getMessageFromBundle$$$("messages/XPathBundle", "button.open.template")); + myOpenTemplate.setVisible(false); + panel2.add(myOpenTemplate, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myEditorPanel = new JPanel(); + myEditorPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(myEditorPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); } + } - @Override - public JLabel getIcon() { - return myIcon; + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); } - - @Override - public JButton getEditContextButton() { - return myEditContextButton; + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); } + return bundle.getString(key); + } - @Override - public JPanel getEditorPanel() { - return myEditorPanel; + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } - @Override - public void dispose() {} + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + + @Override + public JComponent getComponent() { + return this; + } + + @Override + public JLabel getIcon() { + return myIcon; + } + + @Override + public JButton getEditContextButton() { + return myEditContextButton; + } + + @Override + public JPanel getEditorPanel() { + return myEditorPanel; + } + + @Override + public void dispose() { } } diff --git a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java index c3c44ff7fff6..cb64f06cb7bc 100644 --- a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java +++ b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/configuration/PyModuleDependenciesConfigurable.java @@ -12,35 +12,109 @@ import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderEntry; import com.intellij.ui.CheckBoxList; import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.EditableListModelDecorator; import org.jetbrains.annotations.Nullable; import javax.swing.DefaultListModel; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; public class PyModuleDependenciesConfigurable implements UnnamedConfigurable { private final Module myModule; private List myInitialDependencies; - private JPanel myMainPanel; - private JPanel myListHolderPanel; + private final JPanel myMainPanel; + private final JPanel myListHolderPanel; private final CheckBoxList myDependenciesList; public PyModuleDependenciesConfigurable(Module module) { myModule = module; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "py.module.dependencies.configurable.list.title")); + myMainPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myListHolderPanel = new JPanel(); + myListHolderPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myListHolderPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myDependenciesList = new CheckBoxList<>(); resetModel(); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDependenciesList, - new EditableListModelDecorator((DefaultListModel) myDependenciesList.getModel())); + new EditableListModelDecorator( + (DefaultListModel)myDependenciesList.getModel())); decorator.disableRemoveAction(); myListHolderPanel.add(decorator.createPanel(), BorderLayout.CENTER); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void resetModel() { myInitialDependencies = Arrays.asList(ModuleRootManager.getInstance(myModule).getDependencies()); List possibleDependencies = new ArrayList<>(myInitialDependencies); @@ -84,7 +158,7 @@ public class PyModuleDependenciesConfigurable implements UnnamedConfigurable { List entries = new ArrayList<>(); for (OrderEntry entry : model.getOrderEntries()) { if (entry instanceof ModuleOrderEntry) { - entries.add((ModuleOrderEntry) entry); + entries.add((ModuleOrderEntry)entry); } } for (ModuleOrderEntry entry : entries) { diff --git a/python/pluginJava/src/com/intellij/python/community/plugin/java/facet/PythonSdkEditorTab.java b/python/pluginJava/src/com/intellij/python/community/plugin/java/facet/PythonSdkEditorTab.java index 147a89e6c69e..293459fcd887 100644 --- a/python/pluginJava/src/com/intellij/python/community/plugin/java/facet/PythonSdkEditorTab.java +++ b/python/pluginJava/src/com/intellij/python/community/plugin/java/facet/PythonSdkEditorTab.java @@ -7,23 +7,55 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.Disposer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.messages.MessageBusConnection; import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class PythonSdkEditorTab extends FacetEditorTab { - private JPanel myMainPanel; - private PythonSdkComboBox mySdkComboBox; + private final JPanel myMainPanel; + private final PythonSdkComboBox mySdkComboBox; private final FacetEditorContext myEditorContext; private final MessageBusConnection myConnection; public PythonSdkEditorTab(final FacetEditorContext editorContext) { myEditorContext = editorContext; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySdkComboBox = new PythonSdkComboBox(); + myMainPanel.add(mySdkComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "py.sdk.editor.python.interpreter.label.text")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + } final Project project = editorContext.getProject(); mySdkComboBox.setProject(project); myConnection = project.getMessageBus().connect(); @@ -45,6 +77,53 @@ public class PythonSdkEditorTab extends FacetEditorTab { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public @Nls String getDisplayName() { return PyBundle.message("configurable.PythonSdkEditorTab.display.name"); @@ -61,7 +140,7 @@ public class PythonSdkEditorTab extends FacetEditorTab { } private JavaPythonFacetConfiguration getFacetConfiguration() { - return ((JavaPythonFacetConfiguration) myEditorContext.getFacet().getConfiguration()); + return ((JavaPythonFacetConfiguration)myEditorContext.getFacet().getConfiguration()); } @Override diff --git a/python/python-restructuredtext/src/com/intellij/restructuredtext/python/SphinxBaseCommand.java b/python/python-restructuredtext/src/com/intellij/restructuredtext/python/SphinxBaseCommand.java index ba977e8f4fe2..353e922816c4 100644 --- a/python/python-restructuredtext/src/com/intellij/restructuredtext/python/SphinxBaseCommand.java +++ b/python/python-restructuredtext/src/com/intellij/restructuredtext/python/SphinxBaseCommand.java @@ -20,6 +20,8 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.restructuredtext.RestBundle; import com.intellij.ui.viewModel.extraction.ToolWindowContentExtractor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.jetbrains.python.PythonHelper; import com.jetbrains.python.ReSTService; import com.jetbrains.python.run.PythonCommandLineState; @@ -32,13 +34,17 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; /** * User : catherine @@ -61,11 +67,31 @@ public class SphinxBaseCommand { } public static final class AskForWorkDir extends DialogWrapper { - private TextFieldWithBrowseButton myInputFile; - private JPanel myPanel; + private final TextFieldWithBrowseButton myInputFile; + private final JPanel myPanel; private AskForWorkDir(Project project) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setEnabled(false); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "sphinx.ask.for.working.directory.label.text")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInputFile = new TextFieldWithBrowseButton(); + myPanel.add(myInputFile, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, + 0, false)); + } setTitle(RestBundle.message("sphinx.set.working.directory.dialog.title")); init(); @@ -79,6 +105,53 @@ public class SphinxBaseCommand { myPanel.setPreferredSize(new Dimension(600, 20)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected JComponent createCenterPanel() { return myPanel; diff --git a/python/python-restructuredtext/src/com/intellij/restructuredtext/python/run/RestConfigurationEditor.java b/python/python-restructuredtext/src/com/intellij/restructuredtext/python/run/RestConfigurationEditor.java index b5c6d628fb71..8298c4130bc7 100644 --- a/python/python-restructuredtext/src/com/intellij/restructuredtext/python/run/RestConfigurationEditor.java +++ b/python/python-restructuredtext/src/com/intellij/restructuredtext/python/run/RestConfigurationEditor.java @@ -11,36 +11,115 @@ import com.intellij.restructuredtext.RestBundle; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.run.AbstractPyCommonOptionsForm; import com.jetbrains.python.run.AbstractPythonRunConfiguration; import com.jetbrains.python.run.PyCommonOptionsFormFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; public class RestConfigurationEditor extends SettingsEditor implements PanelWithAnchor { - private JPanel myMainPanel; - private JPanel myCommonOptionsPlaceholder; - private TextFieldWithBrowseButton myInputFileField; - private JTextField myParamsTextField; - private JCheckBox myOpenInBrowser; - private TextFieldWithBrowseButton myOutputFileField; - private JComboBox myTasks; - private JBLabel myCommandLabel; - private JLabel myConfigurationName; + private final JPanel myMainPanel; + private final JPanel myCommonOptionsPlaceholder; + private final TextFieldWithBrowseButton myInputFileField; + private final JTextField myParamsTextField; + private final JCheckBox myOpenInBrowser; + private final TextFieldWithBrowseButton myOutputFileField; + private final JComboBox myTasks; + private final JBLabel myCommandLabel; + private final JLabel myConfigurationName; private final AbstractPyCommonOptionsForm myCommonOptionsForm; private final Project myProject; private JComponent anchor; public RestConfigurationEditor(Project project, AbstractPythonRunConfiguration configuration, CollectionComboBoxModel model) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1)); + myCommonOptionsPlaceholder = new JPanel(); + myCommonOptionsPlaceholder.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myCommonOptionsPlaceholder, new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/RestBundle", "runcfg.docutils.input")); + myMainPanel.add(label1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myInputFileField = new TextFieldWithBrowseButton(); + myMainPanel.add(myInputFileField, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, + null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/RestBundle", "runcfg.docutils.options")); + myMainPanel.add(label2, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myParamsTextField = new JTextField(); + myMainPanel.add(myParamsTextField, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RestBundle", "runcfg.docutils.output")); + myMainPanel.add(label3, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myOutputFileField = new TextFieldWithBrowseButton(); + myMainPanel.add(myOutputFileField, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + 1, null, null, null, 0, false)); + myOpenInBrowser = new JCheckBox(); + this.$$$loadButtonText$$$(myOpenInBrowser, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "rest.configuration.editor.open.output.file.in.browser.label.text")); + myMainPanel.add(myOpenInBrowser, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTasks = new JComboBox(); + myMainPanel.add(myTasks, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myCommandLabel = new JBLabel(); + this.$$$loadLabelText$$$(myCommandLabel, this.$$$getMessageFromBundle$$$("messages/RestBundle", "runcfg.docutils.command")); + myMainPanel.add(myCommandLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_FIXED, 1, null, new Dimension(20, -1), null, 0, false)); + myConfigurationName = new JLabel(); + Font myConfigurationNameFont = this.$$$getFont$$$(null, Font.BOLD, -1, myConfigurationName.getFont()); + if (myConfigurationNameFont != null) myConfigurationName.setFont(myConfigurationNameFont); + myConfigurationName.setText(""); + myMainPanel.add(myConfigurationName, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(-1, 20), null, 0, false)); + } myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData()); myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel()); myProject = project; @@ -51,10 +130,12 @@ public class RestConfigurationEditor extends SettingsEditor= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected void resetEditorFrom(@NotNull RestRunConfiguration configuration) { AbstractPythonRunConfiguration.copyParams(configuration, @@ -72,10 +249,12 @@ public class RestConfigurationEditor extends SettingsEditor>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 10, 10, 10), -1, -1)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.optimize.imports"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySortImports = new JBCheckBox(); + this.$$$loadButtonText$$$(mySortImports, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", "formatter.imports.panel.sort.imports")); + panel1.add(mySortImports, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySortNamesInFromImports = new JBCheckBox(); + this.$$$loadButtonText$$$(mySortNamesInFromImports, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.sort.names.in.from.imports")); + panel1.add(mySortNamesInFromImports, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + mySortImportsByTypeFirst = new JBCheckBox(); + this.$$$loadButtonText$$$(mySortImportsByTypeFirst, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", "formatter.imports.panel.sort.by.type")); + panel1.add(mySortImportsByTypeFirst, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + mySortCaseInsensitively = new JBCheckBox(); + mySortCaseInsensitively.setSelected(false); + this.$$$loadButtonText$$$(mySortCaseInsensitively, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.sort.case.insensitively")); + panel1.add(mySortCaseInsensitively, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 2, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.from.imports.structure.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, new Color(-16777216))); + myDoNothingWithFromImports = new JBRadioButton(); + this.$$$loadButtonText$$$(myDoNothingWithFromImports, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.from.imports.leave.as.is")); + panel2.add(myDoNothingWithFromImports, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myJoinFromImportsWithSameSource = new JBRadioButton(); + myJoinFromImportsWithSameSource.setSelected(false); + this.$$$loadButtonText$$$(myJoinFromImportsWithSameSource, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.from.imports.join.with.same.source")); + panel2.add(myJoinFromImportsWithSameSource, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myAlwaysSplitFromImports = new JBRadioButton(); + this.$$$loadButtonText$$$(myAlwaysSplitFromImports, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.imports.panel.from.imports.always.split")); + panel2.add(myAlwaysSplitFromImports, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myRootPanel.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myDoNothingWithFromImports); + buttonGroup.add(myJoinFromImportsWithSameSource); + buttonGroup.add(myAlwaysSplitFromImports); + } addPanelToWatch(myRootPanel); mySortImports.addActionListener(e -> { @@ -43,6 +146,53 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + @Override protected @TabTitle @NotNull String getTabTitle() { return PySyntaxBundle.message("formatter.imports.panel.title"); diff --git a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java index 22fe46c4920b..bfe54cc1b66b 100644 --- a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java +++ b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java @@ -8,7 +8,12 @@ import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.ui.ComboBox; import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.PresentableEnumUtil; import com.jetbrains.python.PythonFileType; import com.jetbrains.python.PythonLanguage; @@ -17,26 +22,141 @@ import com.jetbrains.python.highlighting.PyHighlighter; import com.jetbrains.python.psi.LanguageLevel; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Color; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { - private JPanel myPanel; - private JBCheckBox myAddTrailingBlankLineCheckbox; - private JBCheckBox myUseContinuationIndentForParameters; - private JBCheckBox myUseContinuationIndentForArguments; - private JBCheckBox myUseContinuationIndentForCollectionsAndComprehensions; - private ComboBox myDictAlignmentCombo; - private JPanel myPreviewPanel; - private JBCheckBox myFormatInjectedFragments; - private JBCheckBox myAddIndentInsideInjections; + private final JPanel myPanel; + private final JBCheckBox myAddTrailingBlankLineCheckbox; + private final JBCheckBox myUseContinuationIndentForParameters; + private final JBCheckBox myUseContinuationIndentForArguments; + private final JBCheckBox myUseContinuationIndentForCollectionsAndComprehensions; + private final ComboBox myDictAlignmentCombo; + private final JPanel myPreviewPanel; + private final JBCheckBox myFormatInjectedFragments; + private final JBCheckBox myAddIndentInsideInjections; protected PyOtherCodeStylePanel(CodeStyleSettings settings) { super(PythonLanguage.getInstance(), null, settings); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPreviewPanel = new JPanel(); + myPreviewPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myPreviewPanel, new GridConstraints(0, 1, 4, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPreviewPanel.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 3, new Insets(10, 10, 10, 10), -1, -1)); + panel1.setOpaque(true); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", "formatter.panel.dict.alignment.label")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAddTrailingBlankLineCheckbox = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddTrailingBlankLineCheckbox, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", "formatter.panel.add.trailing.line.feed")); + panel1.add(myAddTrailingBlankLineCheckbox, + new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDictAlignmentCombo = new ComboBox(); + panel1.add(myDictAlignmentCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.use.continuation.indent.for.title"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myUseContinuationIndentForArguments = new JBCheckBox(); + this.$$$loadButtonText$$$(myUseContinuationIndentForArguments, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.use.continuation.indent.for.arguments")); + panel2.add(myUseContinuationIndentForArguments, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseContinuationIndentForParameters = new JBCheckBox(); + this.$$$loadButtonText$$$(myUseContinuationIndentForParameters, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.use.continuation.indent.for.parameters")); + panel2.add(myUseContinuationIndentForParameters, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseContinuationIndentForCollectionsAndComprehensions = new JBCheckBox(); + this.$$$loadButtonText$$$(myUseContinuationIndentForCollectionsAndComprehensions, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.use.continuation.indent.for.collection.literals")); + panel2.add(myUseContinuationIndentForCollectionsAndComprehensions, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.putClientProperty("html.disable", Boolean.FALSE); + panel1.add(panel3, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.injected.fragments"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, + this.$$$getFont$$$(null, -1, -1, panel3.getFont()), + new Color(-4211011))); + myAddIndentInsideInjections = new JBCheckBox(); + this.$$$loadButtonText$$$(myAddIndentInsideInjections, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", + "formatter.panel.injected.fragments.use.continuation.indent")); + panel3.add(myAddIndentInsideInjections, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myFormatInjectedFragments = new JBCheckBox(); + this.$$$loadButtonText$$$(myFormatInjectedFragments, + this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", "formatter.panel.format.injected.fragments")); + panel3.add(myFormatInjectedFragments, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myPanel.add(spacer2, new GridConstraints(1, 0, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myPanel.add(spacer3, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } addPanelToWatch(myPanel); installPreviewPanel(myPreviewPanel); @@ -48,7 +168,7 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { somethingChanged(); } }); - + myUseContinuationIndentForParameters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -78,6 +198,102 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { }); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected EditorHighlighter createHighlighter(@NotNull EditorColorsScheme scheme) { return HighlighterFactory.createHighlighter(new PyHighlighter(LanguageLevel.PYTHON26), scheme); @@ -110,7 +326,8 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { myAddTrailingBlankLineCheckbox.setSelected(pySettings.BLANK_LINE_AT_FILE_END); myUseContinuationIndentForParameters.setSelected(pySettings.USE_CONTINUATION_INDENT_FOR_PARAMETERS); myUseContinuationIndentForArguments.setSelected(pySettings.USE_CONTINUATION_INDENT_FOR_ARGUMENTS); - myUseContinuationIndentForCollectionsAndComprehensions.setSelected(pySettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS); + myUseContinuationIndentForCollectionsAndComprehensions.setSelected( + pySettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS); myFormatInjectedFragments.setSelected(pySettings.FORMAT_INJECTED_FRAGMENTS); myAddIndentInsideInjections.setSelected(pySettings.ADD_INDENT_INSIDE_INJECTIONS); } @@ -131,7 +348,7 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { public boolean isModified(CodeStyleSettings settings) { final PyCodeStyleSettings customSettings = getCustomSettings(settings); return customSettings.DICT_ALIGNMENT != getDictAlignmentAsInt() || - customSettings.BLANK_LINE_AT_FILE_END != ensureTrailingBlankLine() || + customSettings.BLANK_LINE_AT_FILE_END != ensureTrailingBlankLine() || customSettings.USE_CONTINUATION_INDENT_FOR_PARAMETERS != useContinuationIndentForParameters() || customSettings.USE_CONTINUATION_INDENT_FOR_ARGUMENTS != useContinuationIndentForArguments() || customSettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS != useContinuationIndentForCollectionLiterals() || @@ -181,18 +398,18 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { 1, 2, 3) - + def foo_decl( a, b, c): pass - + { "green": 42, "eggs and ham": -0.0e0 } - + odds = [ num for num in range(42) if num % 2 != 0\s diff --git a/python/src/com/jetbrains/python/codeInsight/testIntegration/CreateTestDialog.java b/python/src/com/jetbrains/python/codeInsight/testIntegration/CreateTestDialog.java index 4c58758bdd83..61e2fd539ed7 100644 --- a/python/src/com/jetbrains/python/codeInsight/testIntegration/CreateTestDialog.java +++ b/python/src/com/jetbrains/python/codeInsight/testIntegration/CreateTestDialog.java @@ -6,7 +6,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TableUtil; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.table.JBTable; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ui.JBUI; import com.jetbrains.python.PyBundle; import one.util.streamex.StreamEx; @@ -14,36 +19,90 @@ import org.jetbrains.annotations.NotNull; import javax.swing.AbstractAction; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.table.DefaultTableModel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; import java.util.Vector; public final class CreateTestDialog extends DialogWrapper { private final @NotNull PyTestCreationModel myModel; private final boolean myClassRequired; - private TextFieldWithBrowseButton myTargetDir; - private JTextField myClassName; - private JPanel myMainPanel; - private JTextField myFileName; - private JTable myMethodsTable; + private final TextFieldWithBrowseButton myTargetDir; + private final JTextField myClassName; + private final JPanel myMainPanel; + private final JTextField myFileName; + private final JTable myMethodsTable; private final @NotNull DefaultTableModel myTableModel; private CreateTestDialog(final @NotNull Project project, final @NotNull PyTestCreationModel model) { super(project); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.setMinimumSize(new Dimension(400, 400)); + myMainPanel.setPreferredSize(new Dimension(400, 400)); + myMainPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myMainPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myTargetDir = new TextFieldWithBrowseButton(); + myMainPanel.add(myTargetDir, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.create.test.target.directory")); + myMainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myClassName = new JTextField(); + myMainPanel.add(myClassName, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.create.test.test.class.name")); + myMainPanel.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myFileName = new JTextField(); + myMainPanel.add(myFileName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.create.test.test.file.name")); + myMainPanel.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myMainPanel.add(jBScrollPane1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myMethodsTable = new JBTable(); + myMethodsTable.setShowVerticalLines(true); + myMethodsTable.setUpdateSelectionOnSort(false); + jBScrollPane1.setViewportView(myMethodsTable); + } init(); myClassRequired = StringUtil.isNotEmpty(model.getClassName()); myModel = model; - myTargetDir.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(PyBundle.message("code.insight.select.target.directory"))); + myTargetDir.addBrowseFolderListener(project, FileChooserDescriptorFactory.createSingleFolderDescriptor() + .withTitle(PyBundle.message("code.insight.select.target.directory"))); myTargetDir.setEditable(false); myTargetDir.addActionListener(new ActionListener() { @@ -107,6 +166,53 @@ public final class CreateTestDialog extends DialogWrapper { getOKAction().setEnabled(isValid()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + static boolean userAcceptsTestCreation(final @NotNull Project project, final @NotNull PyTestCreationModel model) { final CreateTestDialog dialog = new CreateTestDialog(project, model); if (!dialog.showAndGet()) { diff --git a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java index afe9f64deab5..2fb077ca4388 100644 --- a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java +++ b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java @@ -28,8 +28,12 @@ import com.intellij.python.community.impl.pipenv.PathKt; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.FileContentUtil; import com.intellij.util.FileContentUtilCore; import com.intellij.util.ObjectUtils; @@ -55,11 +59,16 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; @@ -67,27 +76,28 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public class PyIntegratedToolsConfigurable implements SearchableConfigurable { - private JPanel myMainPanel; - private JComboBox> myTestRunnerComboBox; - private JComboBox myDocstringFormatComboBox; + private final JPanel myMainPanel; + private final JComboBox> myTestRunnerComboBox; + private final JComboBox myDocstringFormatComboBox; private PyTestRunConfigurationsModel myModel; private final @Nullable Module myModule; private final @NotNull Project myProject; private final PyDocumentationSettings myDocumentationSettings; - private TextFieldWithBrowseButton myWorkDir; - private JCheckBox txtIsRst; - private JPanel myErrorPanel; - private TextFieldWithBrowseButton myRequirementsPathField; - private JCheckBox analyzeDoctest; - private JPanel myDocStringsPanel; - private JPanel myRestPanel; - private JCheckBox renderExternal; - private JPanel myPackagingPanel; - private JPanel myTestsPanel; - private TextFieldWithBrowseButton myPipEnvPathField; - private JPanel myPipEnvPanel; + private final TextFieldWithBrowseButton myWorkDir; + private final JCheckBox txtIsRst; + private final JPanel myErrorPanel; + private final TextFieldWithBrowseButton myRequirementsPathField; + private final JCheckBox analyzeDoctest; + private final JPanel myDocStringsPanel; + private final JPanel myRestPanel; + private final JCheckBox renderExternal; + private final JPanel myPackagingPanel; + private final JPanel myTestsPanel; + private final TextFieldWithBrowseButton myPipEnvPathField; + private final JPanel myPipEnvPanel; private final @NotNull Collection<@NotNull DialogPanel> myCustomizePanels = PyIntegratedToolsTestPanelCustomizer.Companion.createPanels(); @@ -102,6 +112,120 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { private PyIntegratedToolsConfigurable(@Nullable Module module, @NotNull Project project) { myModule = module; myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myErrorPanel = new JPanel(); + myErrorPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myErrorPanel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myDocStringsPanel = new JPanel(); + myDocStringsPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myDocStringsPanel, new GridConstraints(3, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.integrated.tools.docstring.format")); + myDocStringsPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myDocstringFormatComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + myDocstringFormatComboBox.setModel(defaultComboBoxModel1); + myDocStringsPanel.add(myDocstringFormatComboBox, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + analyzeDoctest = new JCheckBox(); + this.$$$loadButtonText$$$(analyzeDoctest, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.integrated.tools.analyze.python.code.in.docstrings")); + myDocStringsPanel.add(analyzeDoctest, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + renderExternal = new JCheckBox(); + this.$$$loadButtonText$$$(renderExternal, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.integrated.tools.render.external.documentation.for.stdlib")); + myDocStringsPanel.add(renderExternal, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRestPanel = new JPanel(); + myRestPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myRestPanel, new GridConstraints(5, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.integrated.tools.sphinx.working.directory")); + myRestPanel.add(jBLabel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myWorkDir = new TextFieldWithBrowseButton(); + myRestPanel.add(myWorkDir, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + txtIsRst = new JCheckBox(); + this.$$$loadButtonText$$$(txtIsRst, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.integrated.tools.treat.txt.files.as.restructuredtext")); + myRestPanel.add(txtIsRst, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPackagingPanel = new JPanel(); + myPackagingPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myPackagingPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.integrated.tools.package.requirements.file")); + myPackagingPanel.add(jBLabel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myRequirementsPathField = new TextFieldWithBrowseButton(); + myPackagingPanel.add(myRequirementsPathField, + new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myTestsPanel = new JPanel(); + myTestsPanel.setLayout(new BorderLayout(0, 0)); + myMainPanel.add(myTestsPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.integrated.tools.default.test.runner")); + myTestsPanel.add(label1, BorderLayout.WEST); + myTestRunnerComboBox = new JComboBox(); + myTestsPanel.add(myTestRunnerComboBox, BorderLayout.CENTER); + myPipEnvPanel = new JPanel(); + myPipEnvPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myPipEnvPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.integrated.tools.path.to.pipenv.executable")); + myPipEnvPanel.add(jBLabel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myPipEnvPathField = new TextFieldWithBrowseButton(); + myPipEnvPanel.add(myPipEnvPathField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + jBLabel1.setLabelFor(myDocstringFormatComboBox); + jBLabel2.setLabelFor(myDocstringFormatComboBox); + } myDocumentationSettings = PyDocumentationSettings.getInstance(myModule); PyPackageRequirementsSettings packagingSettings = PyPackageRequirementsSettings.getInstance(module); myDocstringFormatComboBox.setModel(new CollectionComboBoxModel<>(new ArrayList<>(Arrays.asList(DocStringFormat.values())), @@ -128,6 +252,78 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { myPipEnvPanel.setBorder(IdeBorderFactory.createTitledBorder(PyBundle.message("integrated.tools.configurable.pipenv"))); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private @NotNull String getRequirementsPath() { if (myModule == null) { return ""; @@ -174,8 +370,9 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { var factory = myModel.getSelected(); if (factory != null && !factory.isFrameworkInstalled(myProject, sdk)) { return new ValidationResult(PyBundle.message("runcfg.testing.no.test.framework", factory.getName()), - // isFrameworkInstalled() == false => getPackageSpec() != null - createQuickFix(sdk, facetErrorPanel, Objects.requireNonNull(factory.getPackageSpec()).getPackageName())); + // isFrameworkInstalled() == false => getPackageSpec() != null + createQuickFix(sdk, facetErrorPanel, + Objects.requireNonNull(factory.getPackageSpec()).getPackageName())); } } return ValidationResult.OK; diff --git a/python/src/com/jetbrains/python/console/PyConsoleOptionsConfigurable.java b/python/src/com/jetbrains/python/console/PyConsoleOptionsConfigurable.java index 7e9eb49fb200..09ca79037a7b 100644 --- a/python/src/com/jetbrains/python/console/PyConsoleOptionsConfigurable.java +++ b/python/src/com/jetbrains/python/console/PyConsoleOptionsConfigurable.java @@ -7,17 +7,27 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsSafe; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; import java.util.function.Supplier; public final class PyConsoleOptionsConfigurable extends SearchableConfigurable.Parent.Abstract implements Configurable.NoScroll { @@ -154,14 +164,161 @@ public final class PyConsoleOptionsConfigurable extends SearchableConfigurable.P } private static class PyConsoleOptionsPanel { - private JPanel myWholePanel; - private JBCheckBox myShowDebugConsoleByDefault; - private JBCheckBox myIpythonEnabledCheckbox; - private JBCheckBox myShowsVariablesByDefault; - private JBCheckBox myUseExistingConsole; - private JBCheckBox myCommandQueueEnabledCheckbox; - private ComboBox myCodeCompletionComboBox; - private JBLabel myCodeCompletionLabel; + private final JPanel myWholePanel; + private final JBCheckBox myShowDebugConsoleByDefault; + private final JBCheckBox myIpythonEnabledCheckbox; + private final JBCheckBox myShowsVariablesByDefault; + private final JBCheckBox myUseExistingConsole; + private final JBCheckBox myCommandQueueEnabledCheckbox; + private final ComboBox myCodeCompletionComboBox; + private final JBLabel myCodeCompletionLabel; + + public PyConsoleOptionsPanel() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myWholePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, + null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.console.options.settings.title.system.settings"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myShowDebugConsoleByDefault = new JBCheckBox(); + this.$$$loadButtonText$$$(myShowDebugConsoleByDefault, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.console.options.always.show.debug.console")); + panel1.add(myShowDebugConsoleByDefault, + new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel1.add(spacer2, new GridConstraints(5, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myIpythonEnabledCheckbox = new JBCheckBox(); + this.$$$loadButtonText$$$(myIpythonEnabledCheckbox, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.console.options.use.ipython.if.available")); + panel1.add(myIpythonEnabledCheckbox, + new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myShowsVariablesByDefault = new JBCheckBox(); + this.$$$loadButtonText$$$(myShowsVariablesByDefault, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.console.options.show.console.variables.by.default")); + panel1.add(myShowsVariablesByDefault, + new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myUseExistingConsole = new JBCheckBox(); + this.$$$loadButtonText$$$(myUseExistingConsole, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.console.options.use.existing.console.for.run.with.python.console")); + panel1.add(myUseExistingConsole, + new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCommandQueueEnabledCheckbox = new JBCheckBox(); + myCommandQueueEnabledCheckbox.setSelected(true); + this.$$$loadButtonText$$$(myCommandQueueEnabledCheckbox, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.console.options.use.command.queue")); + panel1.add(myCommandQueueEnabledCheckbox, + new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myCodeCompletionComboBox = new ComboBox(); + panel1.add(myCodeCompletionComboBox, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, + null, null, 0, false)); + myCodeCompletionLabel = new JBLabel(); + this.$$$loadLabelText$$$(myCodeCompletionLabel, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.console.options.code.completion")); + panel1.add(myCodeCompletionLabel, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myWholePanel.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + private PyConsoleOptions myOptionsProvider; public JPanel createPanel(PyConsoleOptions optionsProvider) { @@ -194,7 +351,7 @@ public final class PyConsoleOptionsConfigurable extends SearchableConfigurable.P public boolean isModified() { return myShowDebugConsoleByDefault.isSelected() != myOptionsProvider.isShowDebugConsoleByDefault() || - myIpythonEnabledCheckbox.isSelected() != myOptionsProvider.isIpythonEnabled() || + myIpythonEnabledCheckbox.isSelected() != myOptionsProvider.isIpythonEnabled() || myShowsVariablesByDefault.isSelected() != myOptionsProvider.isShowVariableByDefault() || myUseExistingConsole.isSelected() != myOptionsProvider.isUseExistingConsole() || myCommandQueueEnabledCheckbox.isSelected() != myOptionsProvider.isCommandQueueEnabled() || diff --git a/python/src/com/jetbrains/python/console/PyConsoleSpecificOptionsPanel.java b/python/src/com/jetbrains/python/console/PyConsoleSpecificOptionsPanel.java index 69041e44c34f..6e2be3e6ad5b 100644 --- a/python/src/com/jetbrains/python/console/PyConsoleSpecificOptionsPanel.java +++ b/python/src/com/jetbrains/python/console/PyConsoleSpecificOptionsPanel.java @@ -7,6 +7,10 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiDocumentManager; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.UIUtil; import com.jetbrains.python.PythonFileType; import com.jetbrains.python.psi.impl.PyExpressionCodeFragmentImpl; @@ -16,23 +20,81 @@ import com.jetbrains.python.run.PyCommonOptionsFormData; import com.jetbrains.python.run.PyCommonOptionsFormFactory; import org.jetbrains.annotations.NotNull; +import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; public class PyConsoleSpecificOptionsPanel { private final Project myProject; - private JPanel myWholePanel; - private JPanel myStartingScriptPanel; - private JPanel myInterpreterPanel; + private final JPanel myWholePanel; + private final JPanel myStartingScriptPanel; + private final JPanel myInterpreterPanel; private PyConsoleOptions.PyConsoleSettings myConsoleSettings; private EditorTextField myEditorTextField; private AbstractPyCommonOptionsForm myCommonOptionsForm; public PyConsoleSpecificOptionsPanel(Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myWholePanel = new JPanel(); + myWholePanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + myStartingScriptPanel = new JPanel(); + myStartingScriptPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myStartingScriptPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myWholePanel.add(myStartingScriptPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(80, 80), + new Dimension(100, 130), null, 0, false)); + myStartingScriptPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/PyBundle", "form.console.specific.options.starting.script"), TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, + null)); + final Spacer spacer1 = new Spacer(); + myWholePanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myInterpreterPanel = new JPanel(); + myInterpreterPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myInterpreterPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myWholePanel.add(myInterpreterPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + new Dimension(80, 80), null, null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myWholePanel; } + public JPanel createPanel(final PyConsoleOptions.PyConsoleSettings optionsProvider) { myInterpreterPanel.setLayout(new BorderLayout()); myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(createCommonOptionsFormData()); diff --git a/python/src/com/jetbrains/python/debugger/PyDebuggerConfigurable.java b/python/src/com/jetbrains/python/debugger/PyDebuggerConfigurable.java index f8a04e095102..5d851fbda5c0 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebuggerConfigurable.java +++ b/python/src/com/jetbrains/python/debugger/PyDebuggerConfigurable.java @@ -17,36 +17,45 @@ import com.intellij.ui.components.ActionLink; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; import java.util.function.Supplier; public final class PyDebuggerConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private JPanel myMainPanel; - private JCheckBox myAttachToSubprocess; - private JCheckBox mySaveSignatures; - private JCheckBox mySupportGevent; - private JBCheckBox mySupportQt; - private JCheckBox myDropIntoDebuggerOnFailedTests; - private JBLabel warningIcon; - private ComboBox myPyQtBackend; - private ActionLink myActionLink; - private JBTextField myAttachProcessFilter; - private JBLabel myAttachFilterLabel; - private JBLabel myDebuggerPortLabel; - private JBIntSpinner myDebuggerPort; - private JBCheckBox myRunDebuggerInServerMode; - private JPanel myDebuggerPortPanel; - private JBLabel myDebuggerEvaluationResponseTimeoutLabel; - private JBIntSpinner myDebuggerEvaluationResponseTimeout; + private final JPanel myMainPanel; + private final JCheckBox myAttachToSubprocess; + private final JCheckBox mySaveSignatures; + private final JCheckBox mySupportGevent; + private final JBCheckBox mySupportQt; + private final JCheckBox myDropIntoDebuggerOnFailedTests; + private final JBLabel warningIcon; + private final ComboBox myPyQtBackend; + private final ActionLink myActionLink; + private final JBTextField myAttachProcessFilter; + private final JBLabel myAttachFilterLabel; + private final JBLabel myDebuggerPortLabel; + private final JBIntSpinner myDebuggerPort; + private final JBCheckBox myRunDebuggerInServerMode; + private final JPanel myDebuggerPortPanel; + private final JBLabel myDebuggerEvaluationResponseTimeoutLabel; + private final JBIntSpinner myDebuggerEvaluationResponseTimeout; private enum PyQtBackend { AUTO(PyBundle.messagePointer("python.debugger.qt.backend.auto")), @@ -82,6 +91,165 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con public PyDebuggerConfigurable(Project project) { myProject = project; + { + warningIcon = new JBLabel(AllIcons.General.BalloonWarning); + IdeTooltipManager.getInstance().setCustomTooltip( + warningIcon, + new TooltipWithClickableLinks.ForBrowser(warningIcon, + PyBundle.message("debugger.warning.message"))); + + myActionLink = new ActionLink(PyBundle.message("form.debugger.clear.caches.action"), e -> { + boolean cleared = PySignatureCacheManager.getInstance(myProject).clearCache(); + String message; + if (cleared) { + message = PyBundle.message("python.debugger.collection.signatures.deleted"); + } + else { + message = PyBundle.message("python.debugger.nothing.to.delete"); + } + Messages.showInfoMessage(myProject, message, PyBundle.message("debugger.delete.signature.cache")); + }); + + myRunDebuggerInServerMode = new JBCheckBox(); + myDebuggerPortPanel = new JPanel(); + myDebuggerPortLabel = new JBLabel(PyBundle.message("form.debugger.debugger.port")); + myDebuggerPort = new JBIntSpinner(0, PortRange.MIN, PortRange.MAX); + + if (!Registry.is("python.debug.use.single.port")) { + myRunDebuggerInServerMode.setVisible(false); + myDebuggerPortPanel.setVisible(false); + myDebuggerPortLabel.setVisible(false); + myDebuggerPort.setVisible(false); + } + + myDebuggerEvaluationResponseTimeoutLabel = new JBLabel(PyBundle.message("form.debugger.response.timeout")); + myDebuggerEvaluationResponseTimeout = new JBIntSpinner(0, 0, Integer.MAX_VALUE, 500); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(4, 4, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 6, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myAttachToSubprocess = new JCheckBox(); + this.$$$loadButtonText$$$(myAttachToSubprocess, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.debugger.attach.to.subprocess.automatically.while.debugging")); + panel1.add(myAttachToSubprocess, new GridConstraints(0, 0, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + mySaveSignatures = new JCheckBox(); + mySaveSignatures.setActionCommand(this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.save.call.signatures")); + mySaveSignatures.setLabel( + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.collect.run.time.types.information.for.code.insight")); + this.$$$loadButtonText$$$(mySaveSignatures, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.debugger.collect.run.time.types.information.for.code.insight")); + panel1.add(mySaveSignatures, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mySupportGevent = new JCheckBox(); + this.$$$loadButtonText$$$(mySupportGevent, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.gevent.compatible")); + panel1.add(mySupportGevent, new GridConstraints(2, 0, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mySupportQt = new JBCheckBox(); + this.$$$loadButtonText$$$(mySupportQt, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.pyqt.compatible")); + panel1.add(mySupportQt, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + panel1.add(warningIcon, + new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPyQtBackend = new ComboBox(); + panel1.add(myPyQtBackend, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + jBLabel1.setText(" "); + panel1.add(jBLabel1, + new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + this.$$$loadButtonText$$$(myActionLink, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.clear.caches")); + panel1.add(myActionLink, + new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, new Dimension(75, 11), null, 0, false)); + myDropIntoDebuggerOnFailedTests = new JCheckBox(); + myDropIntoDebuggerOnFailedTests.setSelected(false); + this.$$$loadButtonText$$$(myDropIntoDebuggerOnFailedTests, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.drop.into.debugger.on.failed.tests")); + panel1.add(myDropIntoDebuggerOnFailedTests, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myRunDebuggerInServerMode.setHorizontalAlignment(10); + myRunDebuggerInServerMode.setSelected(true); + this.$$$loadButtonText$$$(myRunDebuggerInServerMode, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.run.debugger.in.server.mode")); + panel1.add(myRunDebuggerInServerMode, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myDebuggerPortPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(myDebuggerPortPanel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 1, false)); + this.$$$loadLabelText$$$(myDebuggerPortLabel, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.debugger.port")); + myDebuggerPortPanel.add(myDebuggerPortLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + myDebuggerPort.setMax(65535); + myDebuggerPort.setMin(0); + myDebuggerPortPanel.add(myDebuggerPort, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(3, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myAttachFilterLabel = new JBLabel(); + this.$$$loadLabelText$$$(myAttachFilterLabel, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.debugger.for.attach.to.process.show.processes.with.names.containing")); + myAttachFilterLabel.putClientProperty("html.disable", Boolean.FALSE); + myMainPanel.add(myAttachFilterLabel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + this.$$$loadLabelText$$$(myDebuggerEvaluationResponseTimeoutLabel, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.response.timeout")); + myDebuggerEvaluationResponseTimeoutLabel.putClientProperty("html.disable", Boolean.FALSE); + myMainPanel.add(myDebuggerEvaluationResponseTimeoutLabel, + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAttachProcessFilter = new JBTextField(); + myAttachProcessFilter.setEnabled(true); + myAttachProcessFilter.setText( + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.remote.interpreter.docker.default.interpreter.path")); + myMainPanel.add(myAttachProcessFilter, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer3 = new Spacer(); + myMainPanel.add(spacer3, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + myDebuggerEvaluationResponseTimeout.setMax(2147483647); + myDebuggerEvaluationResponseTimeout.setMin(0); + myMainPanel.add(myDebuggerEvaluationResponseTimeout, + new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myAttachFilterLabel.setLabelFor(myAttachProcessFilter); + myDebuggerEvaluationResponseTimeoutLabel.setLabelFor(myAttachProcessFilter); + } Arrays.stream(PyQtBackend.values()).forEach(e -> myPyQtBackend.addItem(e)); mySupportQt.addItemListener(new ItemListener() { @@ -102,6 +270,78 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con myAttachFilterLabel.setText(PyBundle.message("debugger.attach.to.process.filter.names")); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override public String getDisplayName() { return PyBundle.message("configurable.PyDebuggerConfigurable.display.name"); @@ -173,39 +413,4 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con myAttachProcessFilter.setText(settings.getAttachProcessFilter()); myDebuggerEvaluationResponseTimeout.setNumber(settings.getEvaluationResponseTimeout()); } - - private void createUIComponents() { - warningIcon = new JBLabel(AllIcons.General.BalloonWarning); - IdeTooltipManager.getInstance().setCustomTooltip( - warningIcon, - new TooltipWithClickableLinks.ForBrowser(warningIcon, - PyBundle.message("debugger.warning.message"))); - - myActionLink = new ActionLink(PyBundle.message("form.debugger.clear.caches.action"), e -> { - boolean cleared = PySignatureCacheManager.getInstance(myProject).clearCache(); - String message; - if (cleared) { - message = PyBundle.message("python.debugger.collection.signatures.deleted"); - } - else { - message = PyBundle.message("python.debugger.nothing.to.delete"); - } - Messages.showInfoMessage(myProject, message, PyBundle.message("debugger.delete.signature.cache")); - }); - - myRunDebuggerInServerMode = new JBCheckBox(); - myDebuggerPortPanel = new JPanel(); - myDebuggerPortLabel = new JBLabel(PyBundle.message("form.debugger.debugger.port")); - myDebuggerPort = new JBIntSpinner(0, PortRange.MIN, PortRange.MAX); - - if (!Registry.is("python.debug.use.single.port")) { - myRunDebuggerInServerMode.setVisible(false); - myDebuggerPortPanel.setVisible(false); - myDebuggerPortLabel.setVisible(false); - myDebuggerPort.setVisible(false); - } - - myDebuggerEvaluationResponseTimeoutLabel = new JBLabel(PyBundle.message("form.debugger.response.timeout")); - myDebuggerEvaluationResponseTimeout = new JBIntSpinner(0, 0, Integer.MAX_VALUE, 500); - } } diff --git a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java index acb87223a1aa..521d15f808d1 100644 --- a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java +++ b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java @@ -5,6 +5,9 @@ import com.intellij.openapi.options.ConfigurableUi; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.NonEmptyInputValidator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.Function; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.table.TableModelEditor; @@ -12,24 +15,70 @@ import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class PyDebuggerSteppingConfigurableUi implements ConfigurableUi { private static final ColumnInfo[] COLUMNS = { new EnabledColumn(), new FilterColumn() }; - private JPanel myPanel; - private JPanel mySteppingPanel; - private JBCheckBox myLibrariesFilterCheckBox; - private JBCheckBox myStepFilterEnabledCheckBox; - private JBCheckBox myAlwaysDoSmartStepIntoCheckBox; + private final JPanel myPanel; + private final JPanel mySteppingPanel; + private final JBCheckBox myLibrariesFilterCheckBox; + private final JBCheckBox myStepFilterEnabledCheckBox; + private final JBCheckBox myAlwaysDoSmartStepIntoCheckBox; private TableModelEditor myPySteppingFilterEditor; public PyDebuggerSteppingConfigurableUi() { + { + TableModelEditor.DialogItemEditor itemEditor = new DialogEditor(); + myPySteppingFilterEditor = new TableModelEditor<>(COLUMNS, itemEditor, PyBundle.message("debugger.stepping.no.script.filters")); + mySteppingPanel = new JPanel(new BorderLayout()); + mySteppingPanel.add(myPySteppingFilterEditor.createComponent()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(mySteppingPanel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + myLibrariesFilterCheckBox = new JBCheckBox(); + myLibrariesFilterCheckBox.setHorizontalAlignment(2); + this.$$$loadButtonText$$$(myLibrariesFilterCheckBox, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.debugger.stepping.checkbox.text.do.not.step.into.library.scripts")); + myPanel.add(myLibrariesFilterCheckBox, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myStepFilterEnabledCheckBox = new JBCheckBox(); + myStepFilterEnabledCheckBox.setHorizontalAlignment(2); + this.$$$loadButtonText$$$(myStepFilterEnabledCheckBox, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.stepping.do.not.step.into.scripts")); + myPanel.add(myStepFilterEnabledCheckBox, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myAlwaysDoSmartStepIntoCheckBox = new JBCheckBox(); + myAlwaysDoSmartStepIntoCheckBox.setHorizontalAlignment(2); + myAlwaysDoSmartStepIntoCheckBox.setSelected(false); + this.$$$loadButtonText$$$(myAlwaysDoSmartStepIntoCheckBox, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.debugger.stepping.always.do.smart.step.into")); + myPanel.add(myAlwaysDoSmartStepIntoCheckBox, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } myStepFilterEnabledCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nullable ActionEvent e) { @@ -38,13 +87,53 @@ public class PyDebuggerSteppingConfigurableUi implements ConfigurableUi itemEditor = new DialogEditor(); - myPySteppingFilterEditor = new TableModelEditor<>(COLUMNS, itemEditor, PyBundle.message("debugger.stepping.no.script.filters")); - mySteppingPanel = new JPanel(new BorderLayout()); - mySteppingPanel.add(myPySteppingFilterEditor.createComponent()); + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); } + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public void reset(@NotNull PyDebuggerSettings settings) { myLibrariesFilterCheckBox.setSelected(settings.isLibrariesFilterEnabled()); @@ -118,7 +207,9 @@ public class PyDebuggerSteppingConfigurableUi implements ConfigurableUi mutator, boolean isAdd) { + public void edit(@NotNull PySteppingFilter item, + @NotNull Function mutator, + boolean isAdd) { String pattern = Messages.showInputDialog(myPanel, PyBundle.message("debugger.stepping.filter.specify.pattern"), PyBundle.message("debugger.stepping.filter"), null, item.getFilter(), diff --git a/python/src/com/jetbrains/python/documentation/PythonDocumentationEntryEditor.java b/python/src/com/jetbrains/python/documentation/PythonDocumentationEntryEditor.java index f57067f65dc2..22c58bd835ae 100644 --- a/python/src/com/jetbrains/python/documentation/PythonDocumentationEntryEditor.java +++ b/python/src/com/jetbrains/python/documentation/PythonDocumentationEntryEditor.java @@ -3,31 +3,117 @@ package com.jetbrains.python.documentation; import com.google.common.collect.Maps; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBList; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.PyBundle; +import javax.swing.AbstractButton; +import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.text.BadLocationException; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Map; +import java.util.ResourceBundle; public class PythonDocumentationEntryEditor extends DialogWrapper { - private JPanel myPanel; - private JTextField myNameField; - private JTextField myURLPatternTextField; - private JButton myInsertButton; - private JBList myMacroList; + private final JPanel myPanel; + private final JTextField myNameField; + private final JTextField myURLPatternTextField; + private final JButton myInsertButton; + private final JBList myMacroList; public PythonDocumentationEntryEditor(Component parent) { super(parent, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myNameField = new JTextField(); + myPanel.add(myNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.documentation.entry.module.name")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.documentation.entry.url.path.pattern")); + myPanel.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myURLPatternTextField = new JTextField(); + myURLPatternTextField.setColumns(50); + myPanel.add(myURLPatternTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(600, -1), null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanel.add(panel1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.documentation.entry.available.macros"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + panel1.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + new Dimension(-1, 150), null, 0, false)); + myMacroList = new JBList(); + final DefaultListModel defaultListModel1 = new DefaultListModel(); + defaultListModel1.addElement("{element.name} - name of element under caret"); + defaultListModel1.addElement("{element.qname} - full-qualified name of element under caret"); + defaultListModel1.addElement("{module.name} - name of module containing element under caret"); + defaultListModel1.addElement("{module.basename} - last component of the full-qualified module name of element under caret"); + defaultListModel1.addElement("{class.name} - name of class containing element under caret"); + defaultListModel1.addElement("{function.name} - name of function under caret"); + defaultListModel1.addElement("{functionOrProp.name} - name of function or property (e.g. isEnabled reduced to enabled)"); + defaultListModel1.addElement("{functionIsProperty?} - boolean macros that checks whether function is property,"); + defaultListModel1.addElement("if true substitutes with text between ? and }"); + defaultListModel1.addElement("{python.version} - version of selected Python interpreter"); + defaultListModel1.addElement(".lower - convert text to lower case"); + defaultListModel1.addElement(".slashes - replace . with /"); + defaultListModel1.addElement(".dashes - replace _ with -"); + myMacroList.setModel(defaultListModel1); + myMacroList.setSelectionMode(0); + jBScrollPane1.setViewportView(myMacroList); + myInsertButton = new JButton(); + myInsertButton.setFocusable(false); + this.$$$loadButtonText$$$(myInsertButton, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.documentation.entry.insert")); + panel1.add(myInsertButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myNameField); + label2.setLabelFor(myURLPatternTextField); + } init(); setTitle(PyBundle.message("external.documentation.edit.documentation.url")); myInsertButton.addActionListener(new ActionListener() { @@ -57,6 +143,78 @@ public class PythonDocumentationEntryEditor extends DialogWrapper { updateButtonEnabled(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + private void updateButtonEnabled() { myInsertButton.setEnabled(myMacroList.getSelectedValue() != null); } diff --git a/python/src/com/jetbrains/python/packaging/PyPackageInstallationErrorDialog.java b/python/src/com/jetbrains/python/packaging/PyPackageInstallationErrorDialog.java index e52a7a82e563..ce090e295e73 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageInstallationErrorDialog.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageInstallationErrorDialog.java @@ -13,6 +13,9 @@ import com.intellij.ui.components.JBScrollBar; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.fields.ExpandableSupport; import com.intellij.ui.components.fields.ExtendableTextComponent; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.packaging.ui.PyPackageManagementService; import com.jetbrains.python.run.PyVirtualEnvReaderKt; import com.jetbrains.python.sdk.impl.PySdkBundle; @@ -21,26 +24,175 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JSeparator; import javax.swing.JTextArea; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.datatransfer.StringSelection; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; public class PyPackageInstallationErrorDialog extends DialogWrapper { - private JPanel myMainPanel; - private JTextArea myCommandOutput; - private JPanel myCommandOutputPanel; - private JBLabel packageName; - private JBLabel interpreterPath; - private JBLabel pythonVersion; - private JBLabel myLabelWithLink; - private JTextArea myCommandToTry; - private JBScrollPane myScrollPaneForCommandToTry; + private final JPanel myMainPanel; + private final JTextArea myCommandOutput; + private final JPanel myCommandOutputPanel; + private final JBLabel packageName; + private final JBLabel interpreterPath; + private final JBLabel pythonVersion; + private final JBLabel myLabelWithLink; + private final JTextArea myCommandToTry; + private final JBScrollPane myScrollPaneForCommandToTry; public PyPackageInstallationErrorDialog(@NotNull @NlsContexts.DialogTitle String title, @NotNull PyPackageManagementService.PyPackageInstallationErrorDescription errorDescription) { super(false); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(6, 4, new Insets(0, 0, 0, 0), -1, 10)); + myCommandOutputPanel = new JPanel(); + myCommandOutputPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(myCommandOutputPanel, new GridConstraints(0, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.field.command.output")); + myCommandOutputPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + myCommandOutputPanel.add(jBScrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(700, 300), null, + 0, false)); + myCommandOutput = new JTextArea(); + myCommandOutput.setEditable(false); + myCommandOutput.setLineWrap(true); + myCommandOutput.setMargin(new Insets(6, 12, 16, 24)); + myCommandOutput.setText(this.$$$getMessageFromBundle$$$("messages/LangBundle", "text.area.packaging.error.no.output")); + jBScrollPane1.setViewportView(myCommandOutput); + packageName = new JBLabel(); + packageName.setText(""); + myMainPanel.add(packageName, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + pythonVersion = new JBLabel(); + pythonVersion.setText(""); + pythonVersion.putClientProperty("html.disable", Boolean.FALSE); + myMainPanel.add(pythonVersion, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + interpreterPath = new JBLabel(); + interpreterPath.setHorizontalAlignment(10); + interpreterPath.setText(""); + interpreterPath.setToolTipText(""); + myMainPanel.add(interpreterPath, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.field.package")); + myMainPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.field.interpreter.path")); + myMainPanel.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.field.python.version")); + myMainPanel.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JSeparator separator1 = new JSeparator(); + myMainPanel.add(separator1, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.add(panel1, new GridConstraints(5, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + Font jBLabel2Font = this.$$$getFont$$$(null, Font.BOLD, -1, jBLabel2.getFont()); + if (jBLabel2Font != null) jBLabel2.setFont(jBLabel2Font); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.field.troubleshooting.steps")); + panel1.add(jBLabel2, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myScrollPaneForCommandToTry = new JBScrollPane(); + myScrollPaneForCommandToTry.setVerticalScrollBarPolicy(22); + panel1.add(myScrollPaneForCommandToTry, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(700, 50), null, + 0, false)); + myScrollPaneForCommandToTry.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(8, 12, 8, 12), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCommandToTry = new JTextArea(); + myCommandToTry.setEditable(false); + myCommandToTry.setMargin(new Insets(0, 0, 0, 0)); + myScrollPaneForCommandToTry.setViewportView(myCommandToTry); + myLabelWithLink = new JBLabel(); + this.$$$loadLabelText$$$(myLabelWithLink, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.troubleshooting.steps.guide")); + panel1.add(myLabelWithLink, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel3 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel3, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.troubleshooting.steps.try.in.terminal")); + panel1.add(jBLabel3, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel4 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel4, this.$$$getMessageFromBundle$$$("messages/PySdkBundle", + "python.sdk.packaging.installation.failure.troubleshooting.steps.if.command.crashes")); + panel1.add(jBLabel4, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel5 = new JBLabel(); + jBLabel5.setText("1."); + panel1.add(jBLabel5, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel6 = new JBLabel(); + jBLabel6.setText("2."); + panel1.add(jBLabel6, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel7 = new JBLabel(); + panel1.add(jBLabel7, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myMainPanel.add(spacer1, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myMainPanel.add(spacer2, new GridConstraints(1, 3, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + jBLabel1.setLabelFor(jBScrollPane1); + } init(); setTitle(title); final String output = errorDescription.getOutput(); @@ -98,6 +250,77 @@ public class PyPackageInstallationErrorDialog extends DialogWrapper { this.pythonVersion.setCopyable(true); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + @Override protected @Nullable JComponent createCenterPanel() { return myMainPanel; diff --git a/python/src/com/jetbrains/python/refactoring/introduce/PyIntroduceDialog.java b/python/src/com/jetbrains/python/refactoring/introduce/PyIntroduceDialog.java index 338a73b40fae..5d8a95ca2e06 100644 --- a/python/src/com/jetbrains/python/refactoring/introduce/PyIntroduceDialog.java +++ b/python/src/com/jetbrains/python/refactoring/introduce/PyIntroduceDialog.java @@ -11,7 +11,11 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.EditorComboBoxEditor; import com.intellij.ui.EditorComboBoxRenderer; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.StringComboboxEditor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.PyBundle; import com.jetbrains.python.PyPsiBundle; import com.jetbrains.python.PythonFileType; @@ -20,30 +24,36 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.Collection; import java.util.EnumSet; +import java.util.ResourceBundle; public class PyIntroduceDialog extends DialogWrapper { - private JPanel myContentPane; - private JLabel myNameLabel; - private ComboBox myNameComboBox; - private JCheckBox myReplaceAll; - private JRadioButton mySamePlace; - private JRadioButton myConstructor; - private JRadioButton mySetUp; - private JPanel myPlaceSelector; + private final JPanel myContentPane; + private final JLabel myNameLabel; + private final ComboBox myNameComboBox; + private final JCheckBox myReplaceAll; + private final JRadioButton mySamePlace; + private final JRadioButton myConstructor; + private final JRadioButton mySetUp; + private final JPanel myPlaceSelector; private final Project myProject; private final int myOccurrencesCount; @@ -57,6 +67,85 @@ public class PyIntroduceDialog extends DialogWrapper { final String helpId, final IntroduceOperation operation) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPane = new JPanel(); + myContentPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myNameLabel = new JLabel(); + this.$$$loadLabelText$$$(myNameLabel, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.introduce.name")); + panel1.add(myNameLabel, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameComboBox = new ComboBox(); + myNameComboBox.setEditable(true); + myNameComboBox.setLightWeightPopupEnabled(true); + panel1.add(myNameComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myContentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myReplaceAll = new JCheckBox(); + myReplaceAll.setSelected(false); + this.$$$loadButtonText$$$(myReplaceAll, + this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "replace.all.occurences.checkbox")); + panel3.add(myReplaceAll, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPlaceSelector = new JPanel(); + myPlaceSelector.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPlaceSelector.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(myPlaceSelector, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPlaceSelector.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/RefactoringBundle", "initialize.in.border.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, + null, null)); + mySamePlace = new JRadioButton(); + this.$$$loadButtonText$$$(mySamePlace, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "current.method.radio")); + myPlaceSelector.add(mySamePlace, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPlaceSelector.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myConstructor = new JRadioButton(); + this.$$$loadButtonText$$$(myConstructor, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "class.constructors.radio")); + myPlaceSelector.add(myConstructor, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySetUp = new JRadioButton(); + this.$$$loadButtonText$$$(mySetUp, this.$$$getMessageFromBundle$$$("messages/RefactoringBundle", "setup.method.radio")); + myPlaceSelector.add(mySetUp, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myContentPane.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(mySamePlace); + buttonGroup.add(myConstructor); + buttonGroup.add(mySetUp); + } myOccurrencesCount = operation.getOccurrences().size(); myValidator = validator; myProject = project; @@ -70,6 +159,78 @@ public class PyIntroduceDialog extends DialogWrapper { updateControls(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPane; } + @Override protected String getHelpId() { return myHelpId; @@ -100,7 +261,8 @@ public class PyIntroduceDialog extends DialogWrapper { myContentPane.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true)); + IdeFocusManager.getGlobalInstance() + .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true)); } }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); @@ -167,7 +329,7 @@ public class PyIntroduceDialog extends DialogWrapper { public IntroduceHandler.InitPlace getInitPlace() { if (myConstructor.isSelected()) return IntroduceHandler.InitPlace.CONSTRUCTOR; - if (mySetUp.isSelected()) return IntroduceHandler.InitPlace.SET_UP; + if (mySetUp.isSelected()) return IntroduceHandler.InitPlace.SET_UP; return IntroduceHandler.InitPlace.SAME_METHOD; } } diff --git a/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldPanel.java b/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldPanel.java index 8ceec722faa9..25c81b8de35e 100644 --- a/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldPanel.java +++ b/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldPanel.java @@ -3,26 +3,103 @@ package com.jetbrains.python.refactoring.introduce.field; import com.intellij.openapi.project.Project; import com.intellij.refactoring.introduce.inplace.KeyboardComboSwitcher; +import com.intellij.ui.components.JBLabel; import com.jetbrains.python.PyBundle; import com.jetbrains.python.refactoring.introduce.IntroduceHandler; +import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.BorderLayout; +import java.awt.Color; +import java.lang.reflect.Method; import java.util.EnumSet; +import java.util.ResourceBundle; public class PyIntroduceFieldPanel { - private JPanel myRootPanel; - private JComboBox myInitializerPlaceCombo; + private final JPanel myRootPanel; + private final JComboBox myInitializerPlaceCombo; public PyIntroduceFieldPanel(Project project, EnumSet initPlaces) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new BorderLayout(0, 0)); + myRootPanel.setFocusable(false); + myRootPanel.setBorder( + BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 6, 0, 12), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, new Color(-16777216))); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.introduce.field.initialize.in")); + myRootPanel.add(jBLabel1, BorderLayout.WEST); + myInitializerPlaceCombo = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("current method"); + defaultComboBoxModel1.addElement("constructor"); + myInitializerPlaceCombo.setModel(defaultComboBoxModel1); + myRootPanel.add(myInitializerPlaceCombo, BorderLayout.CENTER); + jBLabel1.setLabelFor(myInitializerPlaceCombo); + } KeyboardComboSwitcher.setupActions(myInitializerPlaceCombo, project); if (initPlaces.contains(IntroduceHandler.InitPlace.SET_UP)) { - ((DefaultComboBoxModel) myInitializerPlaceCombo.getModel()).addElement(PyBundle.message("refactoring.introduce.field.setup.method")); + ((DefaultComboBoxModel)myInitializerPlaceCombo.getModel()).addElement(PyBundle.message("refactoring.introduce.field.setup.method")); } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + public JPanel getRootPanel() { return myRootPanel; } diff --git a/python/src/com/jetbrains/python/refactoring/move/PyBaseMoveDialog.java b/python/src/com/jetbrains/python/refactoring/move/PyBaseMoveDialog.java index 98ac0715a01e..e4b032e5d95e 100644 --- a/python/src/com/jetbrains/python/refactoring/move/PyBaseMoveDialog.java +++ b/python/src/com/jetbrains/python/refactoring/move/PyBaseMoveDialog.java @@ -9,27 +9,76 @@ import com.intellij.openapi.ui.TextComponentAccessor; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.io.File; +import java.lang.reflect.Method; +import java.util.ResourceBundle; /** * @author Mikhail Golubev */ public abstract class PyBaseMoveDialog extends RefactoringDialog { - protected JPanel myCenterPanel; - protected JPanel myExtraPanel; - protected TextFieldWithBrowseButton myBrowseFieldWithButton; - protected JBLabel myDescription; - protected JTextField mySourcePathField; + protected final JPanel myCenterPanel; + protected final JPanel myExtraPanel; + protected final TextFieldWithBrowseButton myBrowseFieldWithButton; + protected final JBLabel myDescription; + protected final JTextField mySourcePathField; public PyBaseMoveDialog(Project project, @NotNull String sourcePath, @NotNull String destinationPath) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myCenterPanel = new JPanel(); + myCenterPanel.setLayout(new GridLayoutManager(4, 2, new Insets(5, 5, 5, 5), -1, -1)); + myCenterPanel.putClientProperty("BorderFactoryClass", ""); + myDescription = new JBLabel(); + this.$$$loadLabelText$$$(myDescription, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "refactoring.move.module.members.dialog.description.selection")); + myCenterPanel.add(myDescription, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myBrowseFieldWithButton = new TextFieldWithBrowseButton(); + myCenterPanel.add(myBrowseFieldWithButton, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myExtraPanel = new JPanel(); + myExtraPanel.setLayout(new BorderLayout(0, 0)); + myExtraPanel.putClientProperty("BorderFactoryClass", ""); + myCenterPanel.add(myExtraPanel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.move.module.members.to")); + myCenterPanel.add(jBLabel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.move.module.members.from")); + myCenterPanel.add(jBLabel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + mySourcePathField = new JTextField(); + mySourcePathField.setEditable(false); + myCenterPanel.add(mySourcePathField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } mySourcePathField.setText(sourcePath); myBrowseFieldWithButton.setText(destinationPath); var descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor() @@ -39,6 +88,53 @@ public abstract class PyBaseMoveDialog extends RefactoringDialog { myBrowseFieldWithButton.addBrowseFolderListener(project, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myCenterPanel; } + @Override protected void init() { super.init(); diff --git a/python/src/com/jetbrains/python/testing/PyTestSharedForm.java b/python/src/com/jetbrains/python/testing/PyTestSharedForm.java index 28e8036d86c7..fd430b1e5438 100644 --- a/python/src/com/jetbrains/python/testing/PyTestSharedForm.java +++ b/python/src/com/jetbrains/python/testing/PyTestSharedForm.java @@ -13,9 +13,12 @@ import com.intellij.psi.PsiDirectory; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TextAccessor; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; import com.intellij.ui.components.JBTextField; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ThreeState; import com.intellij.util.ui.JBUI; import com.jetbrains.python.PySymbolFieldWithBrowseButton; @@ -38,7 +41,12 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.border.TitledBorder; +import java.awt.FlowLayout; import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; @@ -47,6 +55,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.ResourceBundle; import static com.jetbrains.python.run.PythonScriptCommandLineState.getExpandedWorkingDir; @@ -59,20 +68,20 @@ import static com.jetbrains.python.run.PythonScriptCommandLineState.getExpandedW */ public final class PyTestSharedForm implements SimplePropertiesProvider { - private JPanel myPanel; + private final JPanel myPanel; /** * Panel for test targets */ - private JPanel myTargets; + private final JPanel myTargets; /** * Panel for environment options */ - private JPanel myOptionsPanel; + private final JPanel myOptionsPanel; /** * Panel for custom options, specific for runner and for "Additional Arguments"al;sop */ - private JPanel myCustomOptionsPanel; - private JPanel myPanelForTargetFields; + private final JPanel myCustomOptionsPanel; + private final JPanel myPanelForTargetFields; private final ButtonGroup myButtonGroup = new ButtonGroup(); private AbstractPyCommonOptionsForm myOptionsForm; @@ -102,6 +111,57 @@ public final class PyTestSharedForm implements SimplePropertiesProvider { private PyTestSharedForm(final @Nullable Module module, final @NotNull PyAbstractTestConfiguration configuration) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.setEnabled(false); + myPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.test.shared.test"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.test.shared.target")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTargets = new JPanel(); + myTargets.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel1.add(myTargets, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myOptionsPanel = new JPanel(); + myOptionsPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(myOptionsPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myCustomOptionsPanel = new JPanel(); + myCustomOptionsPanel.setLayout(new GridBagLayout()); + myPanel.add(myCustomOptionsPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, true)); + myPanelForTargetFields = new JPanel(); + myPanelForTargetFields.setLayout(new GridBagLayout()); + myPanel.add(myPanelForTargetFields, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + } myPathTarget = new TextFieldWithBrowseButton(); final Project project = configuration.getProject(); @@ -129,6 +189,53 @@ public final class PyTestSharedForm implements SimplePropertiesProvider { }); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + /** * Titles border used among test run configurations */ @@ -141,7 +248,7 @@ public final class PyTestSharedForm implements SimplePropertiesProvider { * @param customOptions additional option names this form shall support. Make sure your configuration has appropriate properties. */ public static @NotNull PyTestSharedForm create(final @NotNull PyAbstractTestConfiguration configuration, - final PyTestCustomOption @NotNull ... customOptions) { + final PyTestCustomOption @NotNull ... customOptions) { final PyTestSharedForm form = new PyTestSharedForm(configuration.getModule(), configuration); for (final PyRunTargetVariant testTargetType : PyRunTargetVariant.values()) { diff --git a/python/src/com/jetbrains/python/testing/PythonTestLegacyRunConfigurationForm.java b/python/src/com/jetbrains/python/testing/PythonTestLegacyRunConfigurationForm.java index 8491a42b992c..14e363f092f7 100644 --- a/python/src/com/jetbrains/python/testing/PythonTestLegacyRunConfigurationForm.java +++ b/python/src/com/jetbrains/python/testing/PythonTestLegacyRunConfigurationForm.java @@ -6,21 +6,35 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.LabeledComponentNoThrow; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.PanelWithAnchor; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.jetbrains.python.PyBundle; import com.jetbrains.python.run.AbstractPyCommonOptionsForm; import com.jetbrains.python.run.AbstractPythonRunConfigurationParams; import com.jetbrains.python.run.PyCommonOptionsFormFactory; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.ResourceBundle; import static com.intellij.openapi.util.io.FileUtil.toSystemIndependentName; import static com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration.TestType; @@ -29,28 +43,28 @@ import static com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfigurat * @author Leonid Shalupov */ public class PythonTestLegacyRunConfigurationForm implements AbstractPythonTestRunConfigurationParams, PanelWithAnchor { - private JPanel myRootPanel; - private LabeledComponentNoThrow myTestClassComponent; - private LabeledComponentNoThrow myTestMethodComponent; - private LabeledComponentNoThrow myTestFolderComponent; - private LabeledComponentNoThrow myTestScriptComponent; - private JRadioButton myAllInFolderRB; - private JRadioButton myTestScriptRB; - private JRadioButton myTestClassRB; - private JRadioButton myTestMethodRB; - private JRadioButton myTestFunctionRB; - private JPanel myAdditionalPanel; - private JPanel myCommonOptionsPlaceholder; - private JPanel myTestsPanel; - private JCheckBox myPatternCheckBox; + private final JPanel myRootPanel; + private final LabeledComponentNoThrow myTestClassComponent; + private final LabeledComponentNoThrow myTestMethodComponent; + private final LabeledComponentNoThrow myTestFolderComponent; + private final LabeledComponentNoThrow myTestScriptComponent; + private final JRadioButton myAllInFolderRB; + private final JRadioButton myTestScriptRB; + private final JRadioButton myTestClassRB; + private final JRadioButton myTestMethodRB; + private final JRadioButton myTestFunctionRB; + private final JPanel myAdditionalPanel; + private final JPanel myCommonOptionsPlaceholder; + private final JPanel myTestsPanel; + private final JCheckBox myPatternCheckBox; - private TextFieldWithBrowseButton myTestFolderTextField; - private TextFieldWithBrowseButton myTestScriptTextField; - private JTextField myTestMethodTextField; - private JTextField myTestClassTextField; - private JTextField myPatternTextField; - private JTextField myParamTextField; - private JCheckBox myParamCheckBox; + private final TextFieldWithBrowseButton myTestFolderTextField; + private final TextFieldWithBrowseButton myTestScriptTextField; + private final JTextField myTestMethodTextField; + private final JTextField myTestClassTextField; + private final JTextField myPatternTextField; + private final JTextField myParamTextField; + private final JCheckBox myParamCheckBox; private final Project myProject; private final AbstractPyCommonOptionsForm myCommonOptionsForm; @@ -61,6 +75,164 @@ public class PythonTestLegacyRunConfigurationForm implements AbstractPythonTestR public PythonTestLegacyRunConfigurationForm(final Project project, final AbstractPythonLegacyTestRunConfiguration configuration) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + final JPanel panel1 = new JPanel(); + panel1.setLayout(new CardLayout(0, 0)); + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(myRootPanel, "Card1"); + myTestsPanel = new JPanel(); + myTestsPanel.setLayout(new CardLayout(0, 0)); + myTestsPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRootPanel.add(myTestsPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 200), null, 0, false)); + myTestsPanel.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.test.run.configuration.unittest"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(9, 7, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myTestsPanel.add(panel2, "Card1"); + myTestClassComponent = new LabeledComponentNoThrow(); + myTestClassComponent.setLabelLocation("West"); //NON-NLS + myTestClassComponent.setText(this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.class_label")); + panel2.add(myTestClassComponent, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myTestMethodComponent = new LabeledComponentNoThrow(); + myTestMethodComponent.setLabelLocation("West"); //NON-NLS + myTestMethodComponent.setText(this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.method_label")); + panel2.add(myTestMethodComponent, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myTestScriptComponent = new LabeledComponentNoThrow(); + myTestScriptComponent.setLabelLocation("West"); //NON-NLS + myTestScriptComponent.setText(this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.test_script_label")); + panel2.add(myTestScriptComponent, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myAdditionalPanel = new JPanel(); + myAdditionalPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(myAdditionalPanel, new GridConstraints(8, 0, 1, 7, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myTestFolderComponent = new LabeledComponentNoThrow(); + myTestFolderComponent.setLabelLocation("West"); //NON-NLS + myTestFolderComponent.setText(this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.folder_path")); + panel2.add(myTestFolderComponent, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myPatternCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myPatternCheckBox, this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.pattern")); + panel2.add(myPatternCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestFolderTextField = new TextFieldWithBrowseButton(); + panel2.add(myTestFolderTextField, new GridConstraints(1, 1, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myPatternTextField = new JTextField(); + myPatternTextField.setToolTipText( + "One or more patterns the file names should match for the files to be considered tests. Use comma as the delimiter. The patterns should be glob patterns. For example \"spa*py,eg*py\""); //NON-NLS + panel2.add(myPatternTextField, new GridConstraints(2, 1, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTestScriptTextField = new TextFieldWithBrowseButton(); + panel2.add(myTestScriptTextField, new GridConstraints(3, 1, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myTestClassTextField = new JTextField(); + panel2.add(myTestClassTextField, new GridConstraints(4, 1, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myTestMethodTextField = new JTextField(); + panel2.add(myTestMethodTextField, new GridConstraints(5, 1, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(7, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.test_type_title")); + panel2.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, new Dimension(82, -1), null, null, 0, false)); + myAllInFolderRB = new JRadioButton(); + this.$$$loadButtonText$$$(myAllInFolderRB, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.all_in_folder_title")); + panel2.add(myAllInFolderRB, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestScriptRB = new JRadioButton(); + this.$$$loadButtonText$$$(myTestScriptRB, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.all_in_script_title")); + panel2.add(myTestScriptRB, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestClassRB = new JRadioButton(); + this.$$$loadButtonText$$$(myTestClassRB, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.test_class_title")); + panel2.add(myTestClassRB, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestMethodRB = new JRadioButton(); + this.$$$loadButtonText$$$(myTestMethodRB, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.test_method_title")); + panel2.add(myTestMethodRB, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myTestFunctionRB = new JRadioButton(); + this.$$$loadButtonText$$$(myTestFunctionRB, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "runcfg.unittest.dlg.test_function_title")); + panel2.add(myTestFunctionRB, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myParamCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myParamCheckBox, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.test.run.configuration.params")); + panel2.add(myParamCheckBox, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myParamTextField = new JTextField(); + myParamTextField.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.test.run.configuration.specify.nosetests.command.line.options")); + panel2.add(myParamTextField, new GridConstraints(6, 1, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myCommonOptionsPlaceholder = new JPanel(); + myCommonOptionsPlaceholder.setLayout(new BorderLayout(0, 0)); + myCommonOptionsPlaceholder.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myCommonOptionsPlaceholder.putClientProperty("html.disable", Boolean.FALSE); + myRootPanel.add(myCommonOptionsPlaceholder, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + myRootPanel.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 10), null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myAllInFolderRB); + buttonGroup.add(myTestScriptRB); + buttonGroup.add(myTestClassRB); + buttonGroup.add(myTestMethodRB); + buttonGroup.add(myTestFunctionRB); + } myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData()); myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel(), BorderLayout.CENTER); initComponents(); @@ -78,6 +250,75 @@ public class PythonTestLegacyRunConfigurationForm implements AbstractPythonTestR myParamCheckBox.setVisible(false); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + @Override public AbstractPythonRunConfigurationParams getBaseParams() { return myCommonOptionsForm; @@ -247,11 +488,11 @@ public class PythonTestLegacyRunConfigurationForm implements AbstractPythonTestR myTestMethodTextField.setVisible(testType == TestType.TEST_METHOD || testType == TestType.TEST_FUNCTION); myPatternTextField.setEnabled(myPatternCheckBox.isSelected()); myParamTextField.setEnabled(myParamCheckBox.isSelected()); - myTestMethodComponent.getLabel().setText(testType == TestType.TEST_METHOD? PyBundle.message("runcfg.unittest.dlg.method_label") - : PyBundle.message("runcfg.unittest.dlg.function_label")); + myTestMethodComponent.getLabel().setText(testType == TestType.TEST_METHOD ? PyBundle.message("runcfg.unittest.dlg.method_label") + : PyBundle.message("runcfg.unittest.dlg.function_label")); if (myPatternIsVisible) { - myPatternTextField.setVisible(getTestType() == AbstractPythonLegacyTestRunConfiguration.TestType.TEST_FOLDER); - myPatternCheckBox.setVisible(getTestType() == AbstractPythonLegacyTestRunConfiguration.TestType.TEST_FOLDER); + myPatternTextField.setVisible(getTestType() == TestType.TEST_FOLDER); + myPatternCheckBox.setVisible(getTestType() == TestType.TEST_FOLDER); } } @@ -266,6 +507,7 @@ public class PythonTestLegacyRunConfigurationForm implements AbstractPythonTestR public JPanel getTestsPanel() { return myTestsPanel; } + public JTextField getPatternComponent() { return myPatternTextField; } diff --git a/python/src/com/jetbrains/python/testing/tox/PyToxConfigurationSettings.java b/python/src/com/jetbrains/python/testing/tox/PyToxConfigurationSettings.java index 1fe2a38c11a3..d9fdb2b3deef 100644 --- a/python/src/com/jetbrains/python/testing/tox/PyToxConfigurationSettings.java +++ b/python/src/com/jetbrains/python/testing/tox/PyToxConfigurationSettings.java @@ -5,6 +5,11 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBLabel; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtilRt; import com.jetbrains.python.run.AbstractPyCommonOptionsForm; import com.jetbrains.python.run.AbstractPythonRunConfiguration; @@ -14,11 +19,17 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.text.JTextComponent; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.List; +import java.util.ResourceBundle; import java.util.regex.Pattern; /** @@ -28,14 +39,102 @@ final class PyToxConfigurationSettings extends SettingsEditor>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + myPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/PyBundle", + "form.tox.configuration.runcfg.tox"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myArgumentsField = new JTextField(); + panel1.add(myArgumentsField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.tox.configuration.arguments")); + panel1.add(jBLabel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, + this.$$$getMessageFromBundle$$$("messages/PyBundle", "form.tox.configuration.environments.to.run")); + panel1.add(jBLabel2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myRunOnlyTestsField = new JTextField(); + panel1.add(myRunOnlyTestsField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected void applyEditorTo(final @NotNull PyToxConfiguration s) { AbstractPythonRunConfiguration.copyParams(myForm, s); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java index 2eb7ce1e4540..e0ec69265e91 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java @@ -4,6 +4,9 @@ package com.intellij.util.xml.ui; import com.intellij.openapi.util.Disposer; import com.intellij.ui.JBColor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.Nls; import javax.swing.BorderFactory; @@ -11,15 +14,23 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Font; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.Locale; +import java.util.ResourceBundle; public class CaptionComponent extends JPanel implements Committable, Highlightable { - private JPanel myRootPanel; - private JLabel myCaptionLabel; - private JLabel myDescriptionLabel; - private JLabel myIconLabel; - private JPanel myErrorPanel; + private final JPanel myRootPanel; + private final JLabel myCaptionLabel; + private final JLabel myDescriptionLabel; + private final JLabel myIconLabel; + private final JPanel myErrorPanel; private CommittablePanel myCommittableErrorPanel; private boolean myBordered = true; @@ -34,6 +45,46 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab public CaptionComponent(@Nls String text, Icon icon) { super(new BorderLayout()); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRootPanel = new JPanel(); + myRootPanel.setLayout(new GridLayoutManager(2, 4, new Insets(5, 5, 5, 5), -1, -1)); + myRootPanel.setBackground(new Color(-789275)); + myRootPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myCaptionLabel = new JLabel(); + Font myCaptionLabelFont = this.$$$getFont$$$("Tahoma", Font.BOLD, 11, myCaptionLabel.getFont()); + if (myCaptionLabelFont != null) myCaptionLabel.setFont(myCaptionLabelFont); + this.$$$loadLabelText$$$(myCaptionLabel, this.$$$getMessageFromBundle$$$("messages/XmlDomBundle", "caption.component.label.unknown")); + myRootPanel.add(myCaptionLabel, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myDescriptionLabel = new JLabel(); + myDescriptionLabel.setText(""); + myRootPanel.add(myDescriptionLabel, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myIconLabel = new JLabel(); + myIconLabel.setText(""); + myIconLabel.setVisible(false); + myRootPanel.add(myIconLabel, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myErrorPanel = new JPanel(); + myErrorPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + myErrorPanel.setBackground(new Color(-789275)); + myRootPanel.add(myErrorPanel, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRootPanel.add(spacer1, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } updateBorder(); myRootPanel.setBackground(new JBColor(new Color(243, 244, 229), new Color(42, 55, 62))); add(myRootPanel, BorderLayout.CENTER); @@ -42,6 +93,77 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab setIcon(icon); } + /** @noinspection ALL */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } + else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } + else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac + ? new Font(font.getFamily(), font.getStyle(), font.getSize()) + : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRootPanel; } + private void updateBorder() { if (myBordered) { myRootPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, JBColor.LIGHT_GRAY)); @@ -110,11 +232,11 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab public void initErrorPanel(final CommittablePanel errorPanel) { myCommittableErrorPanel = errorPanel; Disposer.register(this, errorPanel); - + final JComponent component = errorPanel.getComponent(); component.setBackground(getBackground()); - + myErrorPanel.setLayout(new BorderLayout()); myErrorPanel.add(component, BorderLayout.CENTER); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/EmptyPane.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/EmptyPane.java index 2e55be7c2975..8d6cba8e35f2 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/EmptyPane.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/EmptyPane.java @@ -17,6 +17,9 @@ package com.intellij.util.xml.ui; import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.Nls; @@ -24,17 +27,36 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Insets; public class EmptyPane { - private JPanel myPanel; - private JLabel myLabel; + private final JPanel myPanel; + private final JLabel myLabel; public EmptyPane(@Nls String text) { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myLabel = new JLabel(); + myLabel.setText("#####"); + myPanel.add(myLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myLabel.setForeground(JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground()); myLabel.setText(text); myPanel.setBackground(new Tree().getBackground()); } + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + public JComponent getComponent() { return myPanel; } @@ -48,5 +70,4 @@ public class EmptyPane { panel.setLayout(new BorderLayout()); panel.add(emptyPane.getComponent(), BorderLayout.CENTER); } - } diff --git a/xml/impl/src/com/intellij/javaee/DefaultSchemasConfigurable.java b/xml/impl/src/com/intellij/javaee/DefaultSchemasConfigurable.java index 1e410ff0478e..567e3e2d81a6 100644 --- a/xml/impl/src/com/intellij/javaee/DefaultSchemasConfigurable.java +++ b/xml/impl/src/com/intellij/javaee/DefaultSchemasConfigurable.java @@ -4,8 +4,12 @@ package com.intellij.javaee; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TextFieldWithAutoCompletion; import com.intellij.ui.components.JBRadioButton; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.xml.Html5SchemaProvider; @@ -15,28 +19,168 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.TitledBorder; +import java.awt.BorderLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; public class DefaultSchemasConfigurable implements Configurable { private final Project myProject; - private JRadioButton myHtml4RadioButton; - private JRadioButton myHtml5RadioButton; - private JRadioButton myOtherRadioButton; - private JPanel myContentPanel; - private JPanel myOtherDoctypeWrapper; - private JBRadioButton myXMLSchema10JBRadioButton; - private JBRadioButton myXMLSchema11JBRadioButton; + private final JRadioButton myHtml4RadioButton; + private final JRadioButton myHtml5RadioButton; + private final JRadioButton myOtherRadioButton; + private final JPanel myContentPanel; + private final JPanel myOtherDoctypeWrapper; + private final JBRadioButton myXMLSchema10JBRadioButton; + private final JBRadioButton myXMLSchema11JBRadioButton; private TextFieldWithAutoCompletion myDoctypeTextField; public DefaultSchemasConfigurable(final Project project) { myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myContentPanel = new JPanel(); + myContentPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/XmlBundle", + "xml.schemas.border.title.default.html.language.level"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myHtml4RadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myHtml4RadioButton, this.$$$getMessageFromBundle$$$("messages/XmlBundle", + "xml.schemas.radio.button.html.4.http.www.w3.org.tr.html4.loose.dtd")); + panel1.add(myHtml4RadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myHtml5RadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myHtml5RadioButton, + this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.schemas.radio.button.html.5")); + panel1.add(myHtml5RadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myOtherRadioButton = new JRadioButton(); + this.$$$loadButtonText$$$(myOtherRadioButton, + this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.schemas.radio.button.other.doctype")); + panel2.add(myOtherRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOtherDoctypeWrapper = new JPanel(); + myOtherDoctypeWrapper.setLayout(new BorderLayout(0, 0)); + panel2.add(myOtherDoctypeWrapper, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myContentPanel.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$("messages/XmlBundle", + "xml.schemas.border.title.xml.schema.version"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myXMLSchema10JBRadioButton = new JBRadioButton(); + this.$$$loadButtonText$$$(myXMLSchema10JBRadioButton, + this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.schemas.radio.button.xml.schema.1.0")); + panel3.add(myXMLSchema10JBRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel3.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + myXMLSchema11JBRadioButton = new JBRadioButton(); + this.$$$loadButtonText$$$(myXMLSchema11JBRadioButton, + this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.schemas.radio.button.xml.schema.1.1")); + panel3.add(myXMLSchema11JBRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + myContentPanel.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myHtml4RadioButton); + buttonGroup.add(myHtml5RadioButton); + buttonGroup.add(myOtherRadioButton); + buttonGroup = new ButtonGroup(); + buttonGroup.add(myXMLSchema10JBRadioButton); + buttonGroup.add(myXMLSchema11JBRadioButton); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myContentPanel; } + private @NotNull String getDoctype() { if (myHtml4RadioButton.isSelected()) { return XmlUtil.XHTML4_SCHEMA_LOCATION; @@ -120,7 +264,8 @@ public class DefaultSchemasConfigurable implements Configurable { } }); } - if (ExternalResourceManagerEx.getInstanceEx().getXmlSchemaVersion(myProject) == ExternalResourceManagerEx.XMLSchemaVersion.XMLSchema_1_0) { + if (ExternalResourceManagerEx.getInstanceEx().getXmlSchemaVersion(myProject) == + ExternalResourceManagerEx.XMLSchemaVersion.XMLSchema_1_0) { myXMLSchema10JBRadioButton.setSelected(true); } else { diff --git a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java index 4191d371e336..7cc239654d39 100644 --- a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java +++ b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java @@ -19,6 +19,12 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.treeStructure.Tree; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.xml.XmlBundle; @@ -31,10 +37,13 @@ import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JTree; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -42,10 +51,13 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; +import java.util.ResourceBundle; import java.util.Set; /** @@ -53,18 +65,71 @@ import java.util.Set; */ public class MapExternalResourceDialog extends DialogWrapper { - private static final FileChooserDescriptor FILE_CHOOSER_DESCRIPTOR = new FileChooserDescriptor(true, false, false, false, true, false).withTitle( - XmlBundle.message("choose.schema.file")); + private static final FileChooserDescriptor FILE_CHOOSER_DESCRIPTOR = + new FileChooserDescriptor(true, false, false, false, true, false).withTitle( + XmlBundle.message("choose.schema.file")); - private JTextField myUri; - private JPanel myMainPanel; - private JTree mySchemasTree; - private JPanel mySchemasPanel; - private TextFieldWithBrowseButton myFileTextField; + private final JTextField myUri; + private final JPanel myMainPanel; + private final JTree mySchemasTree; + private final JPanel mySchemasPanel; + private final TextFieldWithBrowseButton myFileTextField; private boolean mySchemaFound; public MapExternalResourceDialog(String uri, @Nullable Project project, @Nullable PsiFile file, @Nullable String location) { super(project); + { + FileTextField field = FileChooserFactory.getInstance().createFileTextField(FILE_CHOOSER_DESCRIPTOR, getDisposable()); + myFileTextField = new TextFieldWithBrowseButton(field.getField()); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myMainPanel = new JPanel(); + myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + myMainPanel.putClientProperty("BorderFactoryClass", ""); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.map.resource.dialog.label.uri")); + myMainPanel.add(jBLabel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + myUri = new JTextField(); + myMainPanel.add(myUri, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + mySchemasPanel = new JPanel(); + mySchemasPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + mySchemasPanel.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"); + mySchemasPanel.putClientProperty("html.disable", Boolean.FALSE); + myMainPanel.add(mySchemasPanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + mySchemasPanel.setBorder(IdeBorderFactory.PlainSmallWithoutIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/XmlBundle", + "xml.map.resource.dialog.border.title.project.schemas"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JBScrollPane jBScrollPane1 = new JBScrollPane(); + mySchemasPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + mySchemasTree = new Tree(); + jBScrollPane1.setViewportView(mySchemasTree); + myMainPanel.add(myFileTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.map.resource.dialog.label.file")); + myMainPanel.add(jBLabel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + jBLabel1.setLabelFor(myUri); + jBLabel2.setLabelFor(myFileTextField); + } setTitle(XmlBundle.message("map.external.resource")); myUri.setText(uri); myUri.getDocument().addDocumentListener(new DocumentAdapter() { @@ -88,6 +153,53 @@ public class MapExternalResourceDialog extends DialogWrapper { init(); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myMainPanel; } + private void setupSchemasTree(String uri, @NotNull Project project, @Nullable PsiFile file, @@ -214,9 +326,4 @@ public class MapExternalResourceDialog extends DialogWrapper { protected @Nullable String getHelpId() { return "Map External Resource dialog"; } - - private void createUIComponents() { - FileTextField field = FileChooserFactory.getInstance().createFileTextField(FILE_CHOOSER_DESCRIPTOR, getDisposable()); - myFileTextField = new TextFieldWithBrowseButton(field.getField()); - } } diff --git a/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java b/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java index f121f7d28ff9..f39bca49c6af 100644 --- a/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java +++ b/xml/impl/src/com/intellij/javaee/XMLCatalogConfigurable.java @@ -6,22 +6,95 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.xml.XmlBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class XMLCatalogConfigurable implements Configurable { - private TextFieldWithBrowseButton myPropertyFile; - private JPanel myPanel; + private final TextFieldWithBrowseButton myPropertyFile; + private final JPanel myPanel; public XMLCatalogConfigurable() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XmlBundle", "xml.options.label.catalog.property.file")); + myPanel.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myPropertyFile = new TextFieldWithBrowseButton(); + myPanel.add(myPropertyFile, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final Spacer spacer1 = new Spacer(); + myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } myPropertyFile.addBrowseFolderListener(null, new FileChooserDescriptor(true, false, false, false, false, false) .withTitle(XmlBundle.message("xml.catalog.properties.file"))); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override public @Nls String getDisplayName() { return XmlBundle.message("configurable.XMLCatalogConfigurable.display.name"); diff --git a/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java b/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java index e301f113df11..aa7f4051bf56 100644 --- a/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java +++ b/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/AdvancedXmlPanel.java @@ -18,30 +18,184 @@ package org.intellij.plugins.intelliLang.inject.config.ui; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.LanguageTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.lang.regexp.RegExpLanguage; import org.intellij.plugins.intelliLang.inject.InjectedLanguage; import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection; import org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; +import java.util.ResourceBundle; public class AdvancedXmlPanel extends AbstractInjectionPanel { - private JPanel myRoot; + private final JPanel myRoot; - private EditorTextField myValuePattern; - private EditorTextField myXPathCondition; - private JLabel myXPathConditionLabel; - private JCheckBox mySingleFileCheckBox; + private final EditorTextField myValuePattern; + private final EditorTextField myXPathCondition; + private final JLabel myXPathConditionLabel; + private final JCheckBox mySingleFileCheckBox; public AdvancedXmlPanel(Project project, AbstractTagInjection injection) { super(injection, project); - $$$setupUI$$$(); // see IDEA-9987 + { + myValuePattern = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getValuePattern(), + new LanguageTextField.SimpleDocumentCreator() { + @Override + public void customizePsiFile(PsiFile psiFile) { + psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE); + } + }); + + // don't even bother to look up the language when xpath-evaluation isn't possible + final XPathSupportProxy proxy = XPathSupportProxy.getInstance(); + myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject, + myOrigInjection.getXPathCondition(), new LanguageTextField.SimpleDocumentCreator() { + @Override + public void customizePsiFile(PsiFile psiFile) { + // important to get proper validation & completion for Jaxen's built-in and PSI functions + // like lower-case(), file-type(), file-ext(), file-name(), etc. + if (proxy != null) { + proxy.attachContext(psiFile); + } + } + }); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "advanced.panel.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "label.value.pattern")); + label1.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "advanced.panel.tooltip.regular.expression.html")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myValuePattern, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + myXPathConditionLabel = new JLabel(); + this.$$$loadLabelText$$$(myXPathConditionLabel, + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "advanced.panel.xpath.condition")); + myXPathConditionLabel.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "advanced.panel.tooltip.xpath.expression.html")); + panel1.add(myXPathConditionLabel, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myXPathCondition, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mySingleFileCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(mySingleFileCheckBox, + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "checkbox.single.file")); + panel1.add(mySingleFileCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(myValuePattern); + myXPathConditionLabel.setLabelFor(myXPathCondition); + } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override protected void apply(AbstractTagInjection other) { other.setValuePattern(myValuePattern.getText()); @@ -60,30 +214,4 @@ public class AdvancedXmlPanel extends AbstractInjectionPanel { public static final Key> URI_MODEL = Key.create("URI_MODEL"); - private JPanel myRoot; + private final JPanel myRoot; - private EditorTextField myLocalName; - private ComboBox myNamespace; - private JCheckBox myWithSubtags; + private final EditorTextField myLocalName; + private final ComboBox myNamespace; + private final JCheckBox myWithSubtags; public TagPanel(Project project, AbstractTagInjection injection) { super(injection, project); - $$$setupUI$$$(); + { + myLocalName = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getTagName()); + myNamespace = new ComboBox(200); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "tag.panel.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "tag.panel.local.name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "tag.panel.namespace")); + panel1.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myLocalName, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + myNamespace.setEditable(true); + panel1.add(myNamespace, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWithSubtags = new JCheckBox(); + this.$$$loadButtonText$$$(myWithSubtags, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "tag.panel.sub.tags")); + panel1.add(myWithSubtags, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + label1.setLabelFor(myLocalName); + label2.setLabelFor(myNamespace); + } myNamespace.setModel(createNamespaceUriModel(myProject)); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + public static ComboBoxModel createNamespaceUriModel(Project project) { final List data = project.getUserData(URI_MODEL); if (data != null) { @@ -107,13 +237,5 @@ public class TagPanel extends AbstractInjectionPanel { final String s = (String)myNamespace.getEditor().getItem(); return s != null ? s : ""; } - - private void createUIComponents() { - myLocalName = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getTagName()); - myNamespace = new ComboBox(200); - } - - private void $$$setupUI$$$() { - } } diff --git a/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java b/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java index 3cfdda84eb71..1c56e9b4a009 100644 --- a/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java +++ b/xml/langInjection/src/org/intellij/plugins/intelliLang/inject/config/ui/XmlAttributePanel.java @@ -19,38 +19,177 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.EditorTextField; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.LanguageTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.lang.regexp.RegExpLanguage; import org.intellij.plugins.intelliLang.inject.config.XmlAttributeInjection; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Objects; +import java.util.ResourceBundle; public class XmlAttributePanel extends AbstractInjectionPanel { - private JPanel myRoot; + private final JPanel myRoot; // read by reflection - LanguagePanel myLanguagePanel; - TagPanel myTagPanel; - AdvancedXmlPanel myAdvancedPanel; + final LanguagePanel myLanguagePanel; + final TagPanel myTagPanel; + final AdvancedXmlPanel myAdvancedPanel; - private EditorTextField myLocalName; - private ComboBox myNamespace; - private JTextField myNameTextField; + private final EditorTextField myLocalName; + private final ComboBox myNamespace; + private final JTextField myNameTextField; private boolean myUseGeneratedName; public XmlAttributePanel(XmlAttributeInjection injection, Project project) { super(injection, project); - $$$setupUI$$$(); // see IDEA-9987 + { + myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); + myTagPanel = new TagPanel(myProject, myOrigInjection); + myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection); + + myLocalName = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getAttributeName()); + + myNamespace = new ComboBox(200); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(myTagPanel.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, this.$$$getMessageFromBundle$$$( + "messages/IntelliLangBundle", "xml.attribute.panel.title"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, + null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "xml.attribute.panel.label.local.name")); + label1.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "xml.attribute.panel.tooltip.regular.expression")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "xml.attribute.panel.label.namespace")); + panel1.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(myLocalName, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + myNamespace.setEditable(true); + panel1.add(myNamespace, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myRoot.add(myLanguagePanel.$$$getRootComponent$$$(), + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myRoot.add(myAdvancedPanel.$$$getRootComponent$$$(), + new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel2, + new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "xml.attribute.panel.label.name")); + panel2.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameTextField = new JTextField(); + panel2.add(myNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + label1.setLabelFor(myLocalName); + label2.setLabelFor(myNamespace); + label3.setLabelFor(myNameTextField); + } myNamespace.setModel(TagPanel.createNamespaceUriModel(project)); init(injection.copy()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override public JPanel getComponent() { return myRoot; @@ -80,17 +219,4 @@ public class XmlAttributePanel extends AbstractInjectionPanel { // read by reflection - LanguagePanel myLanguagePanel; - TagPanel myPanel; - AdvancedXmlPanel myAdvancedPanel; + final LanguagePanel myLanguagePanel; + final TagPanel myPanel; + final AdvancedXmlPanel myAdvancedPanel; - private JPanel myRoot; - private JTextField myNameTextField; + private final JPanel myRoot; + private final JTextField myNameTextField; private boolean myUseGeneratedName; public XmlTagPanel(XmlTagInjection injection, Project project) { super(injection, project); - $$$setupUI$$$(); // see IDEA-9987 + { + myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); + myPanel = new TagPanel(myProject, myOrigInjection); + myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(myPanel.$$$getRootComponent$$$(), + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myRoot.add(myLanguagePanel.$$$getRootComponent$$$(), + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myRoot.add(myAdvancedPanel.$$$getRootComponent$$$(), + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.add(panel1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/IntelliLangBundle", "xml.tag.panel.label.name")); + panel1.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myNameTextField = new JTextField(); + panel1.add(myNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + label1.setLabelFor(myNameTextField); + } init(injection.copy()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override protected void apply(XmlTagInjection other) { String name = myNameTextField.getText(); @@ -61,13 +161,4 @@ public class XmlTagPanel extends AbstractInjectionPanel { public JPanel getComponent() { return myRoot; } - - private void createUIComponents() { - myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); - myPanel = new TagPanel(myProject, myOrigInjection); - myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection); - } - - private void $$$setupUI$$$() { - } } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java index b283e1c7ec15..e5632e85e66f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java @@ -33,25 +33,37 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.PsiRecursiveElementVisitor; import com.intellij.psi.xml.XmlAttributeDecl; import com.intellij.psi.xml.XmlElementDecl; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.intellij.plugins.relaxNG.RelaxngBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.table.AbstractTableModel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; public class AdvancedDtdOptions implements AdvancedOptions { @@ -65,34 +77,179 @@ public class AdvancedDtdOptions implements AdvancedOptions { private static final @NonNls String GENERATE_START = "generate-start"; private static final @NonNls String XMLNS = "xmlns"; - private JComponent myRoot; + private final JComponent myRoot; - private JCheckBox myInlineAttlistCheckBox; - private JTextField myColonReplacement; - private JTextField myElementDefine; - private JTextField myAttlistDefine; - private JTextField myAnyName; - private JCheckBox myStrictAnyCheckBox; - private JTextField myAnnotationPrefix; - private JCheckBox myGenerateStartCheckBox; - private JTextField myDefaultNS; - private JTable myNamespaceMap; + private final JCheckBox myInlineAttlistCheckBox; + private final JTextField myColonReplacement; + private final JTextField myElementDefine; + private final JTextField myAttlistDefine; + private final JTextField myAnyName; + private final JCheckBox myStrictAnyCheckBox; + private final JTextField myAnnotationPrefix; + private final JCheckBox myGenerateStartCheckBox; + private final JTextField myDefaultNS; + private final JTable myNamespaceMap; - private JPanel myToolbar; + private final JPanel myToolbar; public AdvancedDtdOptions() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.border-title.dtd-input"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myInlineAttlistCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myInlineAttlistCheckBox, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.checkbox.inline-attlist")); + myInlineAttlistCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.inline-attlist")); + myRoot.add(myInlineAttlistCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.colon-replacement")); + label1.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.colon-replacement")); + myRoot.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myColonReplacement = new JTextField(); + myRoot.add(myColonReplacement, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.element-define")); + label2.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.element-define")); + myRoot.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myElementDefine = new JTextField(); + myRoot.add(myElementDefine, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.attlist-define")); + label3.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.attlist-define")); + myRoot.add(label3, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + myAttlistDefine = new JTextField(); + myRoot.add(myAttlistDefine, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.any-name")); + label4.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.any-name")); + myRoot.add(label4, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnyName = new JTextField(); + myRoot.add(myAnyName, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myStrictAnyCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myStrictAnyCheckBox, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.checkbox.strict-any")); + myStrictAnyCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.strict-any")); + myRoot.add(myStrictAnyCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.annotation-prefix")); + label5.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.annotation-prefix")); + myRoot.add(label5, + new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnnotationPrefix = new JTextField(); + myRoot.add(myAnnotationPrefix, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + myGenerateStartCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myGenerateStartCheckBox, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.checkbox.generate-start")); + myGenerateStartCheckBox.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.advanced-options.dtd.tooltip.generate-start")); + myRoot.add(myGenerateStartCheckBox, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.border-title.namespace-settings"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.dtd.label.default")); + panel1.add(label6, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myDefaultNS = new JTextField(); + panel1.add(myDefaultNS, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + panel1.add(scrollPane1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, + null, 0, false)); + myNamespaceMap = new JTable(); + myNamespaceMap.setPreferredScrollableViewportSize(new Dimension(250, 70)); + myNamespaceMap.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); + scrollPane1.setViewportView(myNamespaceMap); + myToolbar = new JPanel(); + myToolbar.setLayout(new BorderLayout(0, 0)); + panel1.add(myToolbar, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + label1.setLabelFor(myColonReplacement); + label2.setLabelFor(myElementDefine); + label3.setLabelFor(myAttlistDefine); + label4.setLabelFor(myAnyName); + label5.setLabelFor(myAnnotationPrefix); + label6.setLabelFor(myDefaultNS); + } myInlineAttlistCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { myAttlistDefine.setEnabled(false); - } else { + } + else { myAttlistDefine.setEnabled(true); } } }); myNamespaceMap.setModel(new NamespaceMapModel()); - myNamespaceMap.getColumnModel().getColumn(0).setMaxWidth((int)(new JLabel(CommonBundle.message("label.prefix")).getPreferredSize().width * 1.2)); + myNamespaceMap.getColumnModel().getColumn(0) + .setMaxWidth((int)(new JLabel(CommonBundle.message("label.prefix")).getPreferredSize().width * 1.2)); final DefaultActionGroup group = new DefaultActionGroup(); group.add(new AnAction(Presentation.NULL_STRING, RelaxngBundle.messagePointer( @@ -102,7 +259,8 @@ public class AdvancedDtdOptions implements AdvancedOptions { public void update(@NotNull AnActionEvent e) { if (myNamespaceMap.getModel().getRowCount() == 0 || myNamespaceMap.getSelectedRow() == -1) { e.getPresentation().setEnabled(false); - } else { + } + else { e.getPresentation().setEnabled(true); } } @@ -122,6 +280,78 @@ public class AdvancedDtdOptions implements AdvancedOptions { myToolbar.add(toolbar.getComponent()); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override public JComponent getRoot() { return myRoot; @@ -147,7 +377,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { map.put(GENERATE_START, myGenerateStartCheckBox.isSelected()); if (!myDefaultNS.getText().trim().isEmpty()) { - map.put(XMLNS, myDefaultNS.getText() ); + map.put(XMLNS, myDefaultNS.getText()); } final List data = ((NamespaceMapModel)myNamespaceMap.getModel()).getData(); @@ -218,7 +448,8 @@ public class AdvancedDtdOptions implements AdvancedOptions { map.put(XMLNS + ":" + parts[0], null); } } - } else if (element instanceof XmlAttributeDecl) { + } + else if (element instanceof XmlAttributeDecl) { final String s = ((XmlAttributeDecl)element).getName(); if (s != null) { final String[] parts = s.split(":"); @@ -268,7 +499,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { } public void addMapping(String prefix, String uri) { - myList.add(new String[]{ prefix, uri }); + myList.add(new String[]{prefix, uri}); fireTableRowsInserted(myList.size() - 1, myList.size() - 1); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java index b3b71c2d0440..fd6956b3b2d7 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java @@ -17,23 +17,173 @@ package org.intellij.plugins.relaxNG.convert; import com.intellij.openapi.ui.ComboBox; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NonNls; +import javax.swing.AbstractButton; +import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; +import java.util.ResourceBundle; public class AdvancedXsdOptions implements AdvancedOptions { private static final @NonNls String DISABLE_ABSTRACT_ELEMENTS = "disable-abstract-elements"; private static final @NonNls String ANY_PROCESS_CONTENTS = "any-process-contents"; private static final @NonNls String ANY_ATTRIBUTE_PROCESS_CONTENTS = "any-attribute-process-contents"; - private JComponent myRoot; + private final JComponent myRoot; - private JCheckBox myDisableAbstractElements; - private ComboBox myAnyProcessContents; - private ComboBox myAnyAttributeProcessContents; + private final JCheckBox myDisableAbstractElements; + private final ComboBox myAnyProcessContents; + private final ComboBox myAnyAttributeProcessContents; + + public AdvancedXsdOptions() { + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + myRoot.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.border-title.w3c-xml-schema-output"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.label.any-process-contents")); + label1.setToolTipText(this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.tooltip.any-process-contents")); + myRoot.add(label1, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.label.any-attribute-process-contents")); + label2.setToolTipText(this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.tooltip.any-attribute-process-contents")); + myRoot.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAnyProcessContents = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("strict"); + defaultComboBoxModel1.addElement("lax"); + defaultComboBoxModel1.addElement("skip"); + myAnyProcessContents.setModel(defaultComboBoxModel1); + myRoot.add(myAnyProcessContents, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 0, false)); + myAnyAttributeProcessContents = new ComboBox(); + final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); + defaultComboBoxModel2.addElement("strict"); + defaultComboBoxModel2.addElement("lax"); + defaultComboBoxModel2.addElement("skip"); + myAnyAttributeProcessContents.setModel(defaultComboBoxModel2); + myRoot.add(myAnyAttributeProcessContents, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, + false)); + myDisableAbstractElements = new JCheckBox(); + this.$$$loadButtonText$$$(myDisableAbstractElements, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.checkbox.disable-abstract-elements")); + myDisableAbstractElements.setToolTipText(this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.advanced-options.xsd.tooltip.disable-abstract-elements")); + myRoot.add(myDisableAbstractElements, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1.setLabelFor(myAnyProcessContents); + label2.setLabelFor(myAnyAttributeProcessContents); + } + } + + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } @Override public JComponent getRoot() { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java index e553384ca332..30db57f8699f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java @@ -31,27 +31,39 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingProjectManager; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.ui.DocumentAdapter; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import com.intellij.util.ArrayUtil; import org.intellij.plugins.relaxNG.RelaxngBundle; import org.intellij.plugins.relaxNG.compact.RncFileType; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; +import java.lang.reflect.Method; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { @@ -65,23 +77,142 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { private Map myInputOptions = Collections.emptyMap(); private Map myOutputOptions = Collections.emptyMap(); - private JPanel myRoot; + private final JPanel myRoot; - private JRadioButton myOutputRng; - private JRadioButton myOutputRnc; - private JRadioButton myOutputXsd; - private JRadioButton myOutputDtd; + private final JRadioButton myOutputRng; + private final JRadioButton myOutputRnc; + private final JRadioButton myOutputXsd; + private final JRadioButton myOutputDtd; - private ComboBox myEncoding; + private final ComboBox myEncoding; - private JTextField myIndent; - private JTextField myLineLength; + private final JTextField myIndent; + private final JTextField myLineLength; - private TextFieldWithBrowseButton myOutputDestination; + private final TextFieldWithBrowseButton myOutputDestination; public ConvertSchemaSettingsImpl(Project project, @NotNull SchemaType inputType, VirtualFile firstFile) { myProject = project; myInputType = inputType; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myRoot = new JPanel(); + myRoot.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + final Spacer spacer1 = new Spacer(); + myRoot.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel1.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.border-title.output-type"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOutputRnc = new JRadioButton(); + this.$$$loadButtonText$$$(myOutputRnc, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.radio-button.relax-ng-compact-syntax")); + panel1.add(myOutputRnc, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputXsd = new JRadioButton(); + this.$$$loadButtonText$$$(myOutputXsd, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.radio-button.w3c-xml-schema")); + panel1.add(myOutputXsd, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputDtd = new JRadioButton(); + this.$$$loadButtonText$$$(myOutputDtd, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.radio-button.dtd")); + panel1.add(myOutputDtd, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myOutputRng = new JRadioButton(); + this.$$$loadButtonText$$$(myOutputRng, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.radio-button.relax-ng-xml-syntax")); + panel1.add(myOutputRng, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.border-title.output-options"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.settings.label.encoding")); + panel2.add(label1, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, + GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + myEncoding = new ComboBox(); + panel2.add(myEncoding, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, + null, 0, false)); + myIndent = new JTextField(); + panel2.add(myIndent, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", "relaxng.convert-schema.settings.label.indent")); + panel2.add(label2, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.label.line-length")); + panel2.add(label3, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myLineLength = new JTextField(); + panel2.add(myLineLength, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + myRoot.add(panel3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel3.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(null, + this.$$$getMessageFromBundle$$$("messages/RelaxngBundle", + "relaxng.convert-schema.settings.border-title.output-destination"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + myOutputDestination = new TextFieldWithBrowseButton(); + panel3.add(myOutputDestination, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + label1.setLabelFor(myEncoding); + label2.setLabelFor(myIndent); + label3.setLabelFor(myLineLength); + ButtonGroup buttonGroup; + buttonGroup = new ButtonGroup(); + buttonGroup.add(myOutputRnc); + buttonGroup.add(myOutputRnc); + buttonGroup.add(myOutputXsd); + buttonGroup.add(myOutputDtd); + buttonGroup.add(myOutputRng); + } final FileType type; switch (inputType) { @@ -172,15 +303,90 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myRoot; } + @Override public @NotNull SchemaType getOutputType() { if (myOutputRng.isSelected()) { return SchemaType.RNG; - } else if (myOutputRnc.isSelected()) { + } + else if (myOutputRnc.isSelected()) { return SchemaType.RNC; - } else if (myOutputXsd.isSelected()) { + } + else if (myOutputXsd.isSelected()) { return SchemaType.XSD; - } else { + } + else { assert myOutputDtd.isSelected(); return SchemaType.DTD; } @@ -199,7 +405,8 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { private static int parseInt(String s) { try { return !s.isEmpty() ? Integer.parseInt(s) : -1; - } catch (NumberFormatException e) { + } + catch (NumberFormatException e) { return -1; } } @@ -229,9 +436,11 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { final Object value = map.get(s); if (value == Boolean.TRUE) { inputParams.add(s); - } else if (value == Boolean.FALSE) { + } + else if (value == Boolean.FALSE) { inputParams.add("no-" + s); - } else if (value != null) { + } + else if (value != null) { inputParams.add(s + "=" + value); } } diff --git a/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleHtmlPanel.java b/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleHtmlPanel.java index 94b1731f8094..1efd220f0350 100644 --- a/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleHtmlPanel.java +++ b/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleHtmlPanel.java @@ -13,60 +13,339 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.xml.HtmlCodeStyleSettings; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.fields.ExpandableTextField; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.Function; import com.intellij.util.ui.PresentableEnumUtil; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.ResourceBundle; public final class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { - private JTextField myKeepBlankLines; - private JComboBox myWrapAttributes; - private JCheckBox myAlignAttributes; - private JCheckBox myKeepWhiteSpaces; + private final JTextField myKeepBlankLines; + private final JComboBox myWrapAttributes; + private final JCheckBox myAlignAttributes; + private final JCheckBox myKeepWhiteSpaces; - private JPanel myPanel; - private JPanel myPreviewPanel; + private final JPanel myPanel; + private final JPanel myPreviewPanel; - private JCheckBox mySpacesAroundEquality; - private JCheckBox mySpacesAroundTagName; - private JCheckBox myAlignText; - private ExpandableTextField myInsertNewLineTagNames; - private ExpandableTextField myRemoveNewLineTagNames; - private ExpandableTextField myDoNotAlignChildrenTagNames; - private ExpandableTextField myKeepWhiteSpacesTagNames; - private ExpandableTextField myInlineElementsTagNames; - private JTextField myDoNotAlignChildrenMinSize; - private JCheckBox myShouldKeepBlankLines; - private JCheckBox mySpaceInEmptyTag; - private JCheckBox myWrapText; - private JCheckBox myShouldKeepLineBreaksInText; - private ExpandableTextField myDontBreakIfInlineContent; - private JBScrollPane myJBScrollPane; - private JPanel myRightMarginPanel; - private JComboBox myQuotesCombo; - private JBCheckBox myEnforceQuotesBox; - private ComboBox myBeforeFirstAttributeCombo; - private ComboBox myAfterLastAttributeCombo; - private JPanel mySettingsPanel; + private final JCheckBox mySpacesAroundEquality; + private final JCheckBox mySpacesAroundTagName; + private final JCheckBox myAlignText; + private final ExpandableTextField myInsertNewLineTagNames; + private final ExpandableTextField myRemoveNewLineTagNames; + private final ExpandableTextField myDoNotAlignChildrenTagNames; + private final ExpandableTextField myKeepWhiteSpacesTagNames; + private final ExpandableTextField myInlineElementsTagNames; + private final JTextField myDoNotAlignChildrenMinSize; + private final JCheckBox myShouldKeepBlankLines; + private final JCheckBox mySpaceInEmptyTag; + private final JCheckBox myWrapText; + private final JCheckBox myShouldKeepLineBreaksInText; + private final ExpandableTextField myDontBreakIfInlineContent; + private final JBScrollPane myJBScrollPane; + private final JPanel myRightMarginPanel; + private final JComboBox myQuotesCombo; + private final JBCheckBox myEnforceQuotesBox; + private final ComboBox myBeforeFirstAttributeCombo; + private final ComboBox myAfterLastAttributeCombo; + private final JPanel mySettingsPanel; private RightMarginForm myRightMarginForm; private final List myPanelCustomizers; public CodeStyleHtmlPanel(CodeStyleSettings settings) { super(settings); + { + myRightMarginForm = new RightMarginForm(HtmlFileType.INSTANCE.getLanguage(), getSettings()); + myRightMarginPanel = myRightMarginForm.getTopPanel(); + myJBScrollPane = new JBScrollPane() { + @Override + public Dimension getPreferredSize() { + Dimension prefSize = super.getPreferredSize(); + return new Dimension(prefSize.width + 15, prefSize.height); + } + }; + + Function> parser = (list) -> Arrays.asList(list.split(",")); + Function, String> joiner = (list) -> StringUtil.join(list, ","); + myInsertNewLineTagNames = new ExpandableTextField(parser, joiner); + myRemoveNewLineTagNames = new ExpandableTextField(parser, joiner); + myDoNotAlignChildrenTagNames = new ExpandableTextField(parser, joiner); + myInlineElementsTagNames = new ExpandableTextField(parser, joiner); + myKeepWhiteSpacesTagNames = new ExpandableTextField(parser, joiner); + myDontBreakIfInlineContent = new ExpandableTextField(parser, joiner); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), 4, -1)); + myPreviewPanel = new JPanel(); + myPanel.add(myPreviewPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myJBScrollPane.setHorizontalScrollBarPolicy(31); + panel1.add(myJBScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myJBScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1)); + myJBScrollPane.setViewportView(panel2); + mySettingsPanel = new JPanel(); + mySettingsPanel.setLayout(new GridLayoutManager(11, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(mySettingsPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.or.if.tag.size.more.than")); + mySettingsPanel.add(label1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 1, false)); + myDoNotAlignChildrenMinSize = new JTextField(); + mySettingsPanel.add(myDoNotAlignChildrenMinSize, + new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.lines")); + mySettingsPanel.add(label2, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.insert.new.line.before")); + mySettingsPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label4 = new JLabel(); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.remove.new.line.before")); + mySettingsPanel.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label5 = new JLabel(); + this.$$$loadLabelText$$$(label5, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.do.not.indent.children.of")); + mySettingsPanel.add(label5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myInsertNewLineTagNames.setText(""); + mySettingsPanel.add(myInsertNewLineTagNames, + new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + myRemoveNewLineTagNames.setText(""); + mySettingsPanel.add(myRemoveNewLineTagNames, + new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + myDoNotAlignChildrenTagNames.setText(""); + mySettingsPanel.add(myDoNotAlignChildrenTagNames, + new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + myInlineElementsTagNames.setText(""); + mySettingsPanel.add(myInlineElementsTagNames, + new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + this.$$$loadLabelText$$$(label6, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "inline.elements")); + mySettingsPanel.add(label6, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label7 = new JLabel(); + this.$$$loadLabelText$$$(label7, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "label.keep.white.spaces.inside")); + mySettingsPanel.add(label7, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + final JLabel label8 = new JLabel(); + this.$$$loadLabelText$$$(label8, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "don.t.break.if.inline.content")); + mySettingsPanel.add(label8, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myKeepWhiteSpacesTagNames.setText(""); + mySettingsPanel.add(myKeepWhiteSpacesTagNames, + new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + myDontBreakIfInlineContent.setText(""); + mySettingsPanel.add(myDontBreakIfInlineContent, + new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, 1, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); + final JLabel label9 = new JLabel(); + this.$$$loadLabelText$$$(label9, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "generated.quote.marks")); + mySettingsPanel.add(label9, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, + 0, false)); + myQuotesCombo = new JComboBox(); + mySettingsPanel.add(myQuotesCombo, new GridConstraints(9, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + myEnforceQuotesBox = new JBCheckBox(); + this.$$$loadButtonText$$$(myEnforceQuotesBox, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "generated.quote.enforce.format")); + mySettingsPanel.add(myEnforceQuotesBox, new GridConstraints(10, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + final JBLabel jBLabel1 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel1, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "html.label.new.line.before.first.attribute")); + mySettingsPanel.add(jBLabel1, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myBeforeFirstAttributeCombo = new ComboBox(); + mySettingsPanel.add(myBeforeFirstAttributeCombo, + new GridConstraints(7, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JBLabel jBLabel2 = new JBLabel(); + this.$$$loadLabelText$$$(jBLabel2, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "html.label.new.line.after.last.attribute")); + mySettingsPanel.add(jBLabel2, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myAfterLastAttributeCombo = new ComboBox(); + mySettingsPanel.add(myAfterLastAttributeCombo, + new GridConstraints(8, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + myAlignAttributes = new JCheckBox(); + myAlignAttributes.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myAlignAttributes, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.align.attributes")); + panel4.add(myAlignAttributes, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myAlignText = new JCheckBox(); + myAlignText.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myAlignText, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.align.text")); + panel4.add(myAlignText, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepWhiteSpaces = new JCheckBox(); + myKeepWhiteSpaces.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myKeepWhiteSpaces, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.white.spaces")); + panel4.add(myKeepWhiteSpaces, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWrapText = new JCheckBox(); + this.$$$loadButtonText$$$(myWrapText, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.wrap.text")); + panel4.add(myWrapText, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel5.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel3.add(panel5, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, + null, 0, false)); + panel5.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/ApplicationBundle", "title.spaces"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySpacesAroundEquality = new JCheckBox(); + this.$$$loadButtonText$$$(mySpacesAroundEquality, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.around.equals.in.attribute")); + panel5.add(mySpacesAroundEquality, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySpacesAroundTagName = new JCheckBox(); + this.$$$loadButtonText$$$(mySpacesAroundTagName, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.around.tag.name")); + panel5.add(mySpacesAroundTagName, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySpaceInEmptyTag = new JCheckBox(); + this.$$$loadButtonText$$$(mySpaceInEmptyTag, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.in.empty.tag")); + panel5.add(mySpaceInEmptyTag, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myShouldKeepBlankLines = new JCheckBox(); + myShouldKeepBlankLines.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myShouldKeepBlankLines, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.line.breaks")); + panel6.add(myShouldKeepBlankLines, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label10 = new JLabel(); + this.$$$loadLabelText$$$(label10, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "label.wrap.attributes")); + panel6.add(label10, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + this.$$$loadLabelText$$$(label11, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "editbox.keep.blank.lines")); + panel6.add(label11, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepBlankLines = new JTextField(); + myKeepBlankLines.setColumns(3); + panel6.add(myKeepBlankLines, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1), null, 0, false)); + myWrapAttributes = new JComboBox(); + myWrapAttributes.setEnabled(true); + panel6.add(myWrapAttributes, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + myShouldKeepLineBreaksInText = new JCheckBox(); + myShouldKeepLineBreaksInText.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myShouldKeepLineBreaksInText, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.line.breaks.in.text")); + panel6.add(myShouldKeepLineBreaksInText, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, + null, null, null, 0, false)); + panel2.add(myRightMarginPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + jBLabel1.setLabelFor(myBeforeFirstAttributeCombo); + jBLabel2.setLabelFor(myAfterLastAttributeCombo); + } installPreviewPanel(myPreviewPanel); fillWrappingCombo(myWrapAttributes); @@ -97,32 +376,83 @@ public final class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { } } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected EditorHighlighter createHighlighter(final @NotNull EditorColorsScheme scheme) { return XmlHighlighterFactory.createXMLHighlighter(scheme); } - private void createUIComponents() { - myRightMarginForm = new RightMarginForm(HtmlFileType.INSTANCE.getLanguage(), getSettings()); - myRightMarginPanel = myRightMarginForm.getTopPanel(); - myJBScrollPane = new JBScrollPane() { - @Override - public Dimension getPreferredSize() { - Dimension prefSize = super.getPreferredSize(); - return new Dimension(prefSize.width + 15, prefSize.height); - } - }; - - Function> parser = (list) -> Arrays.asList(list.split(",")); - Function, String> joiner = (list) -> StringUtil.join(list, ","); - myInsertNewLineTagNames = new ExpandableTextField(parser, joiner); - myRemoveNewLineTagNames = new ExpandableTextField(parser, joiner); - myDoNotAlignChildrenTagNames = new ExpandableTextField(parser, joiner); - myInlineElementsTagNames = new ExpandableTextField(parser, joiner); - myKeepWhiteSpacesTagNames = new ExpandableTextField(parser, joiner); - myDontBreakIfInlineContent = new ExpandableTextField(parser, joiner); - } - @Override protected int getRightMargin() { return 60; @@ -186,7 +516,8 @@ public final class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { myInsertNewLineTagNames.setText(settings.HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE); myRemoveNewLineTagNames.setText(settings.HTML_ELEMENTS_TO_REMOVE_NEW_LINE_BEFORE); myDoNotAlignChildrenTagNames.setText(settings.HTML_DO_NOT_INDENT_CHILDREN_OF); - myDoNotAlignChildrenMinSize.setText(settings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES == 0 ? "" : String.valueOf(settings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES)); + myDoNotAlignChildrenMinSize.setText( + settings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES == 0 ? "" : String.valueOf(settings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES)); myInlineElementsTagNames.setText(settings.HTML_INLINE_ELEMENTS); myDontBreakIfInlineContent.setText(settings.HTML_DONT_ADD_BREAKS_IF_INLINE_CONTENT); myKeepWhiteSpacesTagNames.setText(settings.HTML_KEEP_WHITESPACES_INSIDE); @@ -205,7 +536,8 @@ public final class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { if (settings.HTML_KEEP_BLANK_LINES != getIntValue(myKeepBlankLines)) { return true; } - if (settings.HTML_ATTRIBUTE_WRAP != CodeStyleSettings.WrapStyle.getId((CodeStyleSettings.WrapStyle)myWrapAttributes.getSelectedItem())) { + if (settings.HTML_ATTRIBUTE_WRAP != + CodeStyleSettings.WrapStyle.getId((CodeStyleSettings.WrapStyle)myWrapAttributes.getSelectedItem())) { return true; } @@ -291,12 +623,10 @@ public final class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { @Override protected String getPreviewText() { return readFromFile(this.getClass(), "preview.html.template"); - } @Override protected @NotNull FileType getFileType() { return HtmlFileType.INSTANCE; } - } diff --git a/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleXmlPanel.java b/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleXmlPanel.java index 4d3a63955f5d..ea8a30996578 100644 --- a/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleXmlPanel.java +++ b/xml/xml-ui-common/src/com/intellij/application/options/CodeStyleXmlPanel.java @@ -12,42 +12,226 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.xml.XmlCodeStyleSettings; import com.intellij.ui.CollectionComboBoxModel; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBScrollPane; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.xml.XmlUiBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import java.awt.Dimension; +import java.awt.Insets; +import java.lang.reflect.Method; import java.util.Arrays; +import java.util.ResourceBundle; -public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ - private JTextField myKeepBlankLines; - private JComboBox myWrapAttributes; - private JCheckBox myAlignAttributes; - private JCheckBox myKeepWhiteSpaces; +public class CodeStyleXmlPanel extends CodeStyleAbstractPanel { + private final JTextField myKeepBlankLines; + private final JComboBox myWrapAttributes; + private final JCheckBox myAlignAttributes; + private final JCheckBox myKeepWhiteSpaces; - private JPanel myPanel; - private JPanel myPreviewPanel; + private final JPanel myPanel; + private final JPanel myPreviewPanel; - private JCheckBox mySpacesAroundEquality; - private JCheckBox mySpacesAfterTagName; - private JCheckBox myKeepLineBreaks; - private JCheckBox myInEmptyTag; - private JCheckBox myWrapText; - private JCheckBox myKeepLineBreaksInText; - private JComboBox myWhiteSpaceAroundCDATA; - private JCheckBox myKeepWhitespaceInsideCDATACheckBox; - private JBScrollPane myJBScrollPane; - private JPanel myRightMarginPanel; + private final JCheckBox mySpacesAroundEquality; + private final JCheckBox mySpacesAfterTagName; + private final JCheckBox myKeepLineBreaks; + private final JCheckBox myInEmptyTag; + private final JCheckBox myWrapText; + private final JCheckBox myKeepLineBreaksInText; + private final JComboBox myWhiteSpaceAroundCDATA; + private final JCheckBox myKeepWhitespaceInsideCDATACheckBox; + private final JBScrollPane myJBScrollPane; + private final JPanel myRightMarginPanel; private RightMarginForm myRightMarginForm; public CodeStyleXmlPanel(CodeStyleSettings settings) { super(settings); + { + myJBScrollPane = new JBScrollPane() { + @Override + public Dimension getPreferredSize() { + Dimension prefSize = super.getPreferredSize(); + return new Dimension(prefSize.width + 15, prefSize.height); + } + }; + myRightMarginForm = new RightMarginForm(XmlFileType.INSTANCE.getLanguage(), getSettings()); + myRightMarginPanel = myRightMarginForm.getTopPanel(); + } + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + myPanel = new JPanel(); + myPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), 4, -1)); + myJBScrollPane.setHorizontalScrollBarPolicy(31); + myPanel.add(myJBScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myJBScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1)); + myJBScrollPane.setViewportView(panel1); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + myAlignAttributes = new JCheckBox(); + myAlignAttributes.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myAlignAttributes, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.align.attributes")); + panel3.add(myAlignAttributes, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepWhiteSpaces = new JCheckBox(); + myKeepWhiteSpaces.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myKeepWhiteSpaces, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.white.spaces")); + panel3.add(myKeepWhiteSpaces, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWrapText = new JCheckBox(); + myWrapText.setMargin(new Insets(2, 0, 2, 3)); + this.$$$loadButtonText$$$(myWrapText, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.wrap.text")); + panel3.add(myWrapText, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel4.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel4.putClientProperty("html.disable", Boolean.TRUE); + panel2.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel4.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$( + "messages/ApplicationBundle", "title.spaces"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + mySpacesAroundEquality = new JCheckBox(); + mySpacesAroundEquality.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(mySpacesAroundEquality, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.around.equals.in.attribute")); + panel4.add(mySpacesAroundEquality, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mySpacesAfterTagName = new JCheckBox(); + mySpacesAfterTagName.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(mySpacesAfterTagName, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.around.tag.name")); + panel4.add(mySpacesAfterTagName, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myInEmptyTag = new JCheckBox(); + myInEmptyTag.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myInEmptyTag, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.spaces.in.empty.tag")); + panel4.add(myInEmptyTag, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + final JLabel label1 = new JLabel(); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ApplicationBundle", "label.wrap.attributes")); + panel5.add(label1, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWrapAttributes = new JComboBox(); + myWrapAttributes.setEnabled(true); + panel5.add(myWrapAttributes, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + final JLabel label2 = new JLabel(); + this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "editbox.keep.blank.lines")); + panel5.add(label2, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepLineBreaksInText = new JCheckBox(); + myKeepLineBreaksInText.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myKeepLineBreaksInText, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.line.breaks.in.text")); + panel5.add(myKeepLineBreaksInText, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepBlankLines = new JTextField(); + myKeepBlankLines.setColumns(3); + panel5.add(myKeepBlankLines, + new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1), null, 0, false)); + myKeepLineBreaks = new JCheckBox(); + myKeepLineBreaks.setMargin(new Insets(0, 0, 0, 0)); + this.$$$loadButtonText$$$(myKeepLineBreaks, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "checkbox.keep.line.breaks")); + panel5.add(myKeepLineBreaks, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel6.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); + panel1.add(panel6, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, + 0, false)); + panel6.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", + "xml.code.style.border.title.cdata"), + TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, null, null)); + final JLabel label3 = new JLabel(); + this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "xml.code.style.label.whitespace.around")); + panel6.add(label3, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myKeepWhitespaceInsideCDATACheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(myKeepWhitespaceInsideCDATACheckBox, + this.$$$getMessageFromBundle$$$("messages/XmlUiBundle", "xml.code.style.checkbox.keep.whitespace.inside")); + panel6.add(myKeepWhitespaceInsideCDATACheckBox, + new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + myWhiteSpaceAroundCDATA = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("Preserve"); + defaultComboBoxModel1.addElement("Remove (keep with tags)"); + defaultComboBoxModel1.addElement("Add new lines"); + myWhiteSpaceAroundCDATA.setModel(defaultComboBoxModel1); + panel6.add(myWhiteSpaceAroundCDATA, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + panel1.add(myRightMarginPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + myPreviewPanel = new JPanel(); + myPanel.add(myPreviewPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, + null, null, 0, false)); + label3.setLabelFor(myWhiteSpaceAroundCDATA); + } installPreviewPanel(myPreviewPanel); fillWrappingCombo(myWrapAttributes); addPanelToWatch(myPanel); @@ -57,6 +241,78 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ XmlUiBundle.message("add.new.lines")))); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return myPanel; } + @Override protected EditorHighlighter createHighlighter(final @NotNull EditorColorsScheme scheme) { return XmlHighlighterFactory.createXMLHighlighter(scheme); @@ -132,11 +388,11 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ return true; } - if (xmlSettings.XML_SPACE_AROUND_EQUALITY_IN_ATTRIBUTE != mySpacesAroundEquality.isSelected()){ + if (xmlSettings.XML_SPACE_AROUND_EQUALITY_IN_ATTRIBUTE != mySpacesAroundEquality.isSelected()) { return true; } - if (xmlSettings.XML_SPACE_AFTER_TAG_NAME != mySpacesAfterTagName.isSelected()){ + if (xmlSettings.XML_SPACE_AFTER_TAG_NAME != mySpacesAfterTagName.isSelected()) { return true; } @@ -148,7 +404,7 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ return true; } - if (xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG != myInEmptyTag.isSelected()){ + if (xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG != myInEmptyTag.isSelected()) { return true; } if (xmlSettings.XML_WHITE_SPACE_AROUND_CDATA != myWhiteSpaceAroundCDATA.getSelectedIndex()) { @@ -180,16 +436,4 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ protected @NotNull FileType getFileType() { return XmlFileType.INSTANCE; } - - private void createUIComponents() { - myJBScrollPane = new JBScrollPane() { - @Override - public Dimension getPreferredSize() { - Dimension prefSize = super.getPreferredSize(); - return new Dimension(prefSize.width + 15, prefSize.height); - } - }; - myRightMarginForm = new RightMarginForm(XmlFileType.INSTANCE.getLanguage(), getSettings()); - myRightMarginPanel = myRightMarginForm.getTopPanel(); - } } diff --git a/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java index a6b89c65c0be..bfb66ceffd9c 100644 --- a/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java @@ -14,6 +14,8 @@ import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.ui.JBColor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.ApiStatus; @@ -21,6 +23,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -30,26 +33,30 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.lang.reflect.Method; import java.util.Collections; import java.util.List; +import java.util.ResourceBundle; @ApiStatus.Internal public final class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { - private JPanel panel; - private TextFieldWithBrowseButton generateFromUrl; - private JLabel status; - private JLabel statusText; - private JLabel generateFromUrlText; - private JComboBox rootElementChooser; - private JLabel rootElementChooserText; - private JCheckBox enableRestrictionCheck; - private JCheckBox enableUniqueCheck; - private JTextField outputFileName; - private JLabel outputFileNameText; + private final JPanel panel; + private final TextFieldWithBrowseButton generateFromUrl; + private final JLabel status; + private final JLabel statusText; + private final JLabel generateFromUrlText; + private final JComboBox rootElementChooser; + private final JLabel rootElementChooserText; + private final JCheckBox enableRestrictionCheck; + private final JCheckBox enableUniqueCheck; + private final JTextField outputFileName; + private final JLabel outputFileNameText; private String previousUri; private Runnable myOkAction; private final Project myProject; @@ -58,6 +65,85 @@ public final class GenerateInstanceDocumentFromSchemaDialog extends DialogWrappe public GenerateInstanceDocumentFromSchemaDialog(Project project, VirtualFile file) { super(project, true); myProject = project; + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(6, 2, new Insets(1, 1, 1, 1), -1, -1)); + generateFromUrlText = new JLabel(); + this.$$$loadLabelText$$$(generateFromUrlText, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "schema2instance.dialog.schema.path")); + generateFromUrlText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.schema2instance.url.tooltip")); + panel.add(generateFromUrlText, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + statusText = new JLabel(); + this.$$$loadLabelText$$$(statusText, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "any.dialog.status")); + statusText.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "webservice.status.tooltip")); + panel.add(statusText, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + status = new JLabel(); + status.setText(""); + status.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "webservice.status.tooltip")); + panel.add(status, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + generateFromUrl = new TextFieldWithBrowseButton(); + generateFromUrl.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance2schema.url.tooltip")); + panel.add(generateFromUrl, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + rootElementChooserText = new JLabel(); + this.$$$loadLabelText$$$(rootElementChooserText, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "schema2instance.dialog.element.name")); + rootElementChooserText.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.rootelement.tooltip")); + panel.add(rootElementChooserText, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + rootElementChooser = new JComboBox(); + rootElementChooser.setEditable(true); + rootElementChooser.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.rootelement.tooltip")); + panel.add(rootElementChooser, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, + null, 0, false)); + enableRestrictionCheck = new JCheckBox(); + enableRestrictionCheck.setMargin(new Insets(0, 0, 0, 0)); + enableRestrictionCheck.setSelected(true); + this.$$$loadButtonText$$$(enableRestrictionCheck, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", + "schema2instance.dialog.enable.restriction.check")); + enableRestrictionCheck.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.particle.valid.tooltip")); + panel.add(enableRestrictionCheck, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + enableUniqueCheck = new JCheckBox(); + enableUniqueCheck.setHorizontalAlignment(2); + enableUniqueCheck.setHorizontalTextPosition(4); + enableUniqueCheck.setMargin(new Insets(0, 0, 0, 0)); + enableUniqueCheck.setSelected(true); + this.$$$loadButtonText$$$(enableUniqueCheck, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "schema2instance.dialog.enable.unique.check")); + enableUniqueCheck.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.unique.particle.tooltip")); + panel.add(enableUniqueCheck, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + outputFileNameText = new JLabel(); + this.$$$loadLabelText$$$(outputFileNameText, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "schema2instance.dialog.instance.document.name")); + outputFileNameText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance.document.name.tooltip")); + panel.add(outputFileNameText, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + outputFileName = new JTextField(); + outputFileName.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance.document.name.tooltip")); + panel.add(outputFileName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + outputFileNameText.setLabelFor(outputFileName); + } UIUtils.configureBrowseButton(project, generateFromUrl, "xsd", XmlBeansBundle.message("select.xsd.schema.dialog.title"), false); @@ -74,6 +160,78 @@ public final class GenerateInstanceDocumentFromSchemaDialog extends DialogWrappe outputFileName.setText(file.getName() + ".xml"); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + private void $$$loadButtonText$$$(AbstractButton component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + public void doInitFor(JLabel textComponent, JComponent component) { textComponent.setLabelFor(component); @@ -234,7 +392,6 @@ public final class GenerateInstanceDocumentFromSchemaDialog extends DialogWrappe return XmlBeansBundle.message("schema2.instance.output.file.name.is.empty.validation.problem"); } return null; - } private static boolean isAcceptableFile(VirtualFile virtualFile) { diff --git a/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java index 59c7ce824fdc..55d150f015e6 100644 --- a/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java @@ -9,6 +9,8 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.JBColor; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtilRt; import org.jetbrains.annotations.NotNull; @@ -20,31 +22,36 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.File; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; +import java.util.ResourceBundle; /** * @author Konstantin Bulenkov */ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { - private JPanel panel; - private TextFieldWithBrowseButton generateFromUrl; - private JLabel status; - private JLabel statusText; - private JLabel generateFromUrlText; - private JLabel designTypeText; - private JTextField detectEnumerationsLimit; - private ComboBox detectSimpleContentTypes; - private ComboBox designType; - private JLabel detectEnumerationsLimitText; - private JLabel detectSimpleContentTypesText; - private JLabel resultSchemaFileNameText; - private JTextField resultSchemaFileName; + private final JPanel panel; + private final TextFieldWithBrowseButton generateFromUrl; + private final JLabel status; + private final JLabel statusText; + private final JLabel generateFromUrlText; + private final JLabel designTypeText; + private final JTextField detectEnumerationsLimit; + private final ComboBox detectSimpleContentTypes; + private final ComboBox designType; + private final JLabel detectEnumerationsLimitText; + private final JLabel detectSimpleContentTypesText; + private final JLabel resultSchemaFileNameText; + private final JTextField resultSchemaFileName; private static final List designTypes = Arrays.asList( getLocalElementsGlobalComplexTypes(), @@ -59,11 +66,98 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { GenerateSchemaFromInstanceDocumentDialog(Project project, VirtualFile file) { super(project, true); + { + // GUI initializer generated by IntelliJ IDEA GUI Designer + // >>> IMPORTANT!! <<< + // DO NOT EDIT OR ADD ANY CODE HERE! + panel = new JPanel(); + panel.setLayout(new GridLayoutManager(6, 2, new Insets(1, 1, 1, 1), -1, -1)); + generateFromUrlText = new JLabel(); + this.$$$loadLabelText$$$(generateFromUrlText, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "instance2schema.dialog.instance.document.path")); + generateFromUrlText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance2schema.url.tooltip")); + panel.add(generateFromUrlText, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + statusText = new JLabel(); + this.$$$loadLabelText$$$(statusText, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "any.dialog.status")); + statusText.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "webservice.status.tooltip")); + panel.add(statusText, + new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + status = new JLabel(); + status.setForeground(new Color(-65536)); + status.setText(""); + status.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "webservice.status.tooltip")); + panel.add(status, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + generateFromUrl = new TextFieldWithBrowseButton(); + generateFromUrl.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance2schema.url.tooltip")); + panel.add(generateFromUrl, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + designTypeText = new JLabel(); + this.$$$loadLabelText$$$(designTypeText, + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "instance2schema.dialog.design.type")); + designTypeText.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.designtype.tooltip")); + panel.add(designTypeText, + new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + detectSimpleContentTypesText = new JLabel(); + this.$$$loadLabelText$$$(detectSimpleContentTypesText, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", + "instance2schema.dialog.detect.simple.content.type")); + detectSimpleContentTypesText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.simplecontenttype.tooltip")); + panel.add(detectSimpleContentTypesText, + new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + detectEnumerationsLimitText = new JLabel(); + this.$$$loadLabelText$$$(detectEnumerationsLimitText, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", + "instance2schema.dialog.detect.enumerations.limit")); + detectEnumerationsLimitText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.enumerations.tooltip")); + panel.add(detectEnumerationsLimitText, + new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + detectEnumerationsLimit = new JTextField(); + detectEnumerationsLimit.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.enumerations.tooltip")); + panel.add(detectEnumerationsLimit, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + detectSimpleContentTypes = new ComboBox(); + detectSimpleContentTypes.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.simplecontenttype.tooltip")); + panel.add(detectSimpleContentTypes, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + null, null, 0, false)); + designType = new ComboBox(); + designType.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.designtype.tooltip")); + panel.add(designType, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, + false)); + resultSchemaFileNameText = new JLabel(); + this.$$$loadLabelText$$$(resultSchemaFileNameText, this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", + "xml.generate.schema.dialog.label.result.schema.file.name")); + resultSchemaFileNameText.setToolTipText( + this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.instance2schema.result.schema.name")); + panel.add(resultSchemaFileNameText, + new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + resultSchemaFileName = new JTextField(); + resultSchemaFileName.setToolTipText(this.$$$getMessageFromBundle$$$("messages/XmlBeansBundle", "xmlbeans.enumerations.tooltip")); + panel.add(resultSchemaFileName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, + new Dimension(150, -1), null, 0, false)); + detectEnumerationsLimitText.setLabelFor(detectEnumerationsLimit); + resultSchemaFileNameText.setLabelFor(resultSchemaFileName); + } setTitle(XmlBeansBundle.message("generate.schema.from.instance.document.dialog.title")); doInitFor(designTypeText, designType); - configureComboBox(designType,designTypes); + configureComboBox(designType, designTypes); doInitFor(detectSimpleContentTypesText, detectSimpleContentTypes); configureComboBox(detectSimpleContentTypes, simpleContentTypes); @@ -84,6 +178,53 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { resultSchemaFileName.setText(file.getNameWithoutExtension() + ".xsd"); } + private static Method $$$cachedGetBundleMethod$$$ = null; + + /** @noinspection ALL */ + private String $$$getMessageFromBundle$$$(String path, String key) { + ResourceBundle bundle; + try { + Class thisClass = this.getClass(); + if ($$$cachedGetBundleMethod$$$ == null) { + Class dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle"); + $$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class); + } + bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass); + } + catch (Exception e) { + bundle = ResourceBundle.getBundle(path); + } + return bundle.getString(key); + } + + /** @noinspection ALL */ + private void $$$loadLabelText$$$(JLabel component, String text) { + StringBuffer result = new StringBuffer(); + boolean haveMnemonic = false; + char mnemonic = '\0'; + int mnemonicIndex = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '&') { + i++; + if (i == text.length()) break; + if (!haveMnemonic && text.charAt(i) != '&') { + haveMnemonic = true; + mnemonic = text.charAt(i); + mnemonicIndex = result.length(); + } + } + result.append(text.charAt(i)); + } + component.setText(result.toString()); + if (haveMnemonic) { + component.setDisplayedMnemonic(mnemonic); + component.setDisplayedMnemonicIndex(mnemonicIndex); + } + } + + /** @noinspection ALL */ + public JComponent $$$getRootComponent$$$() { return panel; } + private void validateData() { String msg = doValidateWithData(); setOKActionEnabled(msg == null); @@ -135,7 +276,8 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { validateData(); } }); - } else if (component instanceof JComboBox jComboBox) { + } + else if (component instanceof JComboBox jComboBox) { jComboBox.addActionListener(new ActionListener() { @Override @@ -177,11 +319,11 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { } String getDesignType() { - return (String) designType.getSelectedItem(); + return (String)designType.getSelectedItem(); } String getSimpleContentType() { - return (String) detectSimpleContentTypes.getSelectedItem(); + return (String)detectSimpleContentTypes.getSelectedItem(); } String getEnumerationsLimit() { @@ -193,7 +335,7 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { } private @InspectionMessage String doValidateWithData() { - if (! new File(generateFromUrl.getText()).exists()) { + if (!new File(generateFromUrl.getText()).exists()) { return XmlBeansBundle.message("instance.document.file.is.not.exist"); } @@ -204,7 +346,8 @@ final class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { try { int i = Integer.parseInt(getEnumerationsLimit()); if (i < 0) return XmlBeansBundle.message("negative.number.validation.problem"); - } catch(NumberFormatException ex) { + } + catch (NumberFormatException ex) { return XmlBeansBundle.message("invalid.number.validation.problem"); }