@@ -69,15 +69,14 @@ public void setUp() throws Exception {
69
69
70
70
@ After
71
71
public void tearDown () throws Exception {
72
- env .release (program );
73
72
env .dispose ();
74
73
}
75
74
76
75
@ Test
77
76
public void testEnumFields () throws Exception {
78
77
Category c = program .getListing ()
79
- .getDataTypeManager ()
80
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
78
+ .getDataTypeManager ()
79
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
81
80
Enum enumm = createEnum (c , "TestEnum" , 1 );
82
81
edit (enumm );
83
82
@@ -100,7 +99,7 @@ public void testEnumFields() throws Exception {
100
99
JTextField catField = getTextField (panel , "Category" );
101
100
assertNotNull (catField );
102
101
assertEquals ("notepad/Category1" , catField .getText ());
103
- assertTrue (! catField .isEditable ());
102
+ assertFalse ( catField .isEditable ());
104
103
105
104
// size should be "1"
106
105
@ SuppressWarnings ("unchecked" )
@@ -114,12 +113,12 @@ public void testEnumFields() throws Exception {
114
113
// add action should be enabled
115
114
// apply action should be disabled
116
115
// delete action should be disabled
117
- DockingActionIf addAction = getAction ( plugin , "Add Enum Value" );
116
+ DockingActionIf addAction = getAddAction ( );
118
117
assertTrue (addAction .isEnabled ());
119
- DockingActionIf applyAction = getAction ( plugin , "Apply Enum Changes" );
120
- assertTrue (! applyAction .isEnabled ());
121
- DockingActionIf deleteAction = getAction ( plugin , "Delete Enum Value" );
122
- assertTrue (! deleteAction .isEnabled ());
118
+ DockingActionIf applyAction = getApplyAction ( );
119
+ assertFalse ( applyAction .isEnabled ());
120
+ DockingActionIf deleteAction = getDeleteAction ( );
121
+ assertFalse ( deleteAction .isEnabled ());
123
122
124
123
// sort column should be on the value column
125
124
JTable table = (JTable ) findContainer (panel , JTable .class );
@@ -130,8 +129,8 @@ public void testEnumFields() throws Exception {
130
129
@ Test
131
130
public void testEnumSize1 () throws Exception {
132
131
Category category = program .getListing ()
133
- .getDataTypeManager ()
134
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
132
+ .getDataTypeManager ()
133
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
135
134
Enum enumm = createEnum (category , "TestEnum" , 1 );
136
135
edit (enumm );
137
136
@@ -141,7 +140,7 @@ public void testEnumSize1() throws Exception {
141
140
addEnumValue ();
142
141
143
142
waitForSwing ();
144
- DockingActionIf applyAction = getAction ( plugin , "Apply Enum Changes" );
143
+ DockingActionIf applyAction = getApplyAction ( );
145
144
assertTrue (applyAction .isEnabled ());
146
145
assertTrue (panel .needsSave ());
147
146
@@ -181,8 +180,8 @@ public void testEnumSize1() throws Exception {
181
180
public void testEnumSize1BadInput () throws Exception {
182
181
// test entering too large a value
183
182
Category category = program .getListing ()
184
- .getDataTypeManager ()
185
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
183
+ .getDataTypeManager ()
184
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
186
185
Enum enumm = createEnum (category , "TestEnum" , 1 );
187
186
edit (enumm );
188
187
@@ -192,7 +191,7 @@ public void testEnumSize1BadInput() throws Exception {
192
191
addEnumValue ();
193
192
194
193
waitForSwing ();
195
- DockingActionIf applyAction = getAction ( plugin , "Apply Enum Changes" );
194
+ DockingActionIf applyAction = getApplyAction ( );
196
195
assertTrue (applyAction .isEnabled ());
197
196
assertTrue (panel .needsSave ());
198
197
@@ -224,8 +223,8 @@ public void testEnumSize1BadInput() throws Exception {
224
223
@ Test
225
224
public void testEnumSize4BadInput () throws Exception {
226
225
Category category = program .getListing ()
227
- .getDataTypeManager ()
228
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
226
+ .getDataTypeManager ()
227
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
229
228
Enum enumm = createEnum (category , "MyTestEnum" , 4 );
230
229
edit (enumm );
231
230
@@ -243,12 +242,12 @@ public void testEnumSize4BadInput() throws Exception {
243
242
244
243
addEnumValue ();
245
244
waitForSwing ();
246
- DockingActionIf applyAction = getAction ( plugin , "Apply Enum Changes" );
245
+ DockingActionIf applyAction = getApplyAction ( );
247
246
assertTrue (applyAction .isEnabled ());
248
247
assertTrue (panel .needsSave ());
249
248
250
- final JTable table = panel .getTable ();
251
- final EnumTableModel model = (EnumTableModel ) table .getModel ();
249
+ JTable table = panel .getTable ();
250
+ EnumTableModel model = (EnumTableModel ) table .getModel ();
252
251
253
252
assertEquals ("New_Name" , model .getValueAt (0 , NAME_COL ));
254
253
assertEquals (0L , model .getValueAt (0 , VALUE_COL ));
@@ -275,14 +274,14 @@ public void testEnumSize4BadInput() throws Exception {
275
274
@ Test
276
275
public void testBadInputForValue () throws Exception {
277
276
Category cat = program .getListing ()
278
- .getDataTypeManager ()
279
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
277
+ .getDataTypeManager ()
278
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
280
279
Enum enumm = createEnum (cat , "TestEnum" , 1 );
281
280
edit (enumm );
282
281
283
282
EnumEditorPanel panel = findEditorPanel (tool .getToolFrame ());
284
- final JTable table = panel .getTable ();
285
- final EnumTableModel model = (EnumTableModel ) table .getModel ();
283
+ JTable table = panel .getTable ();
284
+ EnumTableModel model = (EnumTableModel ) table .getModel ();
286
285
287
286
addEnumValue ();
288
287
waitForSwing ();
@@ -304,8 +303,8 @@ public void testBadInputForValue() throws Exception {
304
303
public void testEditExistingEnum1 () throws Exception {
305
304
306
305
Category cat = program .getListing ()
307
- .getDataTypeManager ()
308
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
306
+ .getDataTypeManager ()
307
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
309
308
final Enum enumm = new EnumDataType ("Colors" , 1 );
310
309
enumm .add ("Red" , 0 );
311
310
enumm .add ("Green" , 1 );
@@ -368,8 +367,8 @@ public void testEditExistingEnum2() throws Exception {
368
367
@ Test
369
368
public void testValueForNewEntry () throws Exception {
370
369
Category cat = program .getListing ()
371
- .getDataTypeManager ()
372
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
370
+ .getDataTypeManager ()
371
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
373
372
final Enum enumm = new EnumDataType ("Colors" , 1 );
374
373
enumm .add ("Red" , 0x10 );
375
374
enumm .add ("Green" , 0x20 );
@@ -389,7 +388,7 @@ public void testValueForNewEntry() throws Exception {
389
388
runSwing (() -> {
390
389
int lastRow = model .getRowCount () - 1 ;
391
390
table .addRowSelectionInterval (lastRow , lastRow );
392
- DockingActionIf addAction = getAction ( plugin , "Add Enum Value" );
391
+ DockingActionIf addAction = getAddAction ( );
393
392
addAction .actionPerformed (new DefaultActionContext ());
394
393
});
395
394
waitForSwing ();
@@ -762,12 +761,11 @@ public void testNewEnumFromAction() throws Exception {
762
761
public void testChangeEnumSizeAndInStructure () throws Exception {
763
762
764
763
Category category = program .getListing ()
765
- .getDataTypeManager ()
766
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
764
+ .getDataTypeManager ()
765
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
767
766
Enum enumm = createEnum (category , "EnumX" , 2 );
768
767
769
- int transactionID = program .startTransaction ("Test" );
770
- try {
768
+ tx (program , () -> {
771
769
enumm .add ("Zero" , 0 );
772
770
enumm .add ("One" , 1 );
773
771
@@ -783,10 +781,7 @@ public void testChangeEnumSizeAndInStructure() throws Exception {
783
781
structY .add (new ByteDataType ());
784
782
structY .add (enumm );
785
783
category .addDataType (structY , DataTypeConflictHandler .DEFAULT_HANDLER );
786
- }
787
- finally {
788
- program .endTransaction (transactionID , true );
789
- }
784
+ });
790
785
791
786
edit (enumm );
792
787
@@ -832,12 +827,11 @@ public void testChangeEnumSizeAndInStructure() throws Exception {
832
827
public void testChangeEnumDescriptionEtcAndInStructure () throws Exception {
833
828
834
829
Category category = program .getListing ()
835
- .getDataTypeManager ()
836
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
830
+ .getDataTypeManager ()
831
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
837
832
Enum enumm = createEnum (category , "EnumX" , 2 );
838
833
839
- int transactionID = program .startTransaction ("Test" );
840
- try {
834
+ tx (program , () -> {
841
835
enumm .add ("Zero" , 0 );
842
836
enumm .add ("One" , 1 );
843
837
enumm .setDescription ("ABCD" );
@@ -854,10 +848,7 @@ public void testChangeEnumDescriptionEtcAndInStructure() throws Exception {
854
848
structY .add (new ByteDataType ());
855
849
structY .add (enumm );
856
850
category .addDataType (structY , DataTypeConflictHandler .DEFAULT_HANDLER );
857
- }
858
- finally {
859
- program .endTransaction (transactionID , true );
860
- }
851
+ });
861
852
862
853
edit (enumm );
863
854
@@ -1140,8 +1131,8 @@ private Pair<Integer, Integer> getEditingCell(final JTable table) {
1140
1131
1141
1132
private Enum createRedGreenBlueEnum () {
1142
1133
Category cat = program .getListing ()
1143
- .getDataTypeManager ()
1144
- .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
1134
+ .getDataTypeManager ()
1135
+ .getCategory (new CategoryPath (CategoryPath .ROOT , "Category1" ));
1145
1136
final Enum enumm = new EnumDataType ("Colors" , 1 );
1146
1137
enumm .add ("Red" , 0 );
1147
1138
enumm .add ("Green" , 1 );
@@ -1165,7 +1156,7 @@ private void edit(final Enum enummDt) {
1165
1156
1166
1157
private void apply () {
1167
1158
runSwing (() -> {
1168
- DockingActionIf applyAction = getAction ( plugin , "Apply Enum Changes" );
1159
+ DockingActionIf applyAction = getApplyAction ( );
1169
1160
applyAction .actionPerformed (new DefaultActionContext ());
1170
1161
}, false );
1171
1162
program .flushEvents ();
@@ -1290,12 +1281,10 @@ private void doTestFieldChangedWithWarning(boolean alsoRemove) throws Exception
1290
1281
}
1291
1282
1292
1283
private void editValueInTable (int row , String newValue ) {
1293
-
1294
1284
editCellInTable (row , VALUE_COL , newValue );
1295
1285
}
1296
1286
1297
1287
private void editNameInTable (int row , String newValue ) {
1298
-
1299
1288
editCellInTable (row , NAME_COL , newValue );
1300
1289
}
1301
1290
@@ -1331,11 +1320,23 @@ private void createEquate(String name) throws Exception {
1331
1320
1332
1321
private void addEnumValue () {
1333
1322
runSwing (() -> {
1334
- DockingActionIf addAction = getAction ( plugin , "Add Enum Value" );
1323
+ DockingActionIf addAction = getAddAction ( );
1335
1324
addAction .actionPerformed (new DefaultActionContext ());
1336
1325
});
1337
1326
}
1338
1327
1328
+ private DockingActionIf getAddAction () {
1329
+ return getAction (plugin , DataTypeEditorManager .EDIT_ACTION_PREFIX + "Add Enum Value" );
1330
+ }
1331
+
1332
+ private DockingActionIf getApplyAction () {
1333
+ return getAction (plugin , DataTypeEditorManager .EDIT_ACTION_PREFIX + "Apply Enum Changes" );
1334
+ }
1335
+
1336
+ private DockingActionIf getDeleteAction () {
1337
+ return getAction (plugin , DataTypeEditorManager .EDIT_ACTION_PREFIX + "Delete Enum Value" );
1338
+ }
1339
+
1339
1340
private int getRowFor (String theName ) {
1340
1341
1341
1342
JTable table = getEditTable ();
0 commit comments