-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathHoconProjectSettingsPanel.java
More file actions
136 lines (117 loc) · 7.36 KB
/
HoconProjectSettingsPanel.java
File metadata and controls
136 lines (117 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package org.jetbrains.plugins.hocon.settings;
import com.intellij.openapi.project.Project;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import javax.swing.*;
import java.awt.*;
public class HoconProjectSettingsPanel {
private final Project project;
private JPanel mainPanel;
private JPanel wrapperPanel;
private JCheckBox classReferencesUnquotedCheckBox;
private JCheckBox classReferencesQuotedCheckBox;
private JCheckBox propertyReferencesCheckBox;
private JCheckBox searchInGotoSymbol;
private JTextField fileNavigationExtensionsField;
private JTextField fileNavigationSearchRootsField;
public HoconProjectSettingsPanel(Project project) {
this.project = project;
buildWrapperPanel();
loadSettings();
}
private void buildWrapperPanel() {
fileNavigationExtensionsField = new JTextField();
fileNavigationSearchRootsField = new JTextField();
JPanel fileNavPanel = new JPanel(new GridBagLayout());
fileNavPanel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "File Path Navigation"));
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(2, 4, 2, 4);
gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; gbc.fill = GridBagConstraints.NONE;
fileNavPanel.add(new JLabel("File extensions to navigate (comma-separated, e.g. sql,xml):"), gbc);
gbc.gridx = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL;
fileNavPanel.add(fileNavigationExtensionsField, gbc);
gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; gbc.fill = GridBagConstraints.NONE;
fileNavPanel.add(new JLabel("Search root directories (comma-separated, default: resource directory from project model):"), gbc);
gbc.gridx = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL;
fileNavPanel.add(fileNavigationSearchRootsField, gbc);
wrapperPanel = new JPanel(new BorderLayout());
wrapperPanel.add(mainPanel, BorderLayout.NORTH);
wrapperPanel.add(fileNavPanel, BorderLayout.CENTER);
}
public void loadSettings() {
HoconProjectSettings settings = HoconProjectSettings.getInstance(project);
classReferencesUnquotedCheckBox.setSelected(settings.getClassReferencesOnUnquotedStrings());
classReferencesQuotedCheckBox.setSelected(settings.getClassReferencesOnQuotedStrings());
propertyReferencesCheckBox.setSelected(settings.getPropertyReferencesOnStrings());
searchInGotoSymbol.setSelected(settings.getSearchInGotoSymbol());
fileNavigationExtensionsField.setText(settings.getFileNavigationExtensions());
fileNavigationSearchRootsField.setText(settings.getFileNavigationSearchRoots());
}
public JComponent getMainComponent() {
return wrapperPanel;
}
public boolean isModified() {
HoconProjectSettings settings = HoconProjectSettings.getInstance(project);
return classReferencesUnquotedCheckBox.isSelected() != settings.getClassReferencesOnUnquotedStrings() ||
classReferencesQuotedCheckBox.isSelected() != settings.getClassReferencesOnQuotedStrings() ||
propertyReferencesCheckBox.isSelected() != settings.getPropertyReferencesOnStrings() ||
searchInGotoSymbol.isSelected() != settings.getSearchInGotoSymbol() ||
!fileNavigationExtensionsField.getText().equals(settings.getFileNavigationExtensions()) ||
!fileNavigationSearchRootsField.getText().equals(settings.getFileNavigationSearchRoots());
}
public void apply() {
HoconProjectSettings settings = HoconProjectSettings.getInstance(project);
settings.setClassReferencesOnUnquotedStrings(classReferencesUnquotedCheckBox.isSelected());
settings.setClassReferencesOnQuotedStrings(classReferencesQuotedCheckBox.isSelected());
settings.setPropertyReferencesOnStrings(propertyReferencesCheckBox.isSelected());
settings.setSearchInGotoSymbol(searchInGotoSymbol.isSelected());
settings.setFileNavigationExtensions(fileNavigationExtensionsField.getText());
settings.setFileNavigationSearchRoots(fileNavigationSearchRootsField.getText());
}
{
// 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$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1));
classReferencesUnquotedCheckBox = new JCheckBox();
classReferencesUnquotedCheckBox.setText("Detect class references in unquoted strings in HOCON files");
classReferencesUnquotedCheckBox.setMnemonic('U');
classReferencesUnquotedCheckBox.setDisplayedMnemonicIndex(27);
mainPanel.add(classReferencesUnquotedCheckBox, 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));
classReferencesQuotedCheckBox = new JCheckBox();
classReferencesQuotedCheckBox.setText("Detect class references in quoted strings in HOCON files");
classReferencesQuotedCheckBox.setMnemonic('Q');
classReferencesQuotedCheckBox.setDisplayedMnemonicIndex(27);
mainPanel.add(classReferencesQuotedCheckBox, 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();
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));
searchInGotoSymbol = new JCheckBox();
searchInGotoSymbol.setSelected(false);
searchInGotoSymbol.setText("Navigate to HOCON properties using Go To Symbol action");
searchInGotoSymbol.setMnemonic('N');
searchInGotoSymbol.setDisplayedMnemonicIndex(0);
mainPanel.add(searchInGotoSymbol, 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));
propertyReferencesCheckBox = new JCheckBox();
propertyReferencesCheckBox.setText("Detect HOCON property references in string literals");
propertyReferencesCheckBox.setMnemonic('P');
propertyReferencesCheckBox.setDisplayedMnemonicIndex(13);
mainPanel.add(propertyReferencesCheckBox, 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));
}
public JComponent $$$getRootComponent$$$() {
return mainPanel;
}
}