|
@@ -166,6 +166,11 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
|
166
|
166
|
for (final ActionType localTrigger : triggers) {
|
167
|
167
|
triggerList.addTrigger(localTrigger);
|
168
|
168
|
}
|
|
169
|
+
|
|
170
|
+ if (triggers.length > 0) {
|
|
171
|
+ addCompatible(triggers[0]);
|
|
172
|
+ setEnabled(true);
|
|
173
|
+ }
|
169
|
174
|
}
|
170
|
175
|
|
171
|
176
|
/**
|
|
@@ -224,32 +229,37 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
|
224
|
229
|
* @param primaryType Primary type
|
225
|
230
|
*/
|
226
|
231
|
private void addCompatible(final ActionType primaryType) {
|
|
232
|
+ final DefaultComboBoxModel groupModel = (DefaultComboBoxModel) triggerGroup.getModel();
|
|
233
|
+ final DefaultComboBoxModel itemModel = (DefaultComboBoxModel) triggerItem.getModel();
|
|
234
|
+
|
227
|
235
|
comboChange = true;
|
228
|
|
- compatibleTriggers.addAll(ActionManager.getActionManager()
|
229
|
|
- .findCompatibleTypes(primaryType));
|
230
|
|
- ((DefaultComboBoxModel) triggerGroup.getModel()).removeAllElements();
|
231
|
|
- ((DefaultComboBoxModel) triggerItem.getModel()).removeAllElements();
|
232
|
|
- for (final ActionType thisType : compatibleTriggers) {
|
233
|
|
- final List<ActionType> types = triggerList.getTriggers();
|
|
236
|
+ compatibleTriggers.clear();
|
|
237
|
+ groupModel.removeAllElements();
|
|
238
|
+ itemModel.removeAllElements();
|
|
239
|
+ final List<ActionType> types = triggerList.getTriggers();
|
|
240
|
+
|
|
241
|
+ for (final ActionType thisType : ActionManager.getActionManager().findCompatibleTypes(primaryType)) {
|
234
|
242
|
if (!types.contains(thisType)) {
|
235
|
|
- ((DefaultComboBoxModel) triggerItem.getModel())
|
236
|
|
- .addElement(thisType);
|
237
|
|
- if (((DefaultComboBoxModel) triggerGroup.getModel())
|
238
|
|
- .getIndexOf(thisType.getType().getGroup()) == -1) {
|
239
|
|
- ((DefaultComboBoxModel) triggerGroup.getModel())
|
240
|
|
- .addElement(thisType.getType().getGroup());
|
|
243
|
+ compatibleTriggers.add(thisType);
|
|
244
|
+ itemModel.addElement(thisType);
|
|
245
|
+ if (groupModel.getIndexOf(thisType.getType().getGroup()) == -1) {
|
|
246
|
+ groupModel.addElement(thisType.getType().getGroup());
|
241
|
247
|
}
|
242
|
248
|
}
|
243
|
249
|
}
|
244
|
250
|
triggerGroup.setSelectedIndex(-1);
|
245
|
251
|
triggerItem.setSelectedIndex(-1);
|
246
|
|
- if (triggerItem.getModel().getSize() == 0) {
|
247
|
|
- ((DefaultComboBoxModel) triggerGroup.getModel())
|
248
|
|
- .removeAllElements();
|
|
252
|
+ if (itemModel.getSize() == 0) {
|
|
253
|
+ groupModel.removeAllElements();
|
249
|
254
|
}
|
250
|
|
- triggerGroup.setEnabled(triggerGroup.getModel().getSize() > 0);
|
251
|
|
- triggerItem.setEnabled(triggerItem.getModel().getSize() > 0);
|
|
255
|
+ triggerGroup.setEnabled(groupModel.getSize() > 0);
|
|
256
|
+ if (groupModel.getSize() == 1) {
|
|
257
|
+ triggerGroup.setSelectedIndex(0);
|
|
258
|
+ }
|
|
259
|
+
|
|
260
|
+ triggerItem.setEnabled(itemModel.getSize() > 0);
|
252
|
261
|
triggerItem.setEnabled(triggerGroup.getSelectedIndex() != -1);
|
|
262
|
+
|
253
|
263
|
comboChange = false;
|
254
|
264
|
}
|
255
|
265
|
|