Lines 44-66
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.modules.java.ui; |
45 |
package org.netbeans.modules.java.ui; |
46 |
|
46 |
|
|
|
47 |
import java.awt.Rectangle; |
48 |
import java.util.ArrayList; |
49 |
import java.util.Collections; |
50 |
import java.util.EnumSet; |
51 |
import java.util.List; |
52 |
import java.util.prefs.Preferences; |
53 |
|
54 |
import javax.lang.model.element.ElementKind; |
55 |
import javax.lang.model.element.Modifier; |
56 |
import javax.swing.DefaultListModel; |
57 |
import javax.swing.JEditorPane; |
58 |
import javax.swing.JList; |
59 |
import javax.swing.JPanel; |
60 |
import javax.swing.event.ListSelectionEvent; |
61 |
import javax.swing.event.ListSelectionListener; |
62 |
import javax.swing.text.BadLocationException; |
63 |
import javax.swing.text.Document; |
64 |
|
65 |
import com.sun.source.tree.AssignmentTree; |
66 |
import com.sun.source.tree.BlockTree; |
67 |
import com.sun.source.tree.ClassTree; |
68 |
import com.sun.source.tree.CompilationUnitTree; |
69 |
import com.sun.source.tree.ExpressionTree; |
70 |
import com.sun.source.tree.IdentifierTree; |
71 |
import com.sun.source.tree.ModifiersTree; |
72 |
import com.sun.source.tree.NewClassTree; |
73 |
import com.sun.source.tree.Tree; |
74 |
import com.sun.source.tree.TypeParameterTree; |
75 |
import com.sun.source.tree.VariableTree; |
76 |
|
77 |
import org.netbeans.api.java.source.CodeStyle; |
78 |
import org.netbeans.api.java.source.GeneratorUtilities; |
79 |
import org.netbeans.api.java.source.JavaSource.Phase; |
80 |
import org.netbeans.api.java.source.ModificationResult; |
81 |
import org.netbeans.api.java.source.TreeMaker; |
82 |
import org.netbeans.api.java.source.WorkingCopy; |
83 |
import org.netbeans.editor.BaseDocument; |
84 |
import org.netbeans.modules.editor.indent.api.Reformat; |
47 |
import static org.netbeans.modules.java.ui.FmtOptions.*; |
85 |
import static org.netbeans.modules.java.ui.FmtOptions.*; |
|
|
86 |
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport; |
48 |
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID; |
87 |
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID; |
49 |
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport; |
|
|
50 |
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer; |
88 |
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer; |
|
|
89 |
import org.netbeans.modules.parsing.api.ResultIterator; |
90 |
import org.netbeans.modules.parsing.api.Source; |
91 |
import org.netbeans.modules.parsing.api.UserTask; |
92 |
import org.openide.cookies.SaveCookie; |
93 |
import org.openide.filesystems.FileObject; |
94 |
import org.openide.filesystems.FileUtil; |
95 |
import org.openide.loaders.DataObject; |
96 |
import org.openide.util.NbBundle; |
51 |
|
97 |
|
52 |
|
98 |
|
53 |
/** |
99 |
/** |
54 |
* |
100 |
* |
55 |
* @author phrebejk |
101 |
* @author Petr Hrebejk, Dusan Balek |
56 |
*/ |
102 |
*/ |
57 |
public class FmtCodeGeneration extends javax.swing.JPanel { |
103 |
public class FmtCodeGeneration extends javax.swing.JPanel implements Runnable, ListSelectionListener { |
58 |
|
104 |
|
59 |
/** Creates new form FmtCodeGeneration */ |
105 |
/** Creates new form FmtCodeGeneration */ |
60 |
public FmtCodeGeneration() { |
106 |
public FmtCodeGeneration() { |
61 |
initComponents(); |
107 |
initComponents(); |
62 |
|
108 |
|
63 |
preferLongerNamesCheckBox.putClientProperty(OPTION_ID, preferLongerNames); |
109 |
preferLongerNamesCheckBox.putClientProperty(OPTION_ID, preferLongerNames); |
|
|
110 |
isForBooleanGettersCheckBox.putClientProperty(OPTION_ID, useIsForBooleanGetters); |
64 |
fieldPrefixField.putClientProperty(OPTION_ID, fieldNamePrefix); |
111 |
fieldPrefixField.putClientProperty(OPTION_ID, fieldNamePrefix); |
65 |
fieldSuffixField.putClientProperty(OPTION_ID, fieldNameSuffix); |
112 |
fieldSuffixField.putClientProperty(OPTION_ID, fieldNameSuffix); |
66 |
staticFieldPrefixField.putClientProperty(OPTION_ID, staticFieldNamePrefix); |
113 |
staticFieldPrefixField.putClientProperty(OPTION_ID, staticFieldNamePrefix); |
Lines 70-87
Link Here
|
70 |
localVarPrefixField.putClientProperty(OPTION_ID, localVarNamePrefix); |
117 |
localVarPrefixField.putClientProperty(OPTION_ID, localVarNamePrefix); |
71 |
localVarSuffixField.putClientProperty(OPTION_ID, localVarNameSuffix); |
118 |
localVarSuffixField.putClientProperty(OPTION_ID, localVarNameSuffix); |
72 |
qualifyFieldAccessCheckBox.putClientProperty(OPTION_ID, qualifyFieldAccess); |
119 |
qualifyFieldAccessCheckBox.putClientProperty(OPTION_ID, qualifyFieldAccess); |
73 |
isForBooleanGettersCheckBox.putClientProperty(OPTION_ID, useIsForBooleanGetters); |
|
|
74 |
addOverrideAnnortationCheckBox.putClientProperty(OPTION_ID, addOverrideAnnotation); |
120 |
addOverrideAnnortationCheckBox.putClientProperty(OPTION_ID, addOverrideAnnotation); |
75 |
parametersFinalCheckBox.putClientProperty(OPTION_ID, makeParametersFinal); |
121 |
parametersFinalCheckBox.putClientProperty(OPTION_ID, makeParametersFinal); |
76 |
localVarsFinalCheckBox.putClientProperty(OPTION_ID, makeLocalVarsFinal); |
122 |
localVarsFinalCheckBox.putClientProperty(OPTION_ID, makeLocalVarsFinal); |
77 |
// importsOrderList.putClientProperty(OPTION_ID, importsOrder); XXX |
123 |
membersOrderList.putClientProperty(OPTION_ID, classMembersOrder); |
78 |
|
124 |
sortByVisibilityCheckBox.putClientProperty(OPTION_ID, sortMembersByVisibility); |
|
|
125 |
visibilityOrderList.putClientProperty(OPTION_ID, visibilityOrder); |
126 |
insertionPointComboBox.putClientProperty(OPTION_ID, classMemberInsertionPoint); |
79 |
} |
127 |
} |
80 |
|
128 |
|
81 |
public static PreferencesCustomizer.Factory getController() { |
129 |
public static PreferencesCustomizer.Factory getController() { |
82 |
return new CategorySupport.Factory("code-generation", FmtCodeGeneration.class, null); |
130 |
return new PreferencesCustomizer.Factory() { |
|
|
131 |
public PreferencesCustomizer create(Preferences preferences) { |
132 |
CodeGenCategorySupport support = new CodeGenCategorySupport(preferences, new FmtCodeGeneration()); |
133 |
((Runnable)support.panel).run(); |
134 |
return support; |
135 |
} |
136 |
}; |
83 |
} |
137 |
} |
84 |
|
138 |
|
|
|
139 |
@Override |
140 |
public void run() { |
141 |
membersOrderList.setSelectedIndex(0); |
142 |
membersOrderList.addListSelectionListener(this); |
143 |
enableMembersOrderButtons(); |
144 |
visibilityOrderList.setSelectedIndex(0); |
145 |
visibilityOrderList.addListSelectionListener(this); |
146 |
enableVisibilityOrder(); |
147 |
namingConventionsLabel.setVisible(false); |
148 |
preferLongerNamesCheckBox.setVisible(false); |
149 |
isForBooleanGettersCheckBox.setVisible(false); |
150 |
prefixLabel.setVisible(false); |
151 |
suffixLabel.setVisible(false); |
152 |
fieldLabel.setVisible(false); |
153 |
fieldPrefixField.setVisible(false); |
154 |
fieldSuffixField.setVisible(false); |
155 |
staticFieldLabel.setVisible(false); |
156 |
staticFieldPrefixField.setVisible(false); |
157 |
staticFieldSuffixField.setVisible(false); |
158 |
parameterLabel.setVisible(false); |
159 |
parameterPrefixField.setVisible(false); |
160 |
parameterSuffixField.setVisible(false); |
161 |
localVarLabel.setVisible(false); |
162 |
localVarPrefixField.setVisible(false); |
163 |
localVarSuffixField.setVisible(false); |
164 |
jSeparator1.setVisible(false); |
165 |
otherLabel.setVisible(false); |
166 |
qualifyFieldAccessCheckBox.setVisible(false); |
167 |
addOverrideAnnortationCheckBox.setVisible(false); |
168 |
parametersFinalCheckBox.setVisible(false); |
169 |
localVarsFinalCheckBox.setVisible(false); |
170 |
jSeparator3.setVisible(false); |
171 |
} |
172 |
|
173 |
@Override |
174 |
public void valueChanged(ListSelectionEvent e) { |
175 |
if (e.getSource() == membersOrderList) |
176 |
enableMembersOrderButtons(); |
177 |
else |
178 |
enableVisibilityOrder(); |
179 |
} |
180 |
|
85 |
/** This method is called from within the constructor to |
181 |
/** This method is called from within the constructor to |
86 |
* initialize the form. |
182 |
* initialize the form. |
87 |
* WARNING: Do NOT modify this code. The content of this method is |
183 |
* WARNING: Do NOT modify this code. The content of this method is |
Lines 91-98
Link Here
|
91 |
private void initComponents() { |
187 |
private void initComponents() { |
92 |
java.awt.GridBagConstraints gridBagConstraints; |
188 |
java.awt.GridBagConstraints gridBagConstraints; |
93 |
|
189 |
|
94 |
preferLongerNamesLabel = new javax.swing.JLabel(); |
190 |
namingConventionsLabel = new javax.swing.JLabel(); |
95 |
preferLongerNamesCheckBox = new javax.swing.JCheckBox(); |
191 |
preferLongerNamesCheckBox = new javax.swing.JCheckBox(); |
|
|
192 |
isForBooleanGettersCheckBox = new javax.swing.JCheckBox(); |
193 |
jPanel1 = new javax.swing.JPanel(); |
96 |
prefixLabel = new javax.swing.JLabel(); |
194 |
prefixLabel = new javax.swing.JLabel(); |
97 |
suffixLabel = new javax.swing.JLabel(); |
195 |
suffixLabel = new javax.swing.JLabel(); |
98 |
fieldLabel = new javax.swing.JLabel(); |
196 |
fieldLabel = new javax.swing.JLabel(); |
Lines 105-399
Link Here
|
105 |
parameterPrefixField = new javax.swing.JTextField(); |
203 |
parameterPrefixField = new javax.swing.JTextField(); |
106 |
parameterSuffixField = new javax.swing.JTextField(); |
204 |
parameterSuffixField = new javax.swing.JTextField(); |
107 |
localVarLabel = new javax.swing.JLabel(); |
205 |
localVarLabel = new javax.swing.JLabel(); |
|
|
206 |
localVarSuffixField = new javax.swing.JTextField(); |
108 |
localVarPrefixField = new javax.swing.JTextField(); |
207 |
localVarPrefixField = new javax.swing.JTextField(); |
109 |
localVarSuffixField = new javax.swing.JTextField(); |
208 |
jSeparator1 = new javax.swing.JSeparator(); |
110 |
miscLabel = new javax.swing.JLabel(); |
209 |
otherLabel = new javax.swing.JLabel(); |
111 |
qualifyFieldAccessCheckBox = new javax.swing.JCheckBox(); |
210 |
qualifyFieldAccessCheckBox = new javax.swing.JCheckBox(); |
112 |
isForBooleanGettersCheckBox = new javax.swing.JCheckBox(); |
|
|
113 |
addOverrideAnnortationCheckBox = new javax.swing.JCheckBox(); |
211 |
addOverrideAnnortationCheckBox = new javax.swing.JCheckBox(); |
114 |
finalLabel = new javax.swing.JLabel(); |
|
|
115 |
parametersFinalCheckBox = new javax.swing.JCheckBox(); |
212 |
parametersFinalCheckBox = new javax.swing.JCheckBox(); |
116 |
localVarsFinalCheckBox = new javax.swing.JCheckBox(); |
213 |
localVarsFinalCheckBox = new javax.swing.JCheckBox(); |
117 |
jLabel10 = new javax.swing.JLabel(); |
214 |
memberOrderLabel = new javax.swing.JLabel(); |
118 |
jPanel1 = new javax.swing.JPanel(); |
|
|
119 |
jScrollPane1 = new javax.swing.JScrollPane(); |
215 |
jScrollPane1 = new javax.swing.JScrollPane(); |
120 |
importsOrderList = new javax.swing.JList(); |
216 |
membersOrderList = new javax.swing.JList(); |
121 |
importUpButton = new javax.swing.JButton(); |
217 |
upButton = new javax.swing.JButton(); |
122 |
importDownButton = new javax.swing.JButton(); |
218 |
downButton = new javax.swing.JButton(); |
|
|
219 |
jSeparator3 = new javax.swing.JSeparator(); |
220 |
sortByVisibilityCheckBox = new javax.swing.JCheckBox(); |
221 |
jScrollPane2 = new javax.swing.JScrollPane(); |
222 |
visibilityOrderList = new javax.swing.JList(); |
223 |
visUpButton = new javax.swing.JButton(); |
224 |
visDownButton = new javax.swing.JButton(); |
225 |
jSeparator2 = new javax.swing.JSeparator(); |
226 |
insertionPointLabel = new javax.swing.JLabel(); |
227 |
insertionPointComboBox = new javax.swing.JComboBox(); |
123 |
|
228 |
|
124 |
setName(org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_CodeGeneration")); // NOI18N |
229 |
setName(org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_CodeGeneration")); // NOI18N |
125 |
setOpaque(false); |
230 |
setOpaque(false); |
126 |
setLayout(new java.awt.GridBagLayout()); |
|
|
127 |
|
231 |
|
128 |
org.openide.awt.Mnemonics.setLocalizedText(preferLongerNamesLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Naming")); // NOI18N |
232 |
org.openide.awt.Mnemonics.setLocalizedText(namingConventionsLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Naming")); // NOI18N |
129 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
130 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
131 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
132 |
add(preferLongerNamesLabel, gridBagConstraints); |
133 |
|
233 |
|
134 |
org.openide.awt.Mnemonics.setLocalizedText(preferLongerNamesCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_PreferLongerNames")); // NOI18N |
234 |
org.openide.awt.Mnemonics.setLocalizedText(preferLongerNamesCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_PreferLongerNames")); // NOI18N |
135 |
preferLongerNamesCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
235 |
preferLongerNamesCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
136 |
preferLongerNamesCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
236 |
preferLongerNamesCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
137 |
preferLongerNamesCheckBox.setOpaque(false); |
237 |
preferLongerNamesCheckBox.setOpaque(false); |
138 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
139 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
140 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
141 |
gridBagConstraints.weightx = 1.0; |
142 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
143 |
add(preferLongerNamesCheckBox, gridBagConstraints); |
144 |
|
238 |
|
145 |
org.openide.awt.Mnemonics.setLocalizedText(prefixLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Prefix")); // NOI18N |
239 |
org.openide.awt.Mnemonics.setLocalizedText(isForBooleanGettersCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_UseIsForBooleanGetters")); // NOI18N |
|
|
240 |
isForBooleanGettersCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
241 |
isForBooleanGettersCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
242 |
isForBooleanGettersCheckBox.setOpaque(false); |
243 |
|
244 |
jPanel1.setLayout(new java.awt.GridBagLayout()); |
245 |
|
246 |
org.openide.awt.Mnemonics.setLocalizedText(prefixLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Prefix")); // NOI18N |
146 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
247 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
147 |
gridBagConstraints.gridx = 1; |
248 |
gridBagConstraints.gridx = 1; |
148 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
249 |
gridBagConstraints.gridy = 0; |
|
|
250 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
251 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
252 |
gridBagConstraints.weightx = 0.5; |
149 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
253 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
150 |
add(prefixLabel, gridBagConstraints); |
254 |
jPanel1.add(prefixLabel, gridBagConstraints); |
151 |
|
255 |
|
152 |
org.openide.awt.Mnemonics.setLocalizedText(suffixLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Suffix")); // NOI18N |
256 |
org.openide.awt.Mnemonics.setLocalizedText(suffixLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Suffix")); // NOI18N |
153 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
257 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
154 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
258 |
gridBagConstraints.gridx = 2; |
155 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
259 |
gridBagConstraints.gridy = 0; |
|
|
260 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
261 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
262 |
gridBagConstraints.weightx = 0.5; |
156 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
263 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
157 |
add(suffixLabel, gridBagConstraints); |
264 |
jPanel1.add(suffixLabel, gridBagConstraints); |
158 |
|
265 |
|
159 |
org.openide.awt.Mnemonics.setLocalizedText(fieldLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Field")); // NOI18N |
266 |
org.openide.awt.Mnemonics.setLocalizedText(fieldLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Field")); // NOI18N |
160 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
267 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
161 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
268 |
gridBagConstraints.gridx = 0; |
162 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
269 |
gridBagConstraints.gridy = 1; |
163 |
add(fieldLabel, gridBagConstraints); |
270 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
|
271 |
jPanel1.add(fieldLabel, gridBagConstraints); |
164 |
|
272 |
|
165 |
fieldPrefixField.setColumns(5); |
273 |
fieldPrefixField.setColumns(5); |
166 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
274 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
275 |
gridBagConstraints.gridx = 1; |
276 |
gridBagConstraints.gridy = 1; |
167 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
277 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
168 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
278 |
gridBagConstraints.weightx = 0.5; |
169 |
gridBagConstraints.weightx = 1.0; |
279 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
170 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
280 |
jPanel1.add(fieldPrefixField, gridBagConstraints); |
171 |
add(fieldPrefixField, gridBagConstraints); |
|
|
172 |
|
281 |
|
173 |
fieldSuffixField.setColumns(5); |
282 |
fieldSuffixField.setColumns(5); |
174 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
283 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
175 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
284 |
gridBagConstraints.gridx = 2; |
|
|
285 |
gridBagConstraints.gridy = 1; |
176 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
286 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
177 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
287 |
gridBagConstraints.weightx = 0.5; |
178 |
gridBagConstraints.weightx = 1.0; |
288 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
179 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
289 |
jPanel1.add(fieldSuffixField, gridBagConstraints); |
180 |
add(fieldSuffixField, gridBagConstraints); |
|
|
181 |
|
290 |
|
182 |
org.openide.awt.Mnemonics.setLocalizedText(staticFieldLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_StaticField")); // NOI18N |
291 |
org.openide.awt.Mnemonics.setLocalizedText(staticFieldLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_StaticField")); // NOI18N |
183 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
292 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
184 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
293 |
gridBagConstraints.gridx = 0; |
185 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
294 |
gridBagConstraints.gridy = 2; |
186 |
add(staticFieldLabel, gridBagConstraints); |
295 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
|
296 |
jPanel1.add(staticFieldLabel, gridBagConstraints); |
187 |
|
297 |
|
188 |
staticFieldPrefixField.setColumns(5); |
298 |
staticFieldPrefixField.setColumns(5); |
189 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
299 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
300 |
gridBagConstraints.gridx = 1; |
301 |
gridBagConstraints.gridy = 2; |
190 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
302 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
191 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
303 |
gridBagConstraints.weightx = 0.5; |
192 |
gridBagConstraints.weightx = 1.0; |
304 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
193 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
305 |
jPanel1.add(staticFieldPrefixField, gridBagConstraints); |
194 |
add(staticFieldPrefixField, gridBagConstraints); |
|
|
195 |
|
306 |
|
196 |
staticFieldSuffixField.setColumns(5); |
307 |
staticFieldSuffixField.setColumns(5); |
197 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
308 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
198 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
309 |
gridBagConstraints.gridx = 2; |
|
|
310 |
gridBagConstraints.gridy = 2; |
199 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
311 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
200 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
312 |
gridBagConstraints.weightx = 0.5; |
201 |
gridBagConstraints.weightx = 1.0; |
313 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
202 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
314 |
jPanel1.add(staticFieldSuffixField, gridBagConstraints); |
203 |
add(staticFieldSuffixField, gridBagConstraints); |
|
|
204 |
|
315 |
|
205 |
org.openide.awt.Mnemonics.setLocalizedText(parameterLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Parameter")); // NOI18N |
316 |
org.openide.awt.Mnemonics.setLocalizedText(parameterLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Parameter")); // NOI18N |
206 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
317 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
207 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
318 |
gridBagConstraints.gridx = 0; |
208 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
319 |
gridBagConstraints.gridy = 3; |
209 |
add(parameterLabel, gridBagConstraints); |
320 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
|
321 |
jPanel1.add(parameterLabel, gridBagConstraints); |
210 |
|
322 |
|
211 |
parameterPrefixField.setColumns(5); |
323 |
parameterPrefixField.setColumns(5); |
212 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
324 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
325 |
gridBagConstraints.gridx = 1; |
326 |
gridBagConstraints.gridy = 3; |
213 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
327 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
214 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
328 |
gridBagConstraints.weightx = 0.5; |
215 |
gridBagConstraints.weightx = 1.0; |
329 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
216 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
330 |
jPanel1.add(parameterPrefixField, gridBagConstraints); |
217 |
add(parameterPrefixField, gridBagConstraints); |
|
|
218 |
|
331 |
|
219 |
parameterSuffixField.setColumns(5); |
332 |
parameterSuffixField.setColumns(5); |
220 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
333 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
221 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
334 |
gridBagConstraints.gridx = 2; |
|
|
335 |
gridBagConstraints.gridy = 3; |
222 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
336 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
223 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
337 |
gridBagConstraints.weightx = 0.5; |
224 |
gridBagConstraints.weightx = 1.0; |
338 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 4, 0); |
225 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
339 |
jPanel1.add(parameterSuffixField, gridBagConstraints); |
226 |
add(parameterSuffixField, gridBagConstraints); |
|
|
227 |
|
340 |
|
228 |
org.openide.awt.Mnemonics.setLocalizedText(localVarLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_LocalVariable")); // NOI18N |
341 |
org.openide.awt.Mnemonics.setLocalizedText(localVarLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_LocalVariable")); // NOI18N |
229 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
342 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
230 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
343 |
gridBagConstraints.gridx = 0; |
231 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 9, 0); |
344 |
gridBagConstraints.gridy = 4; |
232 |
add(localVarLabel, gridBagConstraints); |
345 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
|
346 |
gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0); |
347 |
jPanel1.add(localVarLabel, gridBagConstraints); |
348 |
|
349 |
localVarSuffixField.setColumns(5); |
350 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
351 |
gridBagConstraints.gridx = 1; |
352 |
gridBagConstraints.gridy = 4; |
353 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
354 |
gridBagConstraints.weightx = 0.5; |
355 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 0, 0); |
356 |
jPanel1.add(localVarSuffixField, gridBagConstraints); |
233 |
|
357 |
|
234 |
localVarPrefixField.setColumns(5); |
358 |
localVarPrefixField.setColumns(5); |
235 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
359 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
360 |
gridBagConstraints.gridx = 2; |
361 |
gridBagConstraints.gridy = 4; |
236 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
362 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
237 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
363 |
gridBagConstraints.weightx = 0.5; |
238 |
gridBagConstraints.weightx = 1.0; |
364 |
gridBagConstraints.insets = new java.awt.Insets(4, 8, 0, 0); |
239 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 9, 0); |
365 |
jPanel1.add(localVarPrefixField, gridBagConstraints); |
240 |
add(localVarPrefixField, gridBagConstraints); |
|
|
241 |
|
366 |
|
242 |
localVarSuffixField.setColumns(5); |
367 |
org.openide.awt.Mnemonics.setLocalizedText(otherLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_Other")); // NOI18N |
243 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
244 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
245 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
246 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
247 |
gridBagConstraints.weightx = 1.0; |
248 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 9, 0); |
249 |
add(localVarSuffixField, gridBagConstraints); |
250 |
|
368 |
|
251 |
org.openide.awt.Mnemonics.setLocalizedText(miscLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_Misc")); // NOI18N |
369 |
org.openide.awt.Mnemonics.setLocalizedText(qualifyFieldAccessCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_QualifyFieldAccess")); // NOI18N |
252 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
253 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
254 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
255 |
add(miscLabel, gridBagConstraints); |
256 |
|
257 |
org.openide.awt.Mnemonics.setLocalizedText(qualifyFieldAccessCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_QualifyFieldAccess")); // NOI18N |
258 |
qualifyFieldAccessCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
370 |
qualifyFieldAccessCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
259 |
qualifyFieldAccessCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
371 |
qualifyFieldAccessCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
260 |
qualifyFieldAccessCheckBox.setOpaque(false); |
372 |
qualifyFieldAccessCheckBox.setOpaque(false); |
261 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
262 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
263 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
264 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
265 |
add(qualifyFieldAccessCheckBox, gridBagConstraints); |
266 |
|
373 |
|
267 |
org.openide.awt.Mnemonics.setLocalizedText(isForBooleanGettersCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_UseIsForBooleanGetters")); // NOI18N |
374 |
org.openide.awt.Mnemonics.setLocalizedText(addOverrideAnnortationCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_AddOverrideAnnotation")); // NOI18N |
268 |
isForBooleanGettersCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
269 |
isForBooleanGettersCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
270 |
isForBooleanGettersCheckBox.setOpaque(false); |
271 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
272 |
gridBagConstraints.gridx = 1; |
273 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
274 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
275 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
276 |
add(isForBooleanGettersCheckBox, gridBagConstraints); |
277 |
|
278 |
org.openide.awt.Mnemonics.setLocalizedText(addOverrideAnnortationCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_AddOverrideAnnotation")); // NOI18N |
279 |
addOverrideAnnortationCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
375 |
addOverrideAnnortationCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
280 |
addOverrideAnnortationCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
376 |
addOverrideAnnortationCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
281 |
addOverrideAnnortationCheckBox.setOpaque(false); |
377 |
addOverrideAnnortationCheckBox.setOpaque(false); |
282 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
283 |
gridBagConstraints.gridx = 1; |
284 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
285 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
286 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 8, 0); |
287 |
add(addOverrideAnnortationCheckBox, gridBagConstraints); |
288 |
|
378 |
|
289 |
org.openide.awt.Mnemonics.setLocalizedText(finalLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_FinalMofier")); // NOI18N |
379 |
org.openide.awt.Mnemonics.setLocalizedText(parametersFinalCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_ParametersFinal")); // NOI18N |
290 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
291 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
292 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
293 |
add(finalLabel, gridBagConstraints); |
294 |
|
295 |
org.openide.awt.Mnemonics.setLocalizedText(parametersFinalCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_ParametersFinal")); // NOI18N |
296 |
parametersFinalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
380 |
parametersFinalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
297 |
parametersFinalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
381 |
parametersFinalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
298 |
parametersFinalCheckBox.setOpaque(false); |
382 |
parametersFinalCheckBox.setOpaque(false); |
299 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
300 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
301 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
302 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
303 |
add(parametersFinalCheckBox, gridBagConstraints); |
304 |
|
383 |
|
305 |
org.openide.awt.Mnemonics.setLocalizedText(localVarsFinalCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_LocalVariablesFinal")); // NOI18N |
384 |
org.openide.awt.Mnemonics.setLocalizedText(localVarsFinalCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_LocalVariablesFinal")); // NOI18N |
306 |
localVarsFinalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
385 |
localVarsFinalCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
307 |
localVarsFinalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
386 |
localVarsFinalCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
308 |
localVarsFinalCheckBox.setOpaque(false); |
387 |
localVarsFinalCheckBox.setOpaque(false); |
309 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
310 |
gridBagConstraints.gridx = 1; |
311 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
312 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
313 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 8, 0); |
314 |
add(localVarsFinalCheckBox, gridBagConstraints); |
315 |
|
388 |
|
316 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel10, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_ImportOredering")); // NOI18N |
389 |
org.openide.awt.Mnemonics.setLocalizedText(memberOrderLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_MembersOreder")); // NOI18N |
317 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
|
318 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
319 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); |
320 |
add(jLabel10, gridBagConstraints); |
321 |
|
390 |
|
322 |
jPanel1.setOpaque(false); |
391 |
membersOrderList.setModel(new javax.swing.AbstractListModel() { |
323 |
jPanel1.setLayout(new java.awt.GridBagLayout()); |
392 |
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9" }; |
324 |
|
|
|
325 |
importsOrderList.setModel(new javax.swing.AbstractListModel() { |
326 |
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; |
327 |
public int getSize() { return strings.length; } |
393 |
public int getSize() { return strings.length; } |
328 |
public Object getElementAt(int i) { return strings[i]; } |
394 |
public Object getElementAt(int i) { return strings[i]; } |
329 |
}); |
395 |
}); |
330 |
jScrollPane1.setViewportView(importsOrderList); |
396 |
membersOrderList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
|
|
397 |
jScrollPane1.setViewportView(membersOrderList); |
331 |
|
398 |
|
332 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
399 |
org.openide.awt.Mnemonics.setLocalizedText(upButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_MembersOrederUp")); // NOI18N |
333 |
gridBagConstraints.gridheight = 2; |
400 |
upButton.addActionListener(new java.awt.event.ActionListener() { |
334 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
401 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
335 |
gridBagConstraints.weightx = 1.0; |
402 |
upButtonActionPerformed(evt); |
336 |
gridBagConstraints.insets = new java.awt.Insets(0, 8, 4, 0); |
403 |
} |
337 |
jPanel1.add(jScrollPane1, gridBagConstraints); |
404 |
}); |
338 |
|
405 |
|
339 |
org.openide.awt.Mnemonics.setLocalizedText(importUpButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_ImportUp")); // NOI18N |
406 |
org.openide.awt.Mnemonics.setLocalizedText(downButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_MembersOrederDown")); // NOI18N |
340 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
407 |
downButton.addActionListener(new java.awt.event.ActionListener() { |
341 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
408 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
342 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
409 |
downButtonActionPerformed(evt); |
343 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
410 |
} |
344 |
gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 1); |
411 |
}); |
345 |
jPanel1.add(importUpButton, gridBagConstraints); |
|
|
346 |
|
412 |
|
347 |
org.openide.awt.Mnemonics.setLocalizedText(importDownButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_ImportDown")); // NOI18N |
413 |
org.openide.awt.Mnemonics.setLocalizedText(sortByVisibilityCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_SortByVisibility")); // NOI18N |
348 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
414 |
sortByVisibilityCheckBox.addActionListener(new java.awt.event.ActionListener() { |
349 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
415 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
350 |
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; |
416 |
sortByVisibilityCheckBoxActionPerformed(evt); |
351 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
417 |
} |
352 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
418 |
}); |
353 |
gridBagConstraints.weighty = 1.0; |
|
|
354 |
gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 1); |
355 |
jPanel1.add(importDownButton, gridBagConstraints); |
356 |
|
419 |
|
357 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
420 |
visibilityOrderList.setModel(new javax.swing.AbstractListModel() { |
358 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
421 |
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4" }; |
359 |
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; |
422 |
public int getSize() { return strings.length; } |
360 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
423 |
public Object getElementAt(int i) { return strings[i]; } |
361 |
gridBagConstraints.weightx = 1.0; |
424 |
}); |
362 |
gridBagConstraints.weighty = 1.0; |
425 |
visibilityOrderList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
363 |
add(jPanel1, gridBagConstraints); |
426 |
jScrollPane2.setViewportView(visibilityOrderList); |
|
|
427 |
|
428 |
org.openide.awt.Mnemonics.setLocalizedText(visUpButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_MembersOrederUp")); // NOI18N |
429 |
visUpButton.addActionListener(new java.awt.event.ActionListener() { |
430 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
431 |
visUpButtonActionPerformed(evt); |
432 |
} |
433 |
}); |
434 |
|
435 |
org.openide.awt.Mnemonics.setLocalizedText(visDownButton, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_MembersOrederDown")); // NOI18N |
436 |
visDownButton.addActionListener(new java.awt.event.ActionListener() { |
437 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
438 |
visDownButtonActionPerformed(evt); |
439 |
} |
440 |
}); |
441 |
|
442 |
insertionPointLabel.setLabelFor(insertionPointComboBox); |
443 |
org.openide.awt.Mnemonics.setLocalizedText(insertionPointLabel, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_gen_InsertionPoint")); // NOI18N |
444 |
|
445 |
insertionPointComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); |
446 |
|
447 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
448 |
this.setLayout(layout); |
449 |
layout.setHorizontalGroup( |
450 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
451 |
.addComponent(jSeparator1) |
452 |
.addGroup(layout.createSequentialGroup() |
453 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
454 |
.addComponent(otherLabel) |
455 |
.addGroup(layout.createSequentialGroup() |
456 |
.addContainerGap() |
457 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
458 |
.addComponent(qualifyFieldAccessCheckBox) |
459 |
.addComponent(addOverrideAnnortationCheckBox) |
460 |
.addComponent(parametersFinalCheckBox) |
461 |
.addComponent(localVarsFinalCheckBox)))) |
462 |
.addGap(0, 0, Short.MAX_VALUE)) |
463 |
.addComponent(jSeparator3) |
464 |
.addGroup(layout.createSequentialGroup() |
465 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
466 |
.addComponent(namingConventionsLabel) |
467 |
.addComponent(memberOrderLabel) |
468 |
.addGroup(layout.createSequentialGroup() |
469 |
.addContainerGap() |
470 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
471 |
.addComponent(isForBooleanGettersCheckBox) |
472 |
.addComponent(preferLongerNamesCheckBox) |
473 |
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE) |
474 |
.addGroup(layout.createSequentialGroup() |
475 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
476 |
.addComponent(jScrollPane1) |
477 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)) |
478 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
479 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
480 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
481 |
.addComponent(downButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
482 |
.addComponent(upButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)) |
483 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
484 |
.addComponent(visDownButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
485 |
.addComponent(visUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))))) |
486 |
.addComponent(sortByVisibilityCheckBox) |
487 |
.addGroup(layout.createSequentialGroup() |
488 |
.addGap(5, 5, 5) |
489 |
.addComponent(insertionPointLabel) |
490 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
491 |
.addComponent(insertionPointComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) |
492 |
.addContainerGap()) |
493 |
.addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING) |
494 |
); |
495 |
layout.setVerticalGroup( |
496 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
497 |
.addGroup(layout.createSequentialGroup() |
498 |
.addComponent(namingConventionsLabel) |
499 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
500 |
.addComponent(preferLongerNamesCheckBox) |
501 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
502 |
.addComponent(isForBooleanGettersCheckBox) |
503 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
504 |
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
505 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
506 |
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
507 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
508 |
.addComponent(otherLabel) |
509 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
510 |
.addComponent(qualifyFieldAccessCheckBox) |
511 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
512 |
.addComponent(addOverrideAnnortationCheckBox) |
513 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
514 |
.addComponent(parametersFinalCheckBox) |
515 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
516 |
.addComponent(localVarsFinalCheckBox) |
517 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
518 |
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
519 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
520 |
.addComponent(memberOrderLabel) |
521 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
522 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
523 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE) |
524 |
.addGroup(layout.createSequentialGroup() |
525 |
.addComponent(upButton) |
526 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
527 |
.addComponent(downButton))) |
528 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
529 |
.addComponent(sortByVisibilityCheckBox) |
530 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
531 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
532 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) |
533 |
.addGroup(layout.createSequentialGroup() |
534 |
.addComponent(visUpButton) |
535 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
536 |
.addComponent(visDownButton))) |
537 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
538 |
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
539 |
.addGap(10, 10, 10) |
540 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
541 |
.addComponent(insertionPointLabel) |
542 |
.addComponent(insertionPointComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) |
543 |
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
544 |
); |
364 |
}// </editor-fold>//GEN-END:initComponents |
545 |
}// </editor-fold>//GEN-END:initComponents |
|
|
546 |
|
547 |
private void upButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upButtonActionPerformed |
548 |
int idx = membersOrderList.getSelectedIndex(); |
549 |
if (idx > 0) { |
550 |
Object val = membersOrderList.getModel().getElementAt(idx); |
551 |
((DefaultListModel)membersOrderList.getModel()).removeElementAt(idx); |
552 |
((DefaultListModel)membersOrderList.getModel()).insertElementAt(val, idx - 1); |
553 |
membersOrderList.setSelectedIndex(idx - 1); |
554 |
} |
555 |
}//GEN-LAST:event_upButtonActionPerformed |
556 |
|
557 |
private void downButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downButtonActionPerformed |
558 |
int idx = membersOrderList.getSelectedIndex(); |
559 |
if (idx >= 0 && idx < membersOrderList.getModel().getSize() - 1) { |
560 |
Object val = membersOrderList.getModel().getElementAt(idx); |
561 |
((DefaultListModel)membersOrderList.getModel()).removeElementAt(idx); |
562 |
((DefaultListModel)membersOrderList.getModel()).insertElementAt(val, idx + 1); |
563 |
membersOrderList.setSelectedIndex(idx + 1); |
564 |
} |
565 |
}//GEN-LAST:event_downButtonActionPerformed |
566 |
|
567 |
private void visUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visUpButtonActionPerformed |
568 |
int idx = visibilityOrderList.getSelectedIndex(); |
569 |
if (idx > 0) { |
570 |
Object val = visibilityOrderList.getModel().getElementAt(idx); |
571 |
((DefaultListModel)visibilityOrderList.getModel()).removeElementAt(idx); |
572 |
((DefaultListModel)visibilityOrderList.getModel()).insertElementAt(val, idx - 1); |
573 |
visibilityOrderList.setSelectedIndex(idx - 1); |
574 |
} |
575 |
}//GEN-LAST:event_visUpButtonActionPerformed |
576 |
|
577 |
private void visDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visDownButtonActionPerformed |
578 |
int idx = visibilityOrderList.getSelectedIndex(); |
579 |
if (idx >= 0 && idx < visibilityOrderList.getModel().getSize() - 1) { |
580 |
Object val = visibilityOrderList.getModel().getElementAt(idx); |
581 |
((DefaultListModel)visibilityOrderList.getModel()).removeElementAt(idx); |
582 |
((DefaultListModel)visibilityOrderList.getModel()).insertElementAt(val, idx + 1); |
583 |
visibilityOrderList.setSelectedIndex(idx + 1); |
584 |
} |
585 |
}//GEN-LAST:event_visDownButtonActionPerformed |
586 |
|
587 |
private void sortByVisibilityCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sortByVisibilityCheckBoxActionPerformed |
588 |
enableVisibilityOrder(); |
589 |
}//GEN-LAST:event_sortByVisibilityCheckBoxActionPerformed |
365 |
|
590 |
|
|
|
591 |
private void enableMembersOrderButtons() { |
592 |
int idx = membersOrderList.getSelectedIndex(); |
593 |
upButton.setEnabled(idx > 0); |
594 |
downButton.setEnabled(idx >= 0 && idx < membersOrderList.getModel().getSize() - 1); |
595 |
} |
596 |
|
597 |
private void enableVisibilityOrder() { |
598 |
int idx = visibilityOrderList.getSelectedIndex(); |
599 |
boolean b = sortByVisibilityCheckBox.isSelected(); |
600 |
visibilityOrderList.setEnabled(b); |
601 |
visUpButton.setEnabled(b && idx > 0); |
602 |
visDownButton.setEnabled(b && idx >= 0 && idx < visibilityOrderList.getModel().getSize() - 1); |
603 |
} |
366 |
|
604 |
|
367 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
605 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
368 |
private javax.swing.JCheckBox addOverrideAnnortationCheckBox; |
606 |
private javax.swing.JCheckBox addOverrideAnnortationCheckBox; |
|
|
607 |
private javax.swing.JButton downButton; |
369 |
private javax.swing.JLabel fieldLabel; |
608 |
private javax.swing.JLabel fieldLabel; |
370 |
private javax.swing.JTextField fieldPrefixField; |
609 |
private javax.swing.JTextField fieldPrefixField; |
371 |
private javax.swing.JTextField fieldSuffixField; |
610 |
private javax.swing.JTextField fieldSuffixField; |
372 |
private javax.swing.JLabel finalLabel; |
611 |
private javax.swing.JComboBox insertionPointComboBox; |
373 |
private javax.swing.JButton importDownButton; |
612 |
private javax.swing.JLabel insertionPointLabel; |
374 |
private javax.swing.JButton importUpButton; |
|
|
375 |
private javax.swing.JList importsOrderList; |
376 |
private javax.swing.JCheckBox isForBooleanGettersCheckBox; |
613 |
private javax.swing.JCheckBox isForBooleanGettersCheckBox; |
377 |
private javax.swing.JLabel jLabel10; |
|
|
378 |
private javax.swing.JPanel jPanel1; |
614 |
private javax.swing.JPanel jPanel1; |
379 |
private javax.swing.JScrollPane jScrollPane1; |
615 |
private javax.swing.JScrollPane jScrollPane1; |
|
|
616 |
private javax.swing.JScrollPane jScrollPane2; |
617 |
private javax.swing.JSeparator jSeparator1; |
618 |
private javax.swing.JSeparator jSeparator2; |
619 |
private javax.swing.JSeparator jSeparator3; |
380 |
private javax.swing.JLabel localVarLabel; |
620 |
private javax.swing.JLabel localVarLabel; |
381 |
private javax.swing.JTextField localVarPrefixField; |
621 |
private javax.swing.JTextField localVarPrefixField; |
382 |
private javax.swing.JTextField localVarSuffixField; |
622 |
private javax.swing.JTextField localVarSuffixField; |
383 |
private javax.swing.JCheckBox localVarsFinalCheckBox; |
623 |
private javax.swing.JCheckBox localVarsFinalCheckBox; |
384 |
private javax.swing.JLabel miscLabel; |
624 |
private javax.swing.JLabel memberOrderLabel; |
|
|
625 |
private javax.swing.JList membersOrderList; |
626 |
private javax.swing.JLabel namingConventionsLabel; |
627 |
private javax.swing.JLabel otherLabel; |
385 |
private javax.swing.JLabel parameterLabel; |
628 |
private javax.swing.JLabel parameterLabel; |
386 |
private javax.swing.JTextField parameterPrefixField; |
629 |
private javax.swing.JTextField parameterPrefixField; |
387 |
private javax.swing.JTextField parameterSuffixField; |
630 |
private javax.swing.JTextField parameterSuffixField; |
388 |
private javax.swing.JCheckBox parametersFinalCheckBox; |
631 |
private javax.swing.JCheckBox parametersFinalCheckBox; |
389 |
private javax.swing.JCheckBox preferLongerNamesCheckBox; |
632 |
private javax.swing.JCheckBox preferLongerNamesCheckBox; |
390 |
private javax.swing.JLabel preferLongerNamesLabel; |
|
|
391 |
private javax.swing.JLabel prefixLabel; |
633 |
private javax.swing.JLabel prefixLabel; |
392 |
private javax.swing.JCheckBox qualifyFieldAccessCheckBox; |
634 |
private javax.swing.JCheckBox qualifyFieldAccessCheckBox; |
|
|
635 |
private javax.swing.JCheckBox sortByVisibilityCheckBox; |
393 |
private javax.swing.JLabel staticFieldLabel; |
636 |
private javax.swing.JLabel staticFieldLabel; |
394 |
private javax.swing.JTextField staticFieldPrefixField; |
637 |
private javax.swing.JTextField staticFieldPrefixField; |
395 |
private javax.swing.JTextField staticFieldSuffixField; |
638 |
private javax.swing.JTextField staticFieldSuffixField; |
396 |
private javax.swing.JLabel suffixLabel; |
639 |
private javax.swing.JLabel suffixLabel; |
|
|
640 |
private javax.swing.JButton upButton; |
641 |
private javax.swing.JButton visDownButton; |
642 |
private javax.swing.JButton visUpButton; |
643 |
private javax.swing.JList visibilityOrderList; |
397 |
// End of variables declaration//GEN-END:variables |
644 |
// End of variables declaration//GEN-END:variables |
|
|
645 |
|
646 |
private static final class CodeGenCategorySupport extends CategorySupport { |
647 |
|
648 |
private Source source = null; |
649 |
|
650 |
private CodeGenCategorySupport(Preferences preferences, JPanel panel) { |
651 |
super(preferences, "code-generation", panel, NbBundle.getMessage(FmtCodeGeneration.class, "SAMPLE_CodeGen"), //NOI18N |
652 |
new String[] { FmtOptions.blankLinesBeforeFields, "1" }); //NOI18N |
653 |
} |
398 |
|
654 |
|
|
|
655 |
@Override |
656 |
protected void loadListData(JList list, String optionID, Preferences node) { |
657 |
DefaultListModel model = new DefaultListModel(); |
658 |
String value = node.get(optionID, getDefaultAsString(optionID)); |
659 |
for (String s : value.trim().split("\\s*[,;]\\s*")) { //NOI18N |
660 |
if (classMembersOrder.equals(optionID)) { |
661 |
Element e = new Element(); |
662 |
if (s.startsWith("STATIC ")) { //NOI18N |
663 |
e.isStatic = true; |
664 |
s = s.substring(7); |
665 |
} |
666 |
e.kind = ElementKind.valueOf(s); |
667 |
model.addElement(e); |
668 |
} else { |
669 |
Visibility v = new Visibility(); |
670 |
v.kind = s; |
671 |
model.addElement(v); |
672 |
} |
673 |
} |
674 |
list.setModel(model); |
675 |
} |
676 |
|
677 |
@Override |
678 |
protected void storeListData(final JList list, final String optionID, final Preferences node) { |
679 |
StringBuilder sb = null; |
680 |
for (int i = 0; i < list.getModel().getSize(); i++) { |
681 |
if (sb == null) { |
682 |
sb = new StringBuilder(); |
683 |
} else { |
684 |
sb.append(';'); |
685 |
} |
686 |
if (classMembersOrder.equals(optionID)) { |
687 |
Element e = (Element) list.getModel().getElementAt(i); |
688 |
if (e.isStatic) |
689 |
sb.append("STATIC "); //NOI18N |
690 |
sb.append(e.kind.name()); |
691 |
} else { |
692 |
Visibility v = (Visibility) list.getModel().getElementAt(i); |
693 |
sb.append(v.kind); |
694 |
} |
695 |
} |
696 |
String value = sb != null ? sb.toString() : ""; //NOI18N |
697 |
if (getDefaultAsString(optionID).equals(value)) |
698 |
node.remove(optionID); |
699 |
else |
700 |
node.put(optionID, value); |
701 |
} |
702 |
|
703 |
@Override |
704 |
public void refreshPreview() { |
705 |
final JEditorPane jep = (JEditorPane) getPreviewComponent(); |
706 |
try { |
707 |
Class.forName(CodeStyle.class.getName(), true, CodeStyle.class.getClassLoader()); |
708 |
} catch (ClassNotFoundException cnfe) { |
709 |
// ignore |
710 |
} |
711 |
|
712 |
final CodeStyle codeStyle = codeStyleProducer.create(previewPrefs); |
713 |
jep.setIgnoreRepaint(true); |
714 |
try { |
715 |
if (source == null) { |
716 |
FileObject fo = FileUtil.createMemoryFileSystem().getRoot().createData("org.netbeans.samples.ClassA", "java"); //NOI18N |
717 |
source = Source.create(fo); |
718 |
} |
719 |
final Document doc = source.getDocument(true); |
720 |
if (doc.getLength() > 0) { |
721 |
doc.remove(0, doc.getLength()); |
722 |
} |
723 |
doc.insertString(0, previewText, null); |
724 |
doc.putProperty(CodeStyle.class, codeStyle); |
725 |
jep.setDocument(doc); |
726 |
ModificationResult result = ModificationResult.runModificationTask(Collections.singleton(source), new UserTask() { |
727 |
|
728 |
@Override |
729 |
public void run(ResultIterator resultIterator) throws Exception { |
730 |
WorkingCopy copy = WorkingCopy.get(resultIterator.getParserResult()); |
731 |
copy.toPhase(Phase.RESOLVED); |
732 |
TreeMaker tm = copy.getTreeMaker(); |
733 |
GeneratorUtilities gu = GeneratorUtilities.get(copy); |
734 |
CompilationUnitTree cut = copy.getCompilationUnit(); |
735 |
ClassTree ct = (ClassTree) cut.getTypeDecls().get(0); |
736 |
VariableTree field = (VariableTree)ct.getMembers().get(1); |
737 |
List<Tree> members = new ArrayList<Tree>(); |
738 |
AssignmentTree stat = tm.Assignment(tm.Identifier("name"), tm.Literal("Name")); //NOI18N |
739 |
BlockTree init = tm.Block(Collections.singletonList(tm.ExpressionStatement(stat)), false); |
740 |
members.add(init); |
741 |
members.add(gu.createConstructor(ct, Collections.<VariableTree>emptyList())); |
742 |
members.add(gu.createGetter(field)); |
743 |
ModifiersTree mods = tm.Modifiers(EnumSet.of(Modifier.PRIVATE)); |
744 |
ClassTree inner = tm.Class(mods, "Inner", Collections.<TypeParameterTree>emptyList(), null, Collections.<Tree>emptyList(), Collections.<Tree>emptyList()); //NOI18N |
745 |
members.add(inner); |
746 |
mods = tm.Modifiers(EnumSet.of(Modifier.PRIVATE, Modifier.STATIC)); |
747 |
ClassTree nested = tm.Class(mods, "Nested", Collections.<TypeParameterTree>emptyList(), null, Collections.<Tree>emptyList(), Collections.<Tree>emptyList()); //NOI18N |
748 |
members.add(nested); |
749 |
IdentifierTree nestedId = tm.Identifier("Nested"); //NOI18N |
750 |
VariableTree staticField = tm.Variable(mods, "instance", nestedId, null); //NOI18N |
751 |
members.add(staticField); |
752 |
NewClassTree nct = tm.NewClass(null, Collections.<ExpressionTree>emptyList(), nestedId, Collections.<ExpressionTree>emptyList(), null); |
753 |
stat = tm.Assignment(tm.Identifier("instance"), nct); //NOI18N |
754 |
BlockTree staticInit = tm.Block(Collections.singletonList(tm.ExpressionStatement(stat)), true); |
755 |
members.add(staticInit); |
756 |
members.add(gu.createGetter(staticField)); |
757 |
ClassTree newCT = gu.insertClassMembers(ct, members); |
758 |
copy.rewrite(ct, newCT); |
759 |
} |
760 |
}); |
761 |
result.commit(); |
762 |
final Reformat reformat = Reformat.get(doc); |
763 |
reformat.lock(); |
764 |
try { |
765 |
if (doc instanceof BaseDocument) { |
766 |
((BaseDocument) doc).runAtomicAsUser(new Runnable() { |
767 |
@Override |
768 |
public void run() { |
769 |
try { |
770 |
reformat.reformat(0, doc.getLength()); |
771 |
} catch (BadLocationException ble) {} |
772 |
} |
773 |
}); |
774 |
} else { |
775 |
reformat.reformat(0, doc.getLength()); |
776 |
} |
777 |
} finally { |
778 |
reformat.unlock(); |
779 |
} |
780 |
DataObject dataObject = DataObject.find(source.getFileObject()); |
781 |
SaveCookie sc = dataObject.getLookup().lookup(SaveCookie.class); |
782 |
if (sc != null) |
783 |
sc.save(); |
784 |
} catch (Exception ex) {} |
785 |
jep.setIgnoreRepaint(false); |
786 |
jep.scrollRectToVisible(new Rectangle(0, 0, 10, 10)); |
787 |
jep.repaint(100); |
788 |
} |
789 |
|
790 |
private static class Element { |
791 |
|
792 |
private boolean isStatic; |
793 |
private ElementKind kind; |
794 |
|
795 |
@Override |
796 |
public String toString() { |
797 |
return (isStatic ? NbBundle.getMessage(FmtCodeGeneration.class, "VAL_gen_STATIC") + " " : "") //NOI18N |
798 |
+ NbBundle.getMessage(FmtCodeGeneration.class, "VAL_gen_" + kind.name()); //NOI18N |
799 |
} |
800 |
} |
801 |
|
802 |
private static class Visibility { |
803 |
|
804 |
private String kind; |
805 |
|
806 |
@Override |
807 |
public String toString() { |
808 |
return NbBundle.getMessage(FmtCodeGeneration.class, "VAL_gen_" + kind); //NOI18N |
809 |
} |
810 |
} |
811 |
} |
399 |
} |
812 |
} |