Skip to content

Commit b5eb6d8

Browse files
shalupovintellij-monorepo-bot
authored andcommitted
MRI-2340 Automatically convert all UI Designer forms to sources
GitOrigin-RevId: 55249a442675e053b5093502648453b84391ec54
1 parent 1a1cdc4 commit b5eb6d8

315 files changed

Lines changed: 47277 additions & 7820 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

grid/impl/src/csv/ui/CsvFormatForm.java

Lines changed: 118 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,33 @@
55
import com.intellij.database.csv.CsvRecordFormat;
66
import com.intellij.openapi.Disposable;
77
import com.intellij.openapi.util.Disposer;
8+
import com.intellij.ui.TitledSeparator;
89
import com.intellij.ui.components.JBCheckBox;
10+
import com.intellij.uiDesigner.core.GridConstraints;
11+
import com.intellij.uiDesigner.core.GridLayoutManager;
12+
import com.intellij.uiDesigner.core.Spacer;
913
import com.intellij.util.EventDispatcher;
1014
import org.jetbrains.annotations.NotNull;
1115
import org.jetbrains.annotations.Nullable;
1216

17+
import javax.swing.AbstractButton;
1318
import javax.swing.JComponent;
1419
import javax.swing.JPanel;
20+
import java.awt.Insets;
1521
import java.awt.event.ItemEvent;
1622
import java.awt.event.ItemListener;
23+
import java.lang.reflect.Method;
1724
import java.util.EventListener;
25+
import java.util.ResourceBundle;
1826

1927
public class CsvFormatForm implements Disposable, CsvFormatEditor {
20-
private JPanel myPanel;
21-
private JBCheckBox myHeaderFormatCheckBox;
28+
private final JPanel myPanel;
29+
private final JBCheckBox myHeaderFormatCheckBox;
2230

23-
@SuppressWarnings("unused") private JPanel myRecordFormatPanel;
24-
@SuppressWarnings("unused") private JPanel myHeaderFormatPanel;
25-
private JBCheckBox myRowNumbersCheckBox;
26-
private JPanel myHeaderFormatWithTitlePanel;
31+
@SuppressWarnings("unused") private final JPanel myRecordFormatPanel;
32+
@SuppressWarnings("unused") private final JPanel myHeaderFormatPanel;
33+
private final JBCheckBox myRowNumbersCheckBox;
34+
private final JPanel myHeaderFormatWithTitlePanel;
2735

2836
private String myFormatName;
2937
private CsvRecordFormatForm myRecordFormatForm;
@@ -34,6 +42,65 @@ public class CsvFormatForm implements Disposable, CsvFormatEditor {
3442
private CsvFormat myFormat;
3543

3644
public CsvFormatForm(@NotNull Disposable parent, @NotNull CsvFormatUISettings settings) {
45+
{
46+
myRecordFormatForm = new CsvRecordFormatForm(this);
47+
myHeaderFormatForm = new CsvRecordFormatForm(this);
48+
myRecordFormatPanel = myRecordFormatForm.getMainPanel();
49+
myHeaderFormatPanel = myHeaderFormatForm.getMainPanel();
50+
}
51+
{
52+
// GUI initializer generated by IntelliJ IDEA GUI Designer
53+
// >>> IMPORTANT!! <<<
54+
// DO NOT EDIT OR ADD ANY CODE HERE!
55+
myPanel = new JPanel();
56+
myPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
57+
final Spacer spacer1 = new Spacer();
58+
myPanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1,
59+
GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
60+
final JPanel panel1 = new JPanel();
61+
panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
62+
myPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
63+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
64+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null,
65+
0, false));
66+
panel1.add(myRecordFormatPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
67+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
68+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null,
69+
null, null, 0, false));
70+
myRowNumbersCheckBox = new JBCheckBox();
71+
this.$$$loadButtonText$$$(myRowNumbersCheckBox,
72+
this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.first.column.is.header"));
73+
panel1.add(myRowNumbersCheckBox,
74+
new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
75+
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
76+
myHeaderFormatCheckBox = new JBCheckBox();
77+
this.$$$loadButtonText$$$(myHeaderFormatCheckBox,
78+
this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.first.row.is.header"));
79+
panel1.add(myHeaderFormatCheckBox,
80+
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
81+
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
82+
myHeaderFormatWithTitlePanel = new JPanel();
83+
myHeaderFormatWithTitlePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
84+
panel1.add(myHeaderFormatWithTitlePanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
85+
GridConstraints.SIZEPOLICY_CAN_SHRINK |
86+
GridConstraints.SIZEPOLICY_CAN_GROW,
87+
GridConstraints.SIZEPOLICY_CAN_SHRINK |
88+
GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
89+
final TitledSeparator titledSeparator1 = new TitledSeparator();
90+
titledSeparator1.setText(this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.header.format.label"));
91+
myHeaderFormatWithTitlePanel.add(titledSeparator1,
92+
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
93+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
94+
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
95+
myHeaderFormatWithTitlePanel.add(myHeaderFormatPanel,
96+
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
97+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
98+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
99+
null, null, null, 0, false));
100+
final Spacer spacer2 = new Spacer();
101+
myPanel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
102+
GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
103+
}
37104
Disposer.register(parent, this);
38105

39106
myHeaderFormatCheckBox.addItemListener(new ItemListener() {
@@ -68,13 +135,53 @@ public void recordFormatChanged(@NotNull CsvRecordFormatForm source) {
68135
myHeaderFormatWithTitlePanel.setVisible(false);
69136
}
70137

71-
private void createUIComponents() {
72-
myRecordFormatForm = new CsvRecordFormatForm(this);
73-
myHeaderFormatForm = new CsvRecordFormatForm(this);
74-
myRecordFormatPanel = myRecordFormatForm.getMainPanel();
75-
myHeaderFormatPanel = myHeaderFormatForm.getMainPanel();
138+
private static Method $$$cachedGetBundleMethod$$$ = null;
139+
140+
/** @noinspection ALL */
141+
private String $$$getMessageFromBundle$$$(String path, String key) {
142+
ResourceBundle bundle;
143+
try {
144+
Class<?> thisClass = this.getClass();
145+
if ($$$cachedGetBundleMethod$$$ == null) {
146+
Class<?> dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle");
147+
$$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class);
148+
}
149+
bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass);
150+
}
151+
catch (Exception e) {
152+
bundle = ResourceBundle.getBundle(path);
153+
}
154+
return bundle.getString(key);
155+
}
156+
157+
/** @noinspection ALL */
158+
private void $$$loadButtonText$$$(AbstractButton component, String text) {
159+
StringBuffer result = new StringBuffer();
160+
boolean haveMnemonic = false;
161+
char mnemonic = '\0';
162+
int mnemonicIndex = -1;
163+
for (int i = 0; i < text.length(); i++) {
164+
if (text.charAt(i) == '&') {
165+
i++;
166+
if (i == text.length()) break;
167+
if (!haveMnemonic && text.charAt(i) != '&') {
168+
haveMnemonic = true;
169+
mnemonic = text.charAt(i);
170+
mnemonicIndex = result.length();
171+
}
172+
}
173+
result.append(text.charAt(i));
174+
}
175+
component.setText(result.toString());
176+
if (haveMnemonic) {
177+
component.setMnemonic(mnemonic);
178+
component.setDisplayedMnemonicIndex(mnemonicIndex);
179+
}
76180
}
77181

182+
/** @noinspection ALL */
183+
public JComponent $$$getRootComponent$$$() { return myPanel; }
184+
78185
public void reset(@NotNull CsvFormat format) {
79186
myFormat = format;
80187
myResetting = true;

grid/impl/src/csv/ui/CsvFormatsUI.java

Lines changed: 98 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,81 @@
1111
import com.intellij.ui.components.JBLabel;
1212
import com.intellij.ui.components.JBScrollPane;
1313
import com.intellij.ui.scale.JBUIScale;
14+
import com.intellij.uiDesigner.core.GridConstraints;
15+
import com.intellij.uiDesigner.core.GridLayoutManager;
1416
import com.intellij.util.ui.JBUI;
1517
import com.intellij.util.ui.UIUtil;
1618
import org.jetbrains.annotations.NotNull;
1719
import org.jetbrains.annotations.Nullable;
1820

21+
import javax.swing.BorderFactory;
1922
import javax.swing.JComponent;
23+
import javax.swing.JLabel;
2024
import javax.swing.JPanel;
2125
import javax.swing.border.EmptyBorder;
26+
import javax.swing.border.TitledBorder;
2227
import java.awt.BorderLayout;
28+
import java.awt.Dimension;
29+
import java.awt.Insets;
30+
import java.lang.reflect.Method;
2331
import java.util.ArrayList;
2432
import java.util.List;
33+
import java.util.ResourceBundle;
2534

2635
public abstract class CsvFormatsUI implements Disposable {
2736

2837
private CsvFormatsListComponent myFormatsList;
2938

30-
private JPanel myPanel;
31-
private JPanel myFormatListPanel;
39+
private final JPanel myPanel;
40+
private final JPanel myFormatListPanel;
3241

33-
private JBLabel myFormatsLabel;
34-
private CsvFormatForm myFormatForm;
42+
private final JBLabel myFormatsLabel;
43+
private final CsvFormatForm myFormatForm;
3544

36-
private JBScrollPane myFormatFormScrollPane;
45+
private final JBScrollPane myFormatFormScrollPane;
3746

3847
private CsvFormatPreview myPreview;
3948
private final CsvFormatUISettings mySettings;
4049

4150
public CsvFormatsUI(boolean allowNameEditing, @NotNull CsvFormatUISettings settings) {
4251
mySettings = settings;
52+
{
53+
myFormatForm = new CsvFormatForm(this, mySettings);
54+
myFormatsList = new CsvFormatsListComponent(this);
55+
myFormatFormScrollPane = (JBScrollPane)ScrollPaneFactory.createScrollPane();
56+
myFormatFormScrollPane.setBorder(JBUI.Borders.empty());
57+
}
58+
{
59+
// GUI initializer generated by IntelliJ IDEA GUI Designer
60+
// >>> IMPORTANT!! <<<
61+
// DO NOT EDIT OR ADD ANY CODE HERE!
62+
myPanel = new JPanel();
63+
myPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
64+
myFormatFormScrollPane.setHorizontalScrollBarPolicy(31);
65+
myPanel.add(myFormatFormScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
66+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
67+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
68+
null, null, null, 0, false));
69+
final JPanel panel1 = new JPanel();
70+
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
71+
myFormatFormScrollPane.setViewportView(panel1);
72+
panel1.setBorder(
73+
BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20), null, TitledBorder.DEFAULT_JUSTIFICATION,
74+
TitledBorder.DEFAULT_POSITION, null, null));
75+
panel1.add(myFormatForm.$$$getRootComponent$$$(),
76+
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL,
77+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
78+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0,
79+
false));
80+
myFormatListPanel = new JPanel();
81+
myFormatListPanel.setLayout(new BorderLayout(0, 0));
82+
myPanel.add(myFormatListPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
83+
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
84+
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(1, -1), null, 0, false));
85+
myFormatsLabel = new JBLabel();
86+
this.$$$loadLabelText$$$(myFormatsLabel, this.$$$getMessageFromBundle$$$("messages/DataGridBundle", "csv.format.settings.formats"));
87+
myFormatListPanel.add(myFormatsLabel, BorderLayout.NORTH);
88+
}
4389
new FormatsListToFormatEditorBond().setListeners();
4490

4591
//noinspection AbstractMethodCallInConstructor
@@ -67,15 +113,55 @@ public void formatsChanged(@NotNull CsvFormatsListComponent formatsListComponent
67113
myFormatFormScrollPane.setPreferredSize(myFormatFormScrollPane.getViewport().getView().getPreferredSize());
68114
}
69115

70-
public @NotNull CsvFormatForm getFormatForm() {
71-
return myFormatForm;
116+
private static Method $$$cachedGetBundleMethod$$$ = null;
117+
118+
/** @noinspection ALL */
119+
private String $$$getMessageFromBundle$$$(String path, String key) {
120+
ResourceBundle bundle;
121+
try {
122+
Class<?> thisClass = this.getClass();
123+
if ($$$cachedGetBundleMethod$$$ == null) {
124+
Class<?> dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle");
125+
$$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class);
126+
}
127+
bundle = (ResourceBundle)$$$cachedGetBundleMethod$$$.invoke(null, path, thisClass);
128+
}
129+
catch (Exception e) {
130+
bundle = ResourceBundle.getBundle(path);
131+
}
132+
return bundle.getString(key);
72133
}
73134

74-
private void createUIComponents() {
75-
myFormatForm = new CsvFormatForm(this, mySettings);
76-
myFormatsList = new CsvFormatsListComponent(this);
77-
myFormatFormScrollPane = (JBScrollPane)ScrollPaneFactory.createScrollPane();
78-
myFormatFormScrollPane.setBorder(JBUI.Borders.empty());
135+
/** @noinspection ALL */
136+
private void $$$loadLabelText$$$(JLabel component, String text) {
137+
StringBuffer result = new StringBuffer();
138+
boolean haveMnemonic = false;
139+
char mnemonic = '\0';
140+
int mnemonicIndex = -1;
141+
for (int i = 0; i < text.length(); i++) {
142+
if (text.charAt(i) == '&') {
143+
i++;
144+
if (i == text.length()) break;
145+
if (!haveMnemonic && text.charAt(i) != '&') {
146+
haveMnemonic = true;
147+
mnemonic = text.charAt(i);
148+
mnemonicIndex = result.length();
149+
}
150+
}
151+
result.append(text.charAt(i));
152+
}
153+
component.setText(result.toString());
154+
if (haveMnemonic) {
155+
component.setDisplayedMnemonic(mnemonic);
156+
component.setDisplayedMnemonicIndex(mnemonicIndex);
157+
}
158+
}
159+
160+
/** @noinspection ALL */
161+
public JComponent $$$getRootComponent$$$() { return myPanel; }
162+
163+
public @NotNull CsvFormatForm getFormatForm() {
164+
return myFormatForm;
79165
}
80166

81167
public void reset(@NotNull List<CsvFormat> formats, @Nullable String nameToSelect) {

0 commit comments

Comments
 (0)