-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProperties.java
More file actions
executable file
·2129 lines (1870 loc) · 68.6 KB
/
Copy pathProperties.java
File metadata and controls
executable file
·2129 lines (1870 loc) · 68.6 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.LinkedList;
import java.util.Vector;
import javax.swing.border.LineBorder;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.AbstractCellEditor;
//Written by: Michael Zimmer - mike@zimmerdesignservices.com
/*
Copyright 2007 Zimmer Design Services
This file is part of Fizzim.
Fizzim is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Fizzim is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class MyTableModel extends AbstractTableModel {
boolean DEBUG = false;
// pz
// String[] columnNames = {"Attribute Name", "Value",
// "Visibility", "Type", "Comment", "Color" };
String[] columnNames = {"Attribute Name", "Value",
"Visibility", "Type", "Comment",
"Color","UserAtts","ResetValue" }; // for state/trans edit boxes
boolean global = false;
GeneralObj obj;
LinkedList<ObjAttribute> attrib;
LinkedList<LinkedList<ObjAttribute>> globalList;
JDialog dialog;
int tab;
MyTableModel(GeneralObj s,JDialog dia,LinkedList<LinkedList<ObjAttribute>> global, int k)
{
obj = s;
attrib = obj.getAttributeList();
globalList = global;
dialog = dia;
tab = k;
}
MyTableModel(LinkedList<ObjAttribute> list,LinkedList<LinkedList<ObjAttribute>> globalL)
{
global = true;
globalList = globalL;
attrib = list;
// pz
// columnNames = new String[] {"Attribute Name", "Default Value",
// "Visibility", "Type","Comment", "Color"};
columnNames = new String[] {"Attribute Name", "Default Value",
"Visibility", "Type","Comment",
"Color","UserAtts","ResetValue"}; // for main att edit boxes
}
//methods that need to be implemented
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return attrib.size();
}
public Object getValueAt(int row, int col) {
Object obj = attrib.get(row).get(col);
if(col == 2) //pz - transition?
{
if(obj.equals(new Integer(0)))
obj = "No";
if(obj.equals(new Integer(1)))
obj = "Yes";
if(obj.equals(new Integer(2)))
obj = "Only non-default";
}
// Translate internal representation "reg" to "statebit"
if(col == 3)
{
if(obj.equals(new String("reg")))
obj = "statebit";
}
return obj;
}
// get type for column
public Class getColumnClass(int col) {
return getValueAt(0, col).getClass();
}
public String getColumnName(int col) {
return columnNames[col];
}
//GLOBAL_FIXED can only be edited in global tab, ABS can't be edited anywhere
public boolean isCellEditable(int row, int col) {
if ((attrib.get(row).getEditable(col) == ObjAttribute.GLOBAL_FIXED && !global) || attrib.get(row).getEditable(col) == ObjAttribute.ABS)
return false;
else if(global && attrib.equals(globalList.get(1)) && (col == 2 || col == 5))
return false;
else
return true;
}
public void setValueAt(Object value, int row, int col) {
// 0: Name
// 1: (Default) value
// 2: Visibility
// 3: Type
// 4: Comment
// 5: Color
// 6: UserAtts
// 7: Resetval
//turn string into corresponding number
if(col == 2)
{
if(value.equals("No"))
value = new Integer(0);
if(value.equals("Yes"))
value = new Integer(1);
if(value.equals("Only non-default"))
value = new Integer(2);
}
// Translate "statebit" to internal representation "reg"
if (col == 3 && value.equals("statebit")) {
value = new String("reg");
}
// check for reserved words
// Not sure if this is really necessary
/*
if ( col == 1 &&
( false
|| value.equals("output")
)) {
JOptionPane.showMessageDialog(dialog,
"\"" + value + "\"" + " is a reserved word",
"error",
JOptionPane.ERROR_MESSAGE);
value = attrib.get(row).get(col);
}
*/
// only flag, regd can have reset values
if ( false
|| (global && col == 7 && !value.equals("") && !((attrib.get(row).getType().equals("flag") || attrib.get(row).getType().equals("regdp"))) )
|| (global && col == 3 && !(value.equals("flag")|| value.equals("regdp")) && !attrib.get(row).getresetval().equals("") )
)
{
JOptionPane.showMessageDialog(dialog,
"Only regdp and flag can have a reset value",
"error",
JOptionPane.ERROR_MESSAGE);
value = attrib.get(row).get(col);
}
// flag type outputs must have null default value
if ( false
|| (global && col == 1 && !value.equals("") && attrib.get(row).getType().equals("flag") )
|| (global && col == 3 && value.equals("flag") && !attrib.get(row).getValue().equals("") )
)
{
JOptionPane.showMessageDialog(dialog,
"Flags cannot have default values",
"error",
JOptionPane.ERROR_MESSAGE);
value = attrib.get(row).get(col);
}
// forces user to enter attribute name in outputs tab
if(!global && col == 3 && value.equals("output"))
{
if(!checkOutputs(attrib.get(row)))
{
value = "";
JOptionPane.showMessageDialog(dialog,
"Attribute with that name must exist in global outputs tab",
"error",
JOptionPane.ERROR_MESSAGE);
}
}
//first time type being set in outputs, create corresponding attribute in state tab
if(global && col == 3 && attrib.equals(globalList.get(2)) && (value.equals("regdp") || value.equals("comb") || value.equals("reg") || value.equals("flag"))
&& attrib.get(row).get(col).equals(""))
{
int[] editable = { ObjAttribute.GLOBAL_FIXED, ObjAttribute.GLOBAL_VAR,
ObjAttribute.GLOBAL_VAR, ObjAttribute.GLOBAL_VAR, ObjAttribute.GLOBAL_VAR, ObjAttribute.GLOBAL_VAR, ObjAttribute.GLOBAL_VAR, ObjAttribute.GLOBAL_VAR};
ObjAttribute newObj = new ObjAttribute(attrib.get(row).getName(),attrib.get(row).getValue(),
attrib.get(row).getVisibility(),"output","",Color.black,"","",editable);
globalList.get(3).addLast(newObj);
}
//if rename something of type output
if(global && col != 3 && globalList.get(2).equals(attrib) && !attrib.get(row).get(col).equals(value))
{
renameAttribute(3,attrib.get(row).getName(),col,value,row);
}
//force user to edit in outputs tab
// changed
if(global &&
// can't edit anything but type in states
(col != 3 && attrib.equals(globalList.get(3)) && attrib.get(row).getType().equals("output"))
// can't edit default value in transitions
// new fizzim.pl (>=4.3 uses default from outputs page)
|| (col == 1 && attrib.equals(globalList.get(4)) && attrib.get(row).getType().equals("output"))
)
{
JOptionPane.showMessageDialog(dialog,
"Must edit in output tab",
"error",
JOptionPane.ERROR_MESSAGE);
value = attrib.get(row).get(col);
}
//if changing from comb to reg
/*
if(attrib.equals(globalList.get(4)) && attrib.get(row).getType().equals("comb") && value.equals("reg"))
{
for(int i = 0; i < globalList.get(2).size(); i++)
{
if(attrib.get(row).getName().equals(globalList.get(2).get(i).getName()))
{
globalList.get(2).remove(i);
}
}
}
*/
// dont set if nothing changes
if(!attrib.get(row).get(col).equals(value))
attrib.get(row).set(col,value);
// set to local if different from global
if(!global)
{
if(!checkValue(row,col,value))
{
attrib.get(row).setEditable(col, ObjAttribute.LOCAL);
}
else
attrib.get(row).setEditable(col, ObjAttribute.GLOBAL_VAR);
}
// checks for when name being changed
if(attrib.get(row).getName().equals("name") && col == 1 && !global)
obj.setName((String) value);
//restore to default if empty string was entered
if(col != 2 && value.equals("") && !global)
{
obj.updateAttrib(globalList,tab);
}
fireTableCellUpdated(row, col);
}
private boolean checkValue(int row, int col, Object value)
{
LinkedList<ObjAttribute> list = globalList.get(tab);
String name = attrib.get(row).getName();
Object val = attrib.get(row).get(col);
for (int i = 0; i < list.size(); i++)
{
ObjAttribute obj = list.get(i);
if(name.equals(obj.getName()) && val.equals(obj.get(col)))
return true;
}
return false;
}
private void renameAttribute(int t, String name, int col, Object value, int row) {
// try to find cooresponding field in states tab that is in the same relative position
// (fixes errors due to multiple fields with same names)
int num = 0;
boolean needed = true;
for(int h = 0; h < globalList.get(t).size(); h++)
{
ObjAttribute obj = globalList.get(t).get(h);
// check if field is of type output in state tab
if(obj.getType().equals("output") && t == 3 && num <= row)
{
if(num == row && obj.getName().equals(name))
{
obj.set(col, value);
needed = false;
break;
}
else
num++;
}
}
if(needed)
{
for(int i = 0; i < globalList.get(t).size(); i++)
{
ObjAttribute obj = globalList.get(t).get(i);
if(obj.getName().equals(name))
{
obj.set(col, value);
break;
}
}
}
}
private boolean checkOutputs(ObjAttribute objAttribute) {
LinkedList<ObjAttribute> outputList = globalList.get(2);
String name = objAttribute.getName();
for(int i = 0; i < outputList.size(); i++)
{
ObjAttribute obj = outputList.get(i);
if(obj.getName().equals(name))
return true;
}
return false;
}
private boolean checkName(LinkedList<ObjAttribute> linkedList, String name) {
for(int i = 0; i < linkedList.size(); i++)
{
ObjAttribute obj = linkedList.get(i);
if(obj.getName().equals(name))
return true;
}
return false;
}
}
class MyJColorRenderer extends JLabel implements TableCellRenderer {
public MyJColorRenderer() {
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable arg0, Object arg1,
boolean arg2, boolean arg3, int arg4, int arg5) {
Color newColor = (Color)arg1;
setBackground(newColor);
return this;
}
}
// http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
class MyJColorEditor extends AbstractCellEditor implements ActionListener, TableCellEditor {
Color currColor;
JButton button;
JColorChooser colorChooser;
JDialog dialog;
public MyJColorEditor(JColorChooser c)
{
button = new JButton();
button.setActionCommand("edit");
button.addActionListener(this);
button.setBorderPainted(false);
colorChooser = new JColorChooser();
dialog = JColorChooser.createDialog(button,
"Pick a Color",
true, //modal
colorChooser,
this, //OK button handler
null); //no CANCEL button handler
}
public Object getCellEditorValue() {
return currColor;
}
public void actionPerformed(ActionEvent e) {
if ("edit".equals(e.getActionCommand())) {
button.setBackground(currColor);
colorChooser.setColor(currColor);
dialog.setVisible(true);
//Make the renderer reappear.
fireEditingStopped();
} else { //User pressed dialog's "OK" button.
currColor = colorChooser.getColor();
}
}
public Component getTableCellEditorComponent(JTable arg0, Object arg1,
boolean arg2, int arg3, int arg4) {
currColor = (Color)arg1;
return button;
}
}
class MyJComboBoxEditor extends DefaultCellEditor {
public MyJComboBoxEditor(String[] items) {
super(new JComboBox(items));
}
}
class TransProperties extends javax.swing.JDialog {
TransitionObj trans;
DrawArea drawArea;
StateObj start;
StateObj end;
StateObj pref;
Vector<StateObj> stateObjs;
boolean loopback = false;
boolean stub = false;
LinkedList<LinkedList<ObjAttribute>> globalList;
Component window = this;
JColorChooser colorChooser;
/** Creates new form TransP */
public TransProperties(DrawArea DA,java.awt.Frame parent, boolean modal, TransitionObj t, Vector<StateObj> states,boolean b,StateObj state) {
super(parent, modal);
trans = t;
drawArea = DA;
stateObjs = states;
loopback = b;
pref = state;
globalList = drawArea.getGlobalList();
colorChooser = drawArea.getColorChooser();
if(trans.getType() == 1)
{
StateTransitionObj t1 = (StateTransitionObj) t;
stub = t1.getStub();
}
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
TPLabel = new javax.swing.JLabel();
TPScroll = new javax.swing.JScrollPane();
TPTable = new javax.swing.JTable();
TPNew = new javax.swing.JButton();
TPDelete = new javax.swing.JButton();
TPCancel = new javax.swing.JButton();
TPOK = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jCheckBox1 = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
if(!loopback)
{
setTitle("Edit State Transition Properties");
TPLabel.setText("Edit the properties of the selected state transition:");
}
else
{
setTitle("Edit Loopback Transition Properties");
TPLabel.setText("Edit the properties of the selected loopback transition:");
}
TPTable.setModel(new MyTableModel(trans,this,globalList,4));
TPTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
//use dropdown boxes
String[] options = new String[]{"No", "Yes", "Only non-default"};
TableColumn column = TPTable.getColumnModel().getColumn(2);
column.setCellEditor(new MyJComboBoxEditor(options));
column = TPTable.getColumnModel().getColumn(5);
column.setPreferredWidth(TPTable.getRowHeight());
column.setCellEditor(new MyJColorEditor(colorChooser));
column.setCellRenderer(new MyJColorRenderer());
TPNew.setVisible(false);
TPDelete.setVisible(false);
TPScroll.setViewportView(TPTable);
TPNew.setText("New");
TPNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TPNewActionPerformed(evt);
}
});
TPDelete.setText("Delete");
TPDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TPDeleteActionPerformed(evt);
}
});
TPCancel.setText("Cancel");
TPCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TPCancelActionPerformed(evt);
}
});
TPOK.setText("OK");
TPOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TPOKActionPerformed(evt);
}
});
if(!loopback)
{
jLabel1.setText("Start State:");
jLabel2.setText("End State:");
}
else
{
jLabel1.setText("State:");
jLabel2.setVisible(false);
jCheckBox1.setVisible(false);
}
jLabel3.setPreferredSize(new Dimension(50,20));
jLabel3.setMinimumSize(new Dimension(50,20));
jLabel3.setOpaque(true);
jLabel3.setVisible(true);
//set background color to color of transition and add action listener
jLabel3.setBackground(trans.getColor());
jLabel3.setBorder(new LineBorder(Color.black, 1));
jLabel3.addMouseListener(new MouseListener() {
ActionListener colorSel = new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
jLabel3.setBackground(colorChooser.getColor());
trans.setColor(colorChooser.getColor());
}
};
public void mouseClicked(MouseEvent e)
{
JDialog dialog;
dialog = JColorChooser.createDialog(window, "Choose Color", true, colorChooser, colorSel, null);
dialog.setVisible(true);
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
});
int size = stateObjs.size();
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(stateObjs));
if(trans.getStartState() == null)
{
if(!loopback)
{
jComboBox1.setSelectedIndex(size-2);
start = stateObjs.get(size-2);
}
else
{
if(pref == null)
{
jComboBox1.setSelectedIndex(size-1);
start = stateObjs.get(size-1);
}
else
{
int index = 0;
for(int i = 0; i < stateObjs.size(); i++)
{
if(stateObjs.get(i).equals(pref))
{
index = i;
break;
}
}
jComboBox1.setSelectedIndex(index);
start = pref;
}
}
}
else
{
start = trans.getStartState();
jComboBox1.setSelectedIndex(stateObjs.indexOf(start));
}
if(!loopback)
{
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(stateObjs));
if(trans.getEndState() == null)
{
jComboBox2.setSelectedIndex(size-1);
end = stateObjs.get(size-1);
}
else
{
end = trans.getEndState();
jComboBox2.setSelectedIndex(stateObjs.indexOf(end));
}
}
else
jComboBox2.setVisible(false);
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
StartStateActionPerformed(evt);
}
});
if(!loopback)
{
jComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EndStateActionPerformed(evt);
}
});
}
if(!loopback)
{
jCheckBox1.setText("Stub?");
jCheckBox1.setSelected(stub);
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0,
0, 0));
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
}
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.addContainerGap()
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
TPScroll,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
480,
Short.MAX_VALUE)
.add(TPLabel)
.add(
layout
.createSequentialGroup()
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.TRAILING,
false)
.add(
layout
.createSequentialGroup()
.add(
jLabel2)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(
jComboBox2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(
org.jdesktop.layout.GroupLayout.LEADING,
layout
.createSequentialGroup()
.add(
jLabel1)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(
jComboBox1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(
org.jdesktop.layout.GroupLayout.LEADING,
layout
.createSequentialGroup()
.add(
TPNew)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
TPDelete)))
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.add(
240,
240,
240)
.add(
TPOK)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
TPCancel))
.add(
layout
.createSequentialGroup()
.add(
42,
42,
42)
.add(
jLabel3))
.add(
layout
.createSequentialGroup()
.add(
42,
42,
42)
.add(
jCheckBox1)))))
.addContainerGap()));
layout
.setVerticalGroup(layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.addContainerGap()
.add(TPLabel)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
TPScroll,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
151,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(TPNew).add(
TPDelete))
.add(22, 22, 22)
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(
jComboBox1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3)
)
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
layout
.createSequentialGroup()
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED,
11,
Short.MAX_VALUE)
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(
TPCancel)
.add(
TPOK))
.addContainerGap())
.add(
layout
.createSequentialGroup()
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(
jLabel2)
.add(
jComboBox2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jCheckBox1))
.addContainerGap()))));
pack();
}// </editor-fold>//GEN-END:initComponents
private void StartStateActionPerformed(ActionEvent evt) {
JComboBox cb = (JComboBox)evt.getSource();
StateObj selState = (StateObj)cb.getSelectedItem();
start = selState;
}
private void EndStateActionPerformed(ActionEvent evt) {
JComboBox cb = (JComboBox)evt.getSource();
StateObj selState = (StateObj)cb.getSelectedItem();
end = selState;
}
//GEN-FIRST:event_TPCancelActionPerformed
private void TPCancelActionPerformed(java.awt.event.ActionEvent evt) {
drawArea.cancel();
dispose();
}//GEN-LAST:event_TPCancelActionPerformed
//GEN-FIRST:event_TPOKActionPerformed
private void TPOKActionPerformed(java.awt.event.ActionEvent evt) {
TPTable.editCellAt(0,0);
if(drawArea.checkTransNames())
{
if(!loopback)
{
if(start != end)
trans.initTrans(start,end);
boolean b = jCheckBox1.isSelected();
if(b != stub)
{
if(trans.getType() == 1)
{
StateTransitionObj t1 = (StateTransitionObj) trans;
t1.setStub(b);
}
}
if(start != end)
{
drawArea.commitUndo();
dispose();
}
else
{
JOptionPane.showMessageDialog(this,
"'Start State' and 'End State' must be different.",
"error",
JOptionPane.ERROR_MESSAGE);
}
}
else
{
trans.initTrans(start);
drawArea.commitUndo();
dispose();
}
}
else
{
JOptionPane.showMessageDialog(this,
"Two different transitions cannot have the same name.",
"error",
JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_TPOKActionPerformed
//GEN-FIRST:event_TPDeleteActionPerformed
private void TPDeleteActionPerformed(java.awt.event.ActionEvent evt) {
// delete selected rows
int[] rows = TPTable.getSelectedRows();
for(int i = rows.length - 1; i > -1; i--)
{
int type = trans.getAttributeList().get(rows[i]).getEditable(0);
if(type != ObjAttribute.GLOBAL_FIXED && type != ObjAttribute.ABS)
{
trans.getAttributeList().remove(rows[i]);
TPTable.revalidate();
}
else
{
JOptionPane.showMessageDialog(this,
"Cannot delete a global attribute.\n"
+ "Must be removed from global attribute properties.",
"error",
JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_TPDeleteActionPerformed
//GEN-FIRST:event_TPNewActionPerformed
private void TPNewActionPerformed(java.awt.event.ActionEvent evt) {
ObjAttribute newObj = new ObjAttribute("","",ObjAttribute.NO,"","",Color.black,"","");
trans.getAttributeList().addLast(newObj);
TPTable.revalidate();
}//GEN-LAST:event_TPNewActionPerformed
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton TPCancel;
private javax.swing.JButton TPDelete;
private javax.swing.JLabel TPLabel;
private javax.swing.JButton TPNew;