Skip to content

Commit 175e578

Browse files
authored
Merge pull request #317 from Haehnchen/feature/settings
remove magic GUI form builder code and use inline code
2 parents 58dce41 + 0f8b312 commit 175e578

File tree

3 files changed

+97
-11
lines changed

3 files changed

+97
-11
lines changed

src/main/java/de/espend/idea/php/annotation/ui/SettingsForm.java

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package de.espend.idea.php.annotation.ui;
22

33
import com.intellij.openapi.options.Configurable;
4+
import com.intellij.uiDesigner.core.GridConstraints;
5+
import com.intellij.uiDesigner.core.GridLayoutManager;
6+
import com.intellij.uiDesigner.core.Spacer;
47
import de.espend.idea.php.annotation.ApplicationSettings;
58
import de.espend.idea.php.annotation.util.PluginUtil;
69
import org.jetbrains.annotations.Nls;
710
import org.jetbrains.annotations.Nullable;
811

912
import javax.swing.*;
13+
import java.awt.*;
1014
import java.awt.event.MouseAdapter;
1115
import java.awt.event.MouseEvent;
1216

@@ -50,7 +54,7 @@ public JComponent createComponent() {
5054
public boolean isModified() {
5155
return
5256
!appendRoundBracket.isSelected() == ApplicationSettings.getInstance().appendRoundBracket
53-
;
57+
;
5458
}
5559

5660
@Override
@@ -71,4 +75,49 @@ private void updateUIFromSettings() {
7175
public void disposeUIResources() {
7276

7377
}
78+
79+
{
80+
// GUI initializer generated by IntelliJ IDEA GUI Designer
81+
// >>> IMPORTANT!! <<<
82+
// DO NOT EDIT OR ADD ANY CODE HERE!
83+
$$$setupUI$$$();
84+
}
85+
86+
/**
87+
* Method generated by IntelliJ IDEA GUI Designer
88+
* >>> IMPORTANT!! <<<
89+
* DO NOT edit this method OR call it in your code!
90+
*
91+
* @noinspection ALL
92+
*/
93+
private void $$$setupUI$$$() {
94+
panel = new JPanel();
95+
panel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
96+
final JLabel label1 = new JLabel();
97+
label1.setText("Autocomplete (Annotations)");
98+
panel.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));
99+
final Spacer spacer1 = new Spacer();
100+
panel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
101+
appendRoundBracket = new JCheckBox();
102+
appendRoundBracket.setText("Insert round bracket after class name");
103+
panel.add(appendRoundBracket, 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));
104+
final JPanel panel1 = new JPanel();
105+
panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
106+
panel.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));
107+
final JLabel label2 = new JLabel();
108+
label2.setText("Actions");
109+
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));
110+
buttonCleanIndex = new JButton();
111+
buttonCleanIndex.setText("Schedule annotation reindex");
112+
panel1.add(buttonCleanIndex, 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));
113+
final Spacer spacer2 = new Spacer();
114+
panel1.add(spacer2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
115+
}
116+
117+
/**
118+
* @noinspection ALL
119+
*/
120+
public JComponent $$$getRootComponent$$$() {
121+
return panel;
122+
}
74123
}

src/main/java/de/espend/idea/php/annotation/ui/UseAliasListForm.java

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.intellij.openapi.options.Configurable;
44
import com.intellij.ui.ToolbarDecorator;
55
import com.intellij.ui.table.TableView;
6+
import com.intellij.uiDesigner.core.GridConstraints;
7+
import com.intellij.uiDesigner.core.GridLayoutManager;
8+
import com.intellij.uiDesigner.core.Spacer;
69
import com.intellij.util.ui.ColumnInfo;
710
import com.intellij.util.ui.ElementProducer;
811
import com.intellij.util.ui.ListTableModel;
@@ -12,6 +15,7 @@
1215
import org.jetbrains.annotations.Nullable;
1316

1417
import javax.swing.*;
18+
import java.awt.*;
1519
import java.util.ArrayList;
1620

1721
/**
@@ -51,7 +55,7 @@ public UseAliasListForm() {
5155
}
5256

5357
private void resetList() {
54-
while(this.modelList.getRowCount() > 0) {
58+
while (this.modelList.getRowCount() > 0) {
5559
this.modelList.removeRow(0);
5660
}
5761

@@ -92,7 +96,7 @@ public boolean canCreateElement() {
9296
tablePanel.setEditAction(anActionButton -> {
9397

9498
UseAliasOption useAliasOption = tableView.getSelectedObject();
95-
if(useAliasOption == null) {
99+
if (useAliasOption == null) {
96100
return;
97101
}
98102

@@ -135,7 +139,7 @@ public void apply() {
135139

136140
@Override
137141
public void reset() {
138-
while(this.modelList.getRowCount() > 0) {
142+
while (this.modelList.getRowCount() > 0) {
139143
this.modelList.removeRow(0);
140144
}
141145

@@ -147,6 +151,43 @@ public void disposeUIResources() {
147151

148152
}
149153

154+
{
155+
// GUI initializer generated by IntelliJ IDEA GUI Designer
156+
// >>> IMPORTANT!! <<<
157+
// DO NOT EDIT OR ADD ANY CODE HERE!
158+
$$$setupUI$$$();
159+
}
160+
161+
/**
162+
* Method generated by IntelliJ IDEA GUI Designer
163+
* >>> IMPORTANT!! <<<
164+
* DO NOT edit this method OR call it in your code!
165+
*
166+
* @noinspection ALL
167+
*/
168+
private void $$$setupUI$$$() {
169+
panel = new JPanel();
170+
panel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
171+
final JLabel label1 = new JLabel();
172+
label1.setText("Auto insert use alias for given class scope eg \"Doctrine\\ORM\\Mapping as ORM\"");
173+
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));
174+
panel1 = new JPanel();
175+
panel1.setLayout(new BorderLayout(0, 0));
176+
panel.add(panel1, 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));
177+
buttonReset = new JButton();
178+
buttonReset.setText("Default reset");
179+
panel.add(buttonReset, 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));
180+
final Spacer spacer1 = new Spacer();
181+
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));
182+
}
183+
184+
/**
185+
* @noinspection ALL
186+
*/
187+
public JComponent $$$getRootComponent$$$() {
188+
return panel;
189+
}
190+
150191
private static class ClassColumn extends ColumnInfo<UseAliasOption, String> {
151192

152193
ClassColumn() {
@@ -183,7 +224,7 @@ public Boolean valueOf(UseAliasOption twigPath) {
183224
return twigPath.isEnabled();
184225
}
185226

186-
public void setValue(UseAliasOption twigPath, Boolean value){
227+
public void setValue(UseAliasOption twigPath, Boolean value) {
187228
twigPath.setEnabled(value);
188229
tableView.getListTableModel().fireTableDataChanged();
189230
changed = true;
@@ -193,13 +234,11 @@ public int getWidth(JTable table) {
193234
return 50;
194235
}
195236

196-
public boolean isCellEditable(UseAliasOption groupItem)
197-
{
237+
public boolean isCellEditable(UseAliasOption groupItem) {
198238
return true;
199239
}
200240

201-
public Class getColumnClass()
202-
{
241+
public Class getColumnClass() {
203242
return Boolean.class;
204243
}
205244
}

src/main/resources/META-INF/plugin.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147

148148
<applicationService serviceImplementation="de.espend.idea.php.annotation.ApplicationSettings"/>
149149

150-
<!--
151150
<projectConfigurable instance="de.espend.idea.php.annotation.ui.SettingsForm"
152151
displayName="Annotations / Attributes"
153152
id="PhpAnnotations.SettingsForm"
@@ -161,7 +160,6 @@
161160
groupId="PhpAnnotations.SettingsForm"
162161
nonDefaultProject="true"
163162
/>
164-
-->
165163

166164
<iconProvider implementation="de.espend.idea.php.annotation.AnnotationIconProvider"/>
167165

0 commit comments

Comments
 (0)