Skip to content

Commit

Permalink
Merge pull request #317 from Haehnchen/feature/settings
Browse files Browse the repository at this point in the history
remove magic GUI form builder code and use inline code
  • Loading branch information
Haehnchen authored Oct 16, 2024
2 parents 58dce41 + 0f8b312 commit 175e578
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 11 deletions.
51 changes: 50 additions & 1 deletion src/main/java/de/espend/idea/php/annotation/ui/SettingsForm.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package de.espend.idea.php.annotation.ui;

import com.intellij.openapi.options.Configurable;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import de.espend.idea.php.annotation.ApplicationSettings;
import de.espend.idea.php.annotation.util.PluginUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

Expand Down Expand Up @@ -50,7 +54,7 @@ public JComponent createComponent() {
public boolean isModified() {
return
!appendRoundBracket.isSelected() == ApplicationSettings.getInstance().appendRoundBracket
;
;
}

@Override
Expand All @@ -71,4 +75,49 @@ private void updateUIFromSettings() {
public void disposeUIResources() {

}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
panel = new JPanel();
panel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
final JLabel label1 = new JLabel();
label1.setText("Autocomplete (Annotations)");
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));
final Spacer spacer1 = new Spacer();
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));
appendRoundBracket = new JCheckBox();
appendRoundBracket.setText("Insert round bracket after class name");
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));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
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));
final JLabel label2 = new JLabel();
label2.setText("Actions");
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));
buttonCleanIndex = new JButton();
buttonCleanIndex.setText("Schedule annotation reindex");
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));
final Spacer spacer2 = new Spacer();
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));
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return panel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.intellij.openapi.options.Configurable;
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.ui.ColumnInfo;
import com.intellij.util.ui.ElementProducer;
import com.intellij.util.ui.ListTableModel;
Expand All @@ -12,6 +15,7 @@
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
Expand Down Expand Up @@ -51,7 +55,7 @@ public UseAliasListForm() {
}

private void resetList() {
while(this.modelList.getRowCount() > 0) {
while (this.modelList.getRowCount() > 0) {
this.modelList.removeRow(0);
}

Expand Down Expand Up @@ -92,7 +96,7 @@ public boolean canCreateElement() {
tablePanel.setEditAction(anActionButton -> {

UseAliasOption useAliasOption = tableView.getSelectedObject();
if(useAliasOption == null) {
if (useAliasOption == null) {
return;
}

Expand Down Expand Up @@ -135,7 +139,7 @@ public void apply() {

@Override
public void reset() {
while(this.modelList.getRowCount() > 0) {
while (this.modelList.getRowCount() > 0) {
this.modelList.removeRow(0);
}

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

}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
panel = new JPanel();
panel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
final JLabel label1 = new JLabel();
label1.setText("Auto insert use alias for given class scope eg \"Doctrine\\ORM\\Mapping as ORM\"");
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));
panel1 = new JPanel();
panel1.setLayout(new BorderLayout(0, 0));
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));
buttonReset = new JButton();
buttonReset.setText("Default reset");
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));
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));
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return panel;
}

private static class ClassColumn extends ColumnInfo<UseAliasOption, String> {

ClassColumn() {
Expand Down Expand Up @@ -183,7 +224,7 @@ public Boolean valueOf(UseAliasOption twigPath) {
return twigPath.isEnabled();
}

public void setValue(UseAliasOption twigPath, Boolean value){
public void setValue(UseAliasOption twigPath, Boolean value) {
twigPath.setEnabled(value);
tableView.getListTableModel().fireTableDataChanged();
changed = true;
Expand All @@ -193,13 +234,11 @@ public int getWidth(JTable table) {
return 50;
}

public boolean isCellEditable(UseAliasOption groupItem)
{
public boolean isCellEditable(UseAliasOption groupItem) {
return true;
}

public Class getColumnClass()
{
public Class getColumnClass() {
return Boolean.class;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@

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

<!--
<projectConfigurable instance="de.espend.idea.php.annotation.ui.SettingsForm"
displayName="Annotations / Attributes"
id="PhpAnnotations.SettingsForm"
Expand All @@ -161,7 +160,6 @@
groupId="PhpAnnotations.SettingsForm"
nonDefaultProject="true"
/>
-->

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

Expand Down

0 comments on commit 175e578

Please sign in to comment.