Merge lp:~yrke/tapaal/evenMore-gui-cleanup into lp:tapaal
- evenMore-gui-cleanup
- Merge into trunk
Status: | Merged | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Jiri Srba | ||||||||||||||||||||||||
Approved revision: | 1152 | ||||||||||||||||||||||||
Merged at revision: | 1078 | ||||||||||||||||||||||||
Proposed branch: | lp:~yrke/tapaal/evenMore-gui-cleanup | ||||||||||||||||||||||||
Merge into: | lp:tapaal | ||||||||||||||||||||||||
Diff against target: |
5542 lines (+1201/-1407) 106 files modified
build.gradle (+1/-0) src/dk/aau/cs/approximation/OverApproximation.java (+2/-2) src/dk/aau/cs/approximation/UnderApproximation.java (+3/-3) src/dk/aau/cs/debug/Logger.java (+6/-2) src/dk/aau/cs/gui/BatchProcessingDialog.java (+8/-8) src/dk/aau/cs/gui/DeleteSharedPlaceOrTransition.java (+27/-19) src/dk/aau/cs/gui/FileNameCellRenderer.java (+1/-1) src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java (+26/-23) src/dk/aau/cs/gui/TabContent.java (+488/-438) src/dk/aau/cs/gui/TabTransformer.java (+2/-2) src/dk/aau/cs/gui/TemplateExplorer.java (+0/-1) src/dk/aau/cs/gui/components/ConstantsListModel.java (+1/-1) src/dk/aau/cs/gui/components/EnabledTransitionsList.java (+4/-11) src/dk/aau/cs/gui/components/NonsearchableJComboBox.java (+1/-1) src/dk/aau/cs/gui/components/StatisticsPanel.java (+0/-1) src/dk/aau/cs/gui/undo/AddFileBatchProcessingCommand.java (+3/-4) src/dk/aau/cs/gui/undo/MoveElementDownCommand.java (+4/-7) src/dk/aau/cs/gui/undo/MoveElementUpCommand.java (+4/-7) src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java (+9/-13) src/dk/aau/cs/gui/undo/RemoveFileBatchProcessingCommand.java (+2/-4) src/dk/aau/cs/gui/undo/SortConstantsCommand.java (+2/-2) src/dk/aau/cs/gui/undo/SortQueriesCommand.java (+1/-1) src/dk/aau/cs/gui/undo/SortSharedPlacesCommand.java (+1/-1) src/dk/aau/cs/gui/undo/SortSharedTransitionsCommand.java (+1/-1) src/dk/aau/cs/gui/undo/SortTemplatesCommand.java (+4/-4) src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java (+5/-2) src/dk/aau/cs/io/LoadedModel.java (+6/-6) src/dk/aau/cs/io/PNMLoader.java (+3/-4) src/dk/aau/cs/io/TapnLegacyXmlLoader.java (+59/-68) src/dk/aau/cs/io/TapnXmlLoader.java (+2/-4) src/dk/aau/cs/io/TraceImportExport.java (+0/-1) src/dk/aau/cs/model/NTA/trace/UppaalTrace.java (+3/-1) src/dk/aau/cs/model/tapn/ConstantStore.java (+2/-2) src/dk/aau/cs/model/tapn/LocalTimedMarking.java (+0/-1) src/dk/aau/cs/model/tapn/NetworkMarking.java (+0/-1) src/dk/aau/cs/model/tapn/TimeInterval.java (+3/-4) src/dk/aau/cs/model/tapn/TimedArcPetriNet.java (+4/-4) src/dk/aau/cs/model/tapn/TimedInputArc.java (+3/-3) src/dk/aau/cs/model/tapn/TransportArc.java (+3/-3) src/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java (+1/-1) src/dk/aau/cs/model/tapn/simulation/RandomDelayMode.java (+2/-2) src/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java (+1/-1) src/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java (+2/-1) src/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java (+2/-1) src/dk/aau/cs/model/tapn/simulation/UntimedTAPNNetworkTrace.java (+3/-1) src/dk/aau/cs/translations/tapn/BroadcastTranslation.java (+3/-3) src/dk/aau/cs/translations/tapn/CombiTranslation.java (+3/-3) src/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java (+3/-3) src/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java (+3/-3) src/dk/aau/cs/translations/tapn/StandardTranslation.java (+3/-3) src/dk/aau/cs/util/IntervalOperations.java (+11/-11) src/dk/aau/cs/util/MemoryMonitor.java (+12/-33) src/dk/aau/cs/verification/TAPNComposer.java (+4/-4) src/dk/aau/cs/verification/VerificationResult.java (+1/-1) src/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java (+8/-3) src/net/tapaal/resourcemanager/ResourceManager.java (+0/-2) src/net/tapaal/swinghelpers/ExtendedJTabbedPane.java (+6/-2) src/net/tapaal/swinghelpers/GridBagHelper.java (+82/-0) src/pipe/dataLayer/Template.java (+0/-1) src/pipe/gui/AnimationControlSidePanel.java (+1/-1) src/pipe/gui/AnimationSettingsDialog.java (+0/-2) src/pipe/gui/Animator.java (+1/-1) src/pipe/gui/CreateGui.java (+28/-10) src/pipe/gui/DelayEnabledTransitionControl.java (+1/-6) src/pipe/gui/ExportBatchDialog.java (+5/-5) src/pipe/gui/GuiFrame.java (+25/-77) src/pipe/gui/GuiFrameController.java (+8/-4) src/pipe/gui/Pipe.java (+6/-6) src/pipe/gui/RunVerification.java (+0/-3) src/pipe/gui/SelectionManager.java (+0/-1) src/pipe/gui/action/GuiAction.java (+0/-1) src/pipe/gui/action/SplitArcAction.java (+1/-1) src/pipe/gui/canvas/Canvas.java (+0/-1) src/pipe/gui/canvas/DrawingSurfaceImpl.java (+0/-2) src/pipe/gui/canvas/PrototypeCanvas.java (+0/-1) src/pipe/gui/graphicElements/AnnotationNote.java (+9/-5) src/pipe/gui/graphicElements/Arc.java (+0/-3) src/pipe/gui/graphicElements/Place.java (+10/-10) src/pipe/gui/graphicElements/PlaceTransitionObject.java (+0/-1) src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java (+0/-1) src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+0/-2) src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+1/-2) src/pipe/gui/handler/ArcHandler.java (+0/-7) src/pipe/gui/handler/PetriNetObjectHandler.java (+1/-24) src/pipe/gui/handler/PlaceHandler.java (+0/-20) src/pipe/gui/handler/TimedArcHandler.java (+0/-5) src/pipe/gui/handler/TransitionHandler.java (+0/-23) src/pipe/gui/undo/AddArcPathPointEdit.java (+3/-3) src/pipe/gui/undo/AddTemplateCommand.java (+1/-1) src/pipe/gui/undo/AnnotationBorderEdit.java (+1/-1) src/pipe/gui/undo/AnnotationTextEdit.java (+3/-3) src/pipe/gui/undo/ArcPathPointTypeEdit.java (+1/-1) src/pipe/gui/undo/ArcTimeIntervalEdit.java (+4/-4) src/pipe/gui/undo/TransitionRotationEdit.java (+2/-2) src/pipe/gui/undo/TranslatePetriNetObjectEdit.java (+4/-4) src/pipe/gui/undo/UndoManager.java (+6/-5) src/pipe/gui/widgets/CTLQueryDialog.java (+16/-14) src/pipe/gui/widgets/ConstantsDialogPanel.java (+25/-46) src/pipe/gui/widgets/ConstantsPane.java (+10/-45) src/pipe/gui/widgets/EngineDialogPanel.java (+16/-16) src/pipe/gui/widgets/GuardDialogue.java (+13/-13) src/pipe/gui/widgets/PlaceEditorPanel.java (+57/-143) src/pipe/gui/widgets/QueryDialog.java (+12/-10) src/pipe/gui/widgets/QueryPane.java (+6/-6) src/pipe/gui/widgets/TAPNTransitionEditor.java (+80/-123) src/pipe/gui/widgets/WorkflowDialog.java (+0/-2) |
||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~yrke/tapaal/evenMore-gui-cleanup | ||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Approve | ||
Review via email: mp+387945@code.launchpad.net |
Commit message
Description of the change
Testing
- double check that bugs are fixed
- Play with quick draw (press ctrl while drawing to continue drawing and placing missing place/transtison) - working as expected, ideas to improve.
- Check that warnings are correctly displayed when drawing invalid nets (eg. double arcs etc)
- check code diff
- 1151. By Kenneth Yrke Jørgensen
-
Removed .THIS file
Peter Haahr Taankvist (ptaank) wrote : | # |
- 1152. By Kenneth Yrke Jørgensen
-
Added required to use ctrl to start quick draw.
Kenneth Yrke Jørgensen (yrke) wrote : | # |
(1) & (2) would be nice, but would required some more work on the model before its feasible to implement.
Fixed (3)
(4) is also in trunk, think its a remain from how we used to draw arcs
Jiri Srba (srba) wrote : | # |
Can 4 be easily fixed in this branch or not?
- 1153. By Kenneth Yrke Jørgensen
-
Merged with trunk
- 1154. By Kenneth Yrke Jørgensen
-
Added logger for memory monitor
- 1155. By Kenneth Yrke Jørgensen
-
Removed logging of memory command
Jiri Srba (srba) wrote : | # |
The logic of showing tool tips is reversed (it shows them when the tick is off and the other way round).
- 1156. By Kenneth Yrke Jørgensen
-
Fixed an issue where showTokenAge action was updated insted of showToolTipaction
Jiri Srba (srba) wrote : | # |
The view option of enabled transitions and future enabled transitions are still broken. Open intro example, go to simulator, deselect future enabled transitions but they are still shown in yellow. The same problem with enabled transitions. Correct behaviour is in 3.6.1
Jiri Srba (srba) wrote : | # |
For the quick draw, it would be nice if the ctrl is release that it will finish the quick draw and the dagnlig arc disappers - right now one has to press ESC to finish this.
- 1157. By Kenneth Yrke Jørgensen
-
Fixes bug #1891001, no longer hardcoded to alwas show dealy enabled transitions
Jiri Srba (srba) wrote : | # |
The bug with enabled transitions is almost fixed, small problem remains:
1. Open intro example and go to simulator
2. Select not to show enabled transitions, the panel correctly disappears
3. Go back to editor and back to simulator
4. Now enabled transitions are shown again - turn the feature on and off and they disappear again.
Jiri Srba (srba) : | # |
Preview Diff
1 | === modified file 'build.gradle' |
2 | --- build.gradle 2020-05-18 06:17:09 +0000 |
3 | +++ build.gradle 2020-08-10 09:00:56 +0000 |
4 | @@ -54,6 +54,7 @@ |
5 | implementation group: 'commons-cli', name: 'commons-cli', version: '1.4' |
6 | implementation group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.5-1' |
7 | implementation group: 'net.java.dev.jna', name: 'jna', version: '4.5.1' |
8 | + implementation 'org.jetbrains:annotations:16.0.2' |
9 | //compile group: 'com.apple', name: 'AppleJavaExtensions', version: '1.4' // Not working |
10 | |
11 | //Add jars from libs dir |
12 | |
13 | === removed file 'libs/AppleJavaExtensions.jar' |
14 | Binary files libs/AppleJavaExtensions.jar 2014-03-04 11:20:32 +0000 and libs/AppleJavaExtensions.jar 1970-01-01 00:00:00 +0000 differ |
15 | === modified file 'src/dk/aau/cs/approximation/OverApproximation.java' |
16 | --- src/dk/aau/cs/approximation/OverApproximation.java 2019-03-22 11:36:50 +0000 |
17 | +++ src/dk/aau/cs/approximation/OverApproximation.java 2020-08-10 09:00:56 +0000 |
18 | @@ -63,10 +63,10 @@ |
19 | IntBound newLowerBound = new IntBound((int) Math.floor(oldInterval.lowerBound().value() / denominator)); |
20 | |
21 | return new TimeInterval( |
22 | - oldInterval.IsLowerBoundNonStrict(), |
23 | + oldInterval.isLowerBoundNonStrict(), |
24 | newLowerBound, |
25 | newUpperBound, |
26 | - oldInterval.IsUpperBoundNonStrict() |
27 | + oldInterval.isUpperBoundNonStrict() |
28 | ); |
29 | } |
30 | |
31 | |
32 | === modified file 'src/dk/aau/cs/approximation/UnderApproximation.java' |
33 | --- src/dk/aau/cs/approximation/UnderApproximation.java 2019-07-01 08:42:23 +0000 |
34 | +++ src/dk/aau/cs/approximation/UnderApproximation.java 2020-08-10 09:00:56 +0000 |
35 | @@ -163,11 +163,11 @@ |
36 | newUpperBound = new IntBound((int) Math.floor((double)oldInterval.upperBound().value() / denominator)); |
37 | } |
38 | |
39 | - boolean isLowerBoundNonStrict = oldInterval.IsLowerBoundNonStrict(); |
40 | - boolean isUpperBoundNonStrict = oldInterval.IsUpperBoundNonStrict(); |
41 | + boolean isLowerBoundNonStrict = oldInterval.isLowerBoundNonStrict(); |
42 | + boolean isUpperBoundNonStrict = oldInterval.isUpperBoundNonStrict(); |
43 | |
44 | // if the interval becomes too small we make it a bit bigger to secure, that we do not have to delete the arc |
45 | - if ( (newUpperBound.value() == newLowerBound.value()) && !(oldInterval.IsLowerBoundNonStrict() && oldInterval.IsUpperBoundNonStrict())) |
46 | + if ( (newUpperBound.value() == newLowerBound.value()) && !(oldInterval.isLowerBoundNonStrict() && oldInterval.isUpperBoundNonStrict())) |
47 | { |
48 | isUpperBoundNonStrict = true; |
49 | isLowerBoundNonStrict = true; |
50 | |
51 | === modified file 'src/dk/aau/cs/debug/Logger.java' |
52 | --- src/dk/aau/cs/debug/Logger.java 2017-04-01 10:46:28 +0000 |
53 | +++ src/dk/aau/cs/debug/Logger.java 2020-08-10 09:00:56 +0000 |
54 | @@ -21,14 +21,18 @@ |
55 | if (enableDebug) { |
56 | logDevice.println(log); |
57 | } |
58 | - |
59 | } |
60 | |
61 | + public static void log(Exception e) { |
62 | + if (enableDebug) { |
63 | + e.printStackTrace(); |
64 | + } |
65 | + } |
66 | + |
67 | public static void log(Object log) { |
68 | if (enableDebug) { |
69 | logDevice.println(log.toString()); |
70 | } |
71 | - |
72 | } |
73 | |
74 | } |
75 | |
76 | === modified file 'src/dk/aau/cs/gui/BatchProcessingDialog.java' |
77 | --- src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-07-13 13:58:47 +0000 |
78 | +++ src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-08-10 09:00:56 +0000 |
79 | @@ -360,8 +360,8 @@ |
80 | JPanel fileListPanel = new JPanel(new GridBagLayout()); |
81 | fileListPanel.setBorder(BorderFactory.createTitledBorder("Models")); |
82 | |
83 | - listModel = new DefaultListModel(); |
84 | - fileList = new JList(listModel); |
85 | + listModel = new DefaultListModel<>(); |
86 | + fileList = new JList<>(listModel); |
87 | fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
88 | fileList.setSelectedIndex(0); |
89 | fileList.addKeyListener(new KeyAdapter() { |
90 | @@ -383,7 +383,7 @@ |
91 | } |
92 | }); |
93 | |
94 | - fileList.setCellRenderer(new FileNameCellRenderer()); |
95 | + fileList.setCellRenderer(new FileNameCellRenderer<>()); |
96 | |
97 | JScrollPane scrollpane = new JScrollPane(fileList); |
98 | scrollpane.setMinimumSize(new Dimension(175, 225)); |
99 | @@ -529,7 +529,7 @@ |
100 | |
101 | String[] options = new String[] { name_KeepQueryOption, |
102 | name_SEARCHWHOLESTATESPACE, name_EXISTDEADLOCK, name_SOUNDNESS, name_STRONGSOUNDNESS}; |
103 | - queryPropertyOption = new JComboBox(options); |
104 | + queryPropertyOption = new JComboBox<>(options); |
105 | queryPropertyOption.setToolTipText(TOOL_TIP_Query_Property_Option); |
106 | |
107 | gbc = new GridBagConstraints(); |
108 | @@ -559,7 +559,7 @@ |
109 | name_OVER_APPROXIMATION, |
110 | name_UNDER_APPROXIMATION |
111 | }; |
112 | - approximationMethodOption = new JComboBox(options); |
113 | + approximationMethodOption = new JComboBox<>(options); |
114 | approximationMethodOption.setToolTipText(TOOL_TIP_Approximation_Method_Option_Keep); |
115 | approximationMethodOption.addActionListener(new ActionListener() { |
116 | @Override |
117 | @@ -796,7 +796,7 @@ |
118 | |
119 | String[] options = new String[] { name_KeepQueryOption, name_SYMMETRY, |
120 | name_NOSYMMETRY }; |
121 | - symmetryOption = new JComboBox(options); |
122 | + symmetryOption = new JComboBox<>(options); |
123 | symmetryOption.setToolTipText(TOOL_TIP_SymmetryOption); |
124 | |
125 | gbc = new GridBagConstraints(); |
126 | @@ -821,7 +821,7 @@ |
127 | |
128 | String[] options = new String[] { name_KeepQueryOption, name_STUBBORNREUDCTION, |
129 | name_NOSTUBBORNREDUCTION }; |
130 | - stubbornReductionOption = new JComboBox(options); |
131 | + stubbornReductionOption = new JComboBox<>(options); |
132 | stubbornReductionOption.setToolTipText(TOOL_TIP_StubbornReductionOption); |
133 | |
134 | gbc = new GridBagConstraints(); |
135 | @@ -944,7 +944,7 @@ |
136 | |
137 | String[] options = new String[] { name_KeepQueryOption, name_HEURISTIC, |
138 | name_BFS, name_DFS, name_Random }; |
139 | - searchOption = new JComboBox(options); |
140 | + searchOption = new JComboBox<>(options); |
141 | searchOption.setToolTipText(TOOL_TIP_SearchOption); |
142 | |
143 | gbc = new GridBagConstraints(); |
144 | |
145 | === modified file 'src/dk/aau/cs/gui/DeleteSharedPlaceOrTransition.java' |
146 | --- src/dk/aau/cs/gui/DeleteSharedPlaceOrTransition.java 2020-04-18 16:08:44 +0000 |
147 | +++ src/dk/aau/cs/gui/DeleteSharedPlaceOrTransition.java 2020-08-10 09:00:56 +0000 |
148 | @@ -54,13 +54,13 @@ |
149 | private static final String TRANSITION_IS_USED_MESSAGE = "<html>The shared transition is used in one or more components.<br/>TAPAAL will unshare all transitions under this name,<br/>but leave the transitions in the components.</html>"; |
150 | private static final String PLACE_IS_USED_MESSAGE = "<html>The shared place is used in one or more components.<br/>TAPAAL will unshare all places under this name,<br/>but leave the places in the components.</html>"; |
151 | |
152 | - JList list; |
153 | - SharedPlacesAndTransitionsPanel sharedPlacesAndTransitionsPanel; |
154 | - TabContent tab; |
155 | - UndoManager undoManager; |
156 | - SharedPlacesListModel sharedPlacesListModel; |
157 | - SharedTransitionsListModel sharedTransitionsListModel; |
158 | - NameGenerator nameGenerator; |
159 | + final JList list; |
160 | + final SharedPlacesAndTransitionsPanel sharedPlacesAndTransitionsPanel; |
161 | + final TabContent tab; |
162 | + final UndoManager undoManager; |
163 | + final SharedPlacesListModel sharedPlacesListModel; |
164 | + final SharedTransitionsListModel sharedTransitionsListModel; |
165 | + final NameGenerator nameGenerator; |
166 | boolean messageShown; |
167 | |
168 | public DeleteSharedPlaceOrTransition(JList list, SharedPlacesAndTransitionsPanel sharedPlacesAndTransitionsPanel, TabContent tab, |
169 | @@ -82,7 +82,7 @@ |
170 | JList listOfComponents = new JList(affectedComponents.toArray()); |
171 | JScrollPane scrollPane = new JScrollPane(listOfComponents); |
172 | Object[] params = {label, checkBox, new JLabel("Components affected:"), scrollPane}; |
173 | - result = JOptionPane.showConfirmDialog(CreateGui.getApp(), params, "Warning", JOptionPane.WARNING_MESSAGE); |
174 | + result = JOptionPane.showConfirmDialog(CreateGui.getApp(), params, "Warning", JOptionPane.OK_CANCEL_OPTION); |
175 | boolean deleteFromTemplates = checkBox.isSelected(); |
176 | return new DeleteSharedResult(result, deleteFromTemplates); |
177 | } |
178 | @@ -161,13 +161,17 @@ |
179 | for(Template template : tab.allTemplates()){ // TODO: Get rid of pipe references somehow |
180 | TimedPlaceComponent place = (TimedPlaceComponent)template.guiModel().getPlaceByName(placeToRemove.name()); |
181 | if(place != null){ |
182 | - for(Arc arc : place.getPreset()){ |
183 | - deleteArc(arc, template); |
184 | - } |
185 | - |
186 | - for(Arc arc : place.getPostset()){ |
187 | - deleteArc(arc, template); |
188 | - } |
189 | + //XXX: we need to save arcs to delete, if we delete it while iterating pre/post set it can lead to errors |
190 | + ArrayList<Arc> arcsToDelete = new ArrayList<>(); |
191 | + |
192 | + for(Arc arc : place.getPreset()){ |
193 | + arcsToDelete.add(arc); |
194 | + } |
195 | + |
196 | + for(Arc arc : place.getPostset()){ |
197 | + arcsToDelete.add(arc); |
198 | + } |
199 | + arcsToDelete.forEach(arc->deleteArc(arc, template)); |
200 | |
201 | Command cmd = new DeleteTimedPlaceCommand(place, template.model(), template.guiModel()); |
202 | cmd.redo(); |
203 | @@ -280,13 +284,17 @@ |
204 | for(Template template : tab.allTemplates()){ // TODO: Get rid of pipe references somehow |
205 | TimedTransitionComponent transition = (TimedTransitionComponent)template.guiModel().getTransitionByName(transitionToBeRemoved.name()); |
206 | if(transition != null){ |
207 | + //XXX: we need to save arcs to delete, if we delete it while iterating pre/post set it can lead to errors |
208 | + ArrayList<Arc> arcsToDelete = new ArrayList<>(); |
209 | + |
210 | for(Arc arc : transition.getPreset()){ |
211 | - deleteArc(arc, template); |
212 | + arcsToDelete.add(arc); |
213 | } |
214 | |
215 | for(Arc arc : transition.getPostset()){ |
216 | - deleteArc(arc, template); |
217 | + arcsToDelete.add(arc); |
218 | } |
219 | + arcsToDelete.forEach(arc->deleteArc(arc, template)); |
220 | |
221 | Command c = new DeleteTimedTransitionCommand(transition, transition.underlyingTransition().model(), template.guiModel()); |
222 | undoManager.addEdit(c); |
223 | @@ -321,8 +329,8 @@ |
224 | } |
225 | |
226 | private static class DeleteSharedResult{ |
227 | - public int choice; |
228 | - public boolean deleteFromTemplates; |
229 | + public final int choice; |
230 | + public final boolean deleteFromTemplates; |
231 | |
232 | public DeleteSharedResult(int choice, boolean deleteFromTemplates) { |
233 | this.choice = choice; |
234 | |
235 | === modified file 'src/dk/aau/cs/gui/FileNameCellRenderer.java' |
236 | --- src/dk/aau/cs/gui/FileNameCellRenderer.java 2020-04-18 12:27:02 +0000 |
237 | +++ src/dk/aau/cs/gui/FileNameCellRenderer.java 2020-08-10 09:00:56 +0000 |
238 | @@ -7,7 +7,7 @@ |
239 | import javax.swing.JList; |
240 | import javax.swing.ListCellRenderer; |
241 | |
242 | -public class FileNameCellRenderer extends JLabel implements ListCellRenderer { |
243 | +public class FileNameCellRenderer<T> extends JLabel implements ListCellRenderer<T> { |
244 | // Custom cell renderer for the file list to only display the name of the |
245 | // file instead of the whole path.{ |
246 | |
247 | |
248 | === modified file 'src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java' |
249 | --- src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2020-08-03 14:47:11 +0000 |
250 | +++ src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2020-08-10 09:00:56 +0000 |
251 | @@ -10,7 +10,6 @@ |
252 | import javax.swing.AbstractListModel; |
253 | import javax.swing.BorderFactory; |
254 | import javax.swing.BoxLayout; |
255 | -import javax.swing.ImageIcon; |
256 | import javax.swing.JButton; |
257 | import javax.swing.JComboBox; |
258 | import javax.swing.JList; |
259 | @@ -25,7 +24,6 @@ |
260 | import net.tapaal.resourcemanager.ResourceManager; |
261 | import pipe.gui.CreateGui; |
262 | import pipe.gui.undo.UndoManager; |
263 | -import pipe.gui.widgets.ConstantsPane; |
264 | import pipe.gui.widgets.EscapableDialog; |
265 | |
266 | import dk.aau.cs.gui.components.NonsearchableJList; |
267 | @@ -42,10 +40,11 @@ |
268 | private static final String TRANSITIONS = "Transitions"; |
269 | private static final String PLACES = "Places"; |
270 | |
271 | - private final JList list = new NonsearchableJList(); |
272 | + //XXX contains a SharedTransition SharePlace based on what is displayed, should be a type param |
273 | + private final JList<Object> list = new NonsearchableJList<>(); |
274 | private final SharedPlacesListModel sharedPlacesListModel; |
275 | private final SharedTransitionsListModel sharedTransitionsListModel; |
276 | - private final JComboBox placesTransitionsComboBox = new JComboBox(new String[]{ PLACES, TRANSITIONS }); |
277 | + private final JComboBox<String> placesTransitionsComboBox = new JComboBox<>(new String[]{ PLACES, TRANSITIONS }); |
278 | private final UndoManager undoManager; |
279 | private final NameGenerator nameGenerator; |
280 | private final TabContent tab; |
281 | @@ -68,8 +67,7 @@ |
282 | //private static final String toolTipSharedPlacesPanel = "Here you can manage the shared places.<html><br/></html>Shared places can link different components."; |
283 | private static final String toolTipNewTransition = "Create a new transition"; |
284 | private static final String toolTipRenameTransition = "Rename the selected transition"; |
285 | - //private static final String toolTipSharedTransitionsPanel = "Here you can manage the shared transitions.<html><br/></html>" + |
286 | - // "Shared transitions can link different components."; |
287 | + //private static final String toolTipSharedTransitionsPanel = "Here you can manage the shared transitions.<html><br/></html>" + "Shared transitions can link different components."; |
288 | private static final String toolTipRemoveTransition ="Remove the selected transition"; |
289 | private static final String toolTipChangeBetweenPlacesAndTransitions = "Switch between shared places and transitions"; |
290 | |
291 | @@ -129,7 +127,7 @@ |
292 | list.addListSelectionListener(new ListSelectionListener() { |
293 | public void valueChanged(ListSelectionEvent e) { |
294 | if(!e.getValueIsAdjusting()){ |
295 | - JList source = (JList)e.getSource(); |
296 | + JList<Object> source = (JList<Object>)e.getSource(); |
297 | if(source.getSelectedIndex() == -1){ |
298 | removeButton.setEnabled(false); |
299 | renameButton.setEnabled(false); |
300 | @@ -143,31 +141,36 @@ |
301 | } |
302 | |
303 | int index = list.getSelectedIndex(); |
304 | - if(index > 0 && list.getSelectedIndices().length == 1) |
305 | - moveUpButton.setEnabled(true); |
306 | - else |
307 | - moveUpButton.setEnabled(false); |
308 | + if(index > 0 && list.getSelectedIndices().length == 1) { |
309 | + moveUpButton.setEnabled(true); |
310 | + } else { |
311 | + moveUpButton.setEnabled(false); |
312 | + } |
313 | |
314 | if(isDisplayingTransitions()) { |
315 | - if(index < sharedTransitionsListModel.getSize() - 1 && list.getSelectedIndices().length == 1) |
316 | - moveDownButton.setEnabled(true); |
317 | - else |
318 | - moveDownButton.setEnabled(false); |
319 | + if(index < sharedTransitionsListModel.getSize() - 1 && list.getSelectedIndices().length == 1) { |
320 | + moveDownButton.setEnabled(true); |
321 | + } else { |
322 | + moveDownButton.setEnabled(false); |
323 | + } |
324 | |
325 | if (sharedTransitionsListModel.getSize() >=2) { |
326 | sortButton.setEnabled(true); |
327 | - } else |
328 | - sortButton.setEnabled(false); |
329 | + } else { |
330 | + sortButton.setEnabled(false); |
331 | + } |
332 | } else { |
333 | - if(index < sharedPlacesListModel.getSize() - 1 && list.getSelectedIndices().length == 1) |
334 | - moveDownButton.setEnabled(true); |
335 | - else |
336 | - moveDownButton.setEnabled(false); |
337 | + if(index < sharedPlacesListModel.getSize() - 1 && list.getSelectedIndices().length == 1) { |
338 | + moveDownButton.setEnabled(true); |
339 | + } else { |
340 | + moveDownButton.setEnabled(false); |
341 | + } |
342 | |
343 | if (sharedPlacesListModel.getSize() >=2) { |
344 | sortButton.setEnabled(true); |
345 | - } else |
346 | - sortButton.setEnabled(false); |
347 | + } else { |
348 | + sortButton.setEnabled(false); |
349 | + } |
350 | } |
351 | } |
352 | } |
353 | |
354 | === modified file 'src/dk/aau/cs/gui/TabContent.java' |
355 | --- src/dk/aau/cs/gui/TabContent.java 2020-08-07 12:53:14 +0000 |
356 | +++ src/dk/aau/cs/gui/TabContent.java 2020-08-10 09:00:56 +0000 |
357 | @@ -1,19 +1,9 @@ |
358 | package dk.aau.cs.gui; |
359 | |
360 | -import java.awt.*; |
361 | -import java.awt.event.MouseAdapter; |
362 | -import java.awt.event.MouseEvent; |
363 | -import java.awt.geom.Point2D; |
364 | -import java.io.*; |
365 | -import java.math.BigDecimal; |
366 | -import java.util.*; |
367 | -import java.util.List; |
368 | - |
369 | -import javax.swing.*; |
370 | -import javax.swing.border.BevelBorder; |
371 | - |
372 | import dk.aau.cs.debug.Logger; |
373 | +import dk.aau.cs.gui.components.BugHandledJXMultisplitPane; |
374 | import dk.aau.cs.gui.components.StatisticsPanel; |
375 | +import dk.aau.cs.gui.components.TransitionFireingComponent; |
376 | import dk.aau.cs.gui.undo.Command; |
377 | import dk.aau.cs.gui.undo.DeleteQueriesCommand; |
378 | import dk.aau.cs.gui.undo.TimedPlaceMarkingEdit; |
379 | @@ -21,33 +11,43 @@ |
380 | import dk.aau.cs.io.queries.SUMOQueryLoader; |
381 | import dk.aau.cs.io.queries.XMLQueryLoader; |
382 | import dk.aau.cs.model.tapn.*; |
383 | +import dk.aau.cs.util.Require; |
384 | import dk.aau.cs.util.Tuple; |
385 | import dk.aau.cs.verification.NameMapping; |
386 | import dk.aau.cs.verification.TAPNComposer; |
387 | import net.tapaal.gui.DrawingSurfaceManager.AbstractDrawingSurfaceManager; |
388 | import net.tapaal.helpers.Reference.MutableReference; |
389 | +import net.tapaal.swinghelpers.JSplitPaneFix; |
390 | import org.jdesktop.swingx.MultiSplitLayout.Divider; |
391 | import org.jdesktop.swingx.MultiSplitLayout.Leaf; |
392 | import org.jdesktop.swingx.MultiSplitLayout.Split; |
393 | - |
394 | -import pipe.dataLayer.*; |
395 | +import org.jetbrains.annotations.NotNull; |
396 | +import pipe.dataLayer.DataLayer; |
397 | +import pipe.dataLayer.NetWriter; |
398 | import pipe.dataLayer.TAPNQuery; |
399 | +import pipe.dataLayer.Template; |
400 | import pipe.gui.*; |
401 | import pipe.gui.canvas.DrawingSurfaceImpl; |
402 | import pipe.gui.graphicElements.*; |
403 | import pipe.gui.graphicElements.tapn.*; |
404 | import pipe.gui.undo.*; |
405 | import pipe.gui.widgets.ConstantsPane; |
406 | -import pipe.gui.undo.ChangeSpacingEdit; |
407 | -import pipe.gui.undo.UndoManager; |
408 | -import pipe.gui.widgets.*; |
409 | - |
410 | -import net.tapaal.swinghelpers.JSplitPaneFix; |
411 | -import dk.aau.cs.gui.components.BugHandledJXMultisplitPane; |
412 | -import dk.aau.cs.gui.components.TransitionFireingComponent; |
413 | -import dk.aau.cs.util.Require; |
414 | +import pipe.gui.widgets.QueryPane; |
415 | +import pipe.gui.widgets.WorkflowDialog; |
416 | import pipe.gui.widgets.filebrowser.FileBrowser; |
417 | |
418 | +import javax.swing.*; |
419 | +import javax.swing.border.BevelBorder; |
420 | +import java.awt.*; |
421 | +import java.awt.event.MouseAdapter; |
422 | +import java.awt.event.MouseEvent; |
423 | +import java.awt.event.MouseWheelEvent; |
424 | +import java.awt.geom.Point2D; |
425 | +import java.io.*; |
426 | +import java.math.BigDecimal; |
427 | +import java.util.List; |
428 | +import java.util.*; |
429 | + |
430 | public class TabContent extends JSplitPane implements TabContentActions{ |
431 | |
432 | public static class TAPNLens { |
433 | @@ -76,18 +76,74 @@ |
434 | private final HashMap<TimedArcPetriNet, DataLayer> guiModels = new HashMap<TimedArcPetriNet, DataLayer>(); |
435 | private final HashMap<DataLayer, TimedArcPetriNet> guiModelToModel = new HashMap<>(); |
436 | |
437 | + //XXX: should be replaced iwth DataLayer->Zoomer, TimedArcPetriNet has nothing to do with zooming |
438 | private final HashMap<TimedArcPetriNet, Zoomer> zoomLevels = new HashMap<TimedArcPetriNet, Zoomer>(); |
439 | |
440 | |
441 | private final UndoManager undoManager = new UndoManager(); |
442 | |
443 | + public final static class Result<T,R> { |
444 | + private final T result; |
445 | + private final boolean hasErrors; |
446 | + private final List<R> errors; |
447 | + |
448 | + public Result(T result) { |
449 | + hasErrors = false; |
450 | + this.result = result; |
451 | + errors = new ArrayList<>(0); |
452 | + } |
453 | + public Result(Collection<R> errors) { |
454 | + hasErrors = true; |
455 | + this.errors = new ArrayList<>(errors); |
456 | + result = null; |
457 | + } |
458 | + } |
459 | + public final static class RequirementChecker<R> { |
460 | + public final List<R> errors = new LinkedList<R>(); |
461 | + |
462 | + public final void Not(boolean b, R s) { |
463 | + if (b) { |
464 | + errors.add(s); |
465 | + } |
466 | + } |
467 | + |
468 | + public final void notNull(Object c, R s) { |
469 | + if (c == null) { |
470 | + errors.add(s); |
471 | + } |
472 | + } |
473 | + |
474 | + public final boolean failed() { |
475 | + return errors.size() != 0; |
476 | + } |
477 | + public final List<R> getErrors() { |
478 | + return Collections.unmodifiableList(errors); |
479 | + } |
480 | + } |
481 | + private enum ModelViolation { |
482 | + |
483 | + //PlaceNotNull("Place can't be null"), |
484 | + //TransitionNotNull("Transion can't be null"), |
485 | + //ModelNotNull("Model can't be null"), |
486 | + MaxOneArcBetweenPlaceAndTransition("There is already an arc between the selected place and transition"), |
487 | + MaxOneArcBetweenTransitionAndPlace("There is already an arc between the selected transition and place"), |
488 | + CantHaveArcBetweenSharedPlaceAndTransition("You are attempting to draw an arc between a shared transition and a shared place"); |
489 | + |
490 | + private final String errorMessage; |
491 | + |
492 | + ModelViolation(String s) { |
493 | + this.errorMessage = s; |
494 | + } |
495 | + |
496 | + public String getErrorMessage() { return this.errorMessage;} |
497 | + } |
498 | public final GuiModelManager guiModelManager = new GuiModelManager(); |
499 | public class GuiModelManager { |
500 | public GuiModelManager(){ |
501 | |
502 | } |
503 | |
504 | - public void addNewTimedPlace(DataLayer c, Point p){ |
505 | + public Result<TimedPlaceComponent, ModelViolation> addNewTimedPlace(DataLayer c, Point p){ |
506 | Require.notNull(c, "datalyer can't be null"); |
507 | Require.notNull(p, "Point can't be null"); |
508 | |
509 | @@ -97,10 +153,10 @@ |
510 | c.addPetriNetObject(pnObject); |
511 | |
512 | getUndoManager().addNewEdit(new AddTimedPlaceCommand(pnObject, guiModelToModel.get(c), c)); |
513 | - |
514 | + return new Result<>(pnObject); |
515 | } |
516 | |
517 | - public void addNewTimedTransitions(DataLayer c, Point p) { |
518 | + public Result<TimedTransitionComponent, ModelViolation> addNewTimedTransitions(DataLayer c, Point p) { |
519 | dk.aau.cs.model.tapn.TimedTransition transition = new dk.aau.cs.model.tapn.TimedTransition(drawingSurface.getNameGenerator().getNewTransitionName(guiModelToModel.get(c))); |
520 | |
521 | TimedTransitionComponent pnObject = new TimedTransitionComponent(p.x, p.y, transition); |
522 | @@ -109,6 +165,7 @@ |
523 | c.addPetriNetObject(pnObject); |
524 | |
525 | getUndoManager().addNewEdit(new AddTimedTransitionCommand(pnObject, guiModelToModel.get(c), c)); |
526 | + return new Result<>(pnObject); |
527 | } |
528 | |
529 | public void addAnnotationNote(DataLayer c, Point p) { |
530 | @@ -122,134 +179,119 @@ |
531 | } |
532 | } |
533 | |
534 | - public void addTimedInputArc(DataLayer c, TimedPlaceComponent p, TimedTransitionComponent t, ArcPath path) { |
535 | - Require.notNull(c, "DataLayer can't be null"); |
536 | - Require.notNull(p, "Place can't be null"); |
537 | - Require.notNull(t, "Transitions can't be null"); |
538 | - |
539 | - TimedArcPetriNet modelNet = guiModelToModel.get(c); |
540 | - |
541 | - if (!modelNet.hasArcFromPlaceToTransition(p.underlyingPlace(), t.underlyingTransition())) { |
542 | - |
543 | - TimedInputArc tia = new TimedInputArc( |
544 | - p.underlyingPlace(), |
545 | - t.underlyingTransition(), |
546 | - TimeInterval.ZERO_INF |
547 | - ); |
548 | - |
549 | - TimedInputArcComponent tiac = new TimedInputArcComponent(p,t,tia); |
550 | - |
551 | - if (path != null) { |
552 | - tiac.setArcPath(new ArcPath(tiac, path)); |
553 | - } |
554 | - |
555 | - Command edit = new AddTimedInputArcCommand( |
556 | - tiac, |
557 | - modelNet, |
558 | - c |
559 | - ); |
560 | - edit.redo(); |
561 | - |
562 | - undoManager.addNewEdit(edit); |
563 | - |
564 | - } else { |
565 | - //TODO: can't have two arcs between place and transition |
566 | - JOptionPane.showMessageDialog( |
567 | - CreateGui.getApp(), |
568 | - "There was an error drawing the arc. Possible problems:\n" |
569 | - + " - There is already an arc between the selected place and transition\n" |
570 | - + " - You are attempting to draw an arc between a shared transition and a shared place", |
571 | - "Error", JOptionPane.ERROR_MESSAGE |
572 | - ); |
573 | - } |
574 | - } |
575 | - |
576 | - public void addTimedOutputArc(DataLayer c, TimedTransitionComponent t, TimedPlaceComponent p, ArcPath path) { |
577 | - Require.notNull(c, "DataLayer can't be null"); |
578 | - Require.notNull(p, "Place can't be null"); |
579 | - Require.notNull(t, "Transitions can't be null"); |
580 | - |
581 | - TimedArcPetriNet modelNet = guiModelToModel.get(c); |
582 | - |
583 | - if (!modelNet.hasArcFromTransitionToPlace(t.underlyingTransition(), p.underlyingPlace())) { |
584 | - |
585 | - TimedOutputArc toa = new TimedOutputArc( |
586 | - t.underlyingTransition(), |
587 | - p.underlyingPlace() |
588 | - ); |
589 | - |
590 | - TimedOutputArcComponent toac = new TimedOutputArcComponent(t, p, toa); |
591 | - |
592 | - if (path != null) { |
593 | - toac.setArcPath(new ArcPath(toac, path)); |
594 | - } |
595 | - |
596 | - Command edit = new AddTimedOutputArcCommand( |
597 | - toac, |
598 | - modelNet, |
599 | - c |
600 | - ); |
601 | - edit.redo(); |
602 | - undoManager.addNewEdit(edit); |
603 | - |
604 | - } else { |
605 | - |
606 | - JOptionPane.showMessageDialog( |
607 | - CreateGui.getApp(), |
608 | - "There was an error drawing the arc. Possible problems:\n" |
609 | - + " - There is already an arc between the selected place and transition\n" |
610 | - + " - You are attempting to draw an arc between a shared transition and a shared place", |
611 | - "Error", JOptionPane.ERROR_MESSAGE |
612 | - ); |
613 | - |
614 | - } |
615 | - |
616 | - |
617 | - } |
618 | - |
619 | - public void addInhibitorArc(DataLayer c, TimedPlaceComponent p, TimedTransitionComponent t, ArcPath path) { |
620 | - Require.notNull(c, "DataLayer can't be null"); |
621 | - Require.notNull(p, "Place can't be null"); |
622 | - Require.notNull(t, "Transitions can't be null"); |
623 | - |
624 | - TimedArcPetriNet modelNet = guiModelToModel.get(c); |
625 | - |
626 | - if (!modelNet.hasArcFromPlaceToTransition(p.underlyingPlace(), t.underlyingTransition())) { |
627 | - |
628 | - TimedInhibitorArc tiha = new TimedInhibitorArc( |
629 | - p.underlyingPlace(), |
630 | - t.underlyingTransition() |
631 | - ); |
632 | - |
633 | - TimedInhibitorArcComponent tihac = new TimedInhibitorArcComponent(p, t, tiha); |
634 | - |
635 | - if (path != null) { |
636 | - tihac.setArcPath(new ArcPath(tihac, path)); |
637 | - } |
638 | - |
639 | - Command edit = new AddTimedInhibitorArcCommand( |
640 | - tihac, |
641 | - modelNet, |
642 | - c |
643 | - ); |
644 | - edit.redo(); |
645 | - undoManager.addNewEdit(edit); |
646 | - |
647 | - } else { |
648 | - |
649 | - JOptionPane.showMessageDialog( |
650 | - CreateGui.getApp(), |
651 | - "There was an error drawing the arc. Possible problems:\n" |
652 | - + " - There is already an arc between the selected place and transition\n" |
653 | - + " - You are attempting to draw an arc between a shared transition and a shared place", |
654 | - "Error", JOptionPane.ERROR_MESSAGE |
655 | - ); |
656 | - |
657 | - } |
658 | - |
659 | - } |
660 | - |
661 | - public void addTimedTransportArc(DataLayer c, TimedPlaceComponent p1, TimedTransitionComponent t, TimedPlaceComponent p2, ArcPath path1, ArcPath path2) { |
662 | + public Result<TimedInputArcComponent, ModelViolation> addTimedInputArc(@NotNull DataLayer c, @NotNull TimedPlaceComponent p, @NotNull TimedTransitionComponent t, ArcPath path) { |
663 | + Require.notNull(c, "DataLayer can't be null"); |
664 | + Require.notNull(p, "Place can't be null"); |
665 | + Require.notNull(t, "Transitions can't be null"); |
666 | + |
667 | + var require = new RequirementChecker<ModelViolation>(); |
668 | + require.Not(guiModelToModel.get(c).hasArcFromPlaceToTransition(p.underlyingPlace(), t.underlyingTransition()), ModelViolation.MaxOneArcBetweenPlaceAndTransition); |
669 | + require.Not( (p.underlyingPlace().isShared() && t.underlyingTransition().isShared()), ModelViolation.CantHaveArcBetweenSharedPlaceAndTransition); |
670 | + |
671 | + if (require.failed()) { |
672 | + return new Result<>(require.getErrors()); |
673 | + } |
674 | + |
675 | + TimedArcPetriNet modelNet = guiModelToModel.get(c); |
676 | + TimedInputArc tia = new TimedInputArc( |
677 | + p.underlyingPlace(), |
678 | + t.underlyingTransition(), |
679 | + TimeInterval.ZERO_INF |
680 | + ); |
681 | + |
682 | + TimedInputArcComponent tiac = new TimedInputArcComponent(p, t, tia); |
683 | + |
684 | + if (path != null) { |
685 | + tiac.setArcPath(new ArcPath(tiac, path)); |
686 | + } |
687 | + |
688 | + Command edit = new AddTimedInputArcCommand( |
689 | + tiac, |
690 | + modelNet, |
691 | + c |
692 | + ); |
693 | + edit.redo(); |
694 | + |
695 | + undoManager.addNewEdit(edit); |
696 | + |
697 | + return new Result<>(tiac); |
698 | + } |
699 | + |
700 | + public Result<TimedOutputArcComponent, ModelViolation> addTimedOutputArc(DataLayer c, TimedTransitionComponent t, TimedPlaceComponent p, ArcPath path) { |
701 | + Require.notNull(c, "DataLayer can't be null"); |
702 | + Require.notNull(p, "Place can't be null"); |
703 | + Require.notNull(t, "Transitions can't be null"); |
704 | + |
705 | + var require = new RequirementChecker<ModelViolation>(); |
706 | + require.Not(guiModelToModel.get(c).hasArcFromTransitionToPlace(t.underlyingTransition(), p.underlyingPlace()), ModelViolation.MaxOneArcBetweenTransitionAndPlace); |
707 | + require.Not((p.underlyingPlace().isShared() && t.underlyingTransition().isShared()), ModelViolation.CantHaveArcBetweenSharedPlaceAndTransition); |
708 | + |
709 | + if (require.failed()) { |
710 | + return new Result<>(require.getErrors()); |
711 | + } |
712 | + |
713 | + TimedArcPetriNet modelNet = guiModelToModel.get(c); |
714 | + |
715 | + TimedOutputArc toa = new TimedOutputArc( |
716 | + t.underlyingTransition(), |
717 | + p.underlyingPlace() |
718 | + ); |
719 | + |
720 | + TimedOutputArcComponent toac = new TimedOutputArcComponent(t, p, toa); |
721 | + |
722 | + if (path != null) { |
723 | + toac.setArcPath(new ArcPath(toac, path)); |
724 | + } |
725 | + |
726 | + Command edit = new AddTimedOutputArcCommand( |
727 | + toac, |
728 | + modelNet, |
729 | + c |
730 | + ); |
731 | + edit.redo(); |
732 | + undoManager.addNewEdit(edit); |
733 | + |
734 | + return new Result<>(toac); |
735 | + } |
736 | + |
737 | + public Result<TimedInhibitorArcComponent, ModelViolation> addInhibitorArc(DataLayer c, TimedPlaceComponent p, TimedTransitionComponent t, ArcPath path) { |
738 | + Require.notNull(c, "DataLayer can't be null"); |
739 | + Require.notNull(p, "Place can't be null"); |
740 | + Require.notNull(t, "Transitions can't be null"); |
741 | + |
742 | + TimedArcPetriNet modelNet = guiModelToModel.get(c); |
743 | + |
744 | + var require = new RequirementChecker<ModelViolation>(); |
745 | + require.Not(modelNet.hasArcFromPlaceToTransition(p.underlyingPlace(), t.underlyingTransition()), ModelViolation.MaxOneArcBetweenPlaceAndTransition); |
746 | + require.Not( (p.underlyingPlace().isShared() && t.underlyingTransition().isShared()), ModelViolation.CantHaveArcBetweenSharedPlaceAndTransition); |
747 | + |
748 | + if (require.failed()) { |
749 | + return new Result<>(require.getErrors()); |
750 | + } |
751 | + |
752 | + TimedInhibitorArc tiha = new TimedInhibitorArc( |
753 | + p.underlyingPlace(), |
754 | + t.underlyingTransition() |
755 | + ); |
756 | + |
757 | + TimedInhibitorArcComponent tihac = new TimedInhibitorArcComponent(p, t, tiha); |
758 | + |
759 | + if (path != null) { |
760 | + tihac.setArcPath(new ArcPath(tihac, path)); |
761 | + } |
762 | + |
763 | + Command edit = new AddTimedInhibitorArcCommand( |
764 | + tihac, |
765 | + modelNet, |
766 | + c |
767 | + ); |
768 | + edit.redo(); |
769 | + undoManager.addNewEdit(edit); |
770 | + |
771 | + return new Result<>(tihac); |
772 | + } |
773 | + |
774 | + public Result<TimedTransportArcComponent, ModelViolation> addTimedTransportArc(DataLayer c, TimedPlaceComponent p1, TimedTransitionComponent t, TimedPlaceComponent p2, ArcPath path1, ArcPath path2) { |
775 | Require.notNull(c, "DataLayer can't be null"); |
776 | Require.notNull(p1, "Place1 can't be null"); |
777 | Require.notNull(t, "Transitions can't be null"); |
778 | @@ -257,48 +299,45 @@ |
779 | |
780 | TimedArcPetriNet modelNet = guiModelToModel.get(c); |
781 | |
782 | - if ( |
783 | - !modelNet.hasArcFromPlaceToTransition(p1.underlyingPlace(), t.underlyingTransition()) && |
784 | - !modelNet.hasArcFromTransitionToPlace(t.underlyingTransition(), p2.underlyingPlace()) |
785 | - ) { |
786 | - |
787 | - int groupNr = getNextTransportArcMaxGroupNumber(p1, t); |
788 | - |
789 | - TransportArc tta = new TransportArc(p1.underlyingPlace(), t.underlyingTransition(), p2.underlyingPlace()); |
790 | - |
791 | - TimedTransportArcComponent ttac1 = new TimedTransportArcComponent(p1, t, tta, groupNr); |
792 | - TimedTransportArcComponent ttac2 = new TimedTransportArcComponent(t, p2, tta, groupNr); |
793 | - |
794 | - ttac1.setConnectedTo(ttac2); |
795 | - ttac2.setConnectedTo(ttac1); |
796 | - |
797 | - if (path1 != null) { |
798 | - ttac1.setArcPath(new ArcPath(ttac1, path1)); |
799 | - } |
800 | - if (path2 != null) { |
801 | - ttac2.setArcPath(new ArcPath(ttac2, path2)); |
802 | - } |
803 | - |
804 | - //XXX: the Command should take both arcs |
805 | - Command edit = new AddTransportArcCommand( |
806 | - ttac2, |
807 | - tta, |
808 | - modelNet, |
809 | - c |
810 | - ); |
811 | - edit.redo(); |
812 | - undoManager.addNewEdit(edit); |
813 | - |
814 | - } else { |
815 | - JOptionPane.showMessageDialog( |
816 | - CreateGui.getApp(), |
817 | - "There was an error drawing the arc. Possible problems:\n" |
818 | - + " - There is already an arc between the source place and transition\n" |
819 | - + " - There is already an arc between the transtion and the target place\n" |
820 | - + " - You are attempting to draw an arc between a shared transition and a shared place", |
821 | - "Error", JOptionPane.ERROR_MESSAGE |
822 | - ); |
823 | - } |
824 | + var require = new RequirementChecker<ModelViolation>(); |
825 | + require.Not(modelNet.hasArcFromPlaceToTransition(p1.underlyingPlace(), t.underlyingTransition()), ModelViolation.MaxOneArcBetweenPlaceAndTransition); |
826 | + require.Not(modelNet.hasArcFromTransitionToPlace(t.underlyingTransition(), p2.underlyingPlace()), ModelViolation.MaxOneArcBetweenTransitionAndPlace); |
827 | + require.Not((p1.underlyingPlace().isShared() && t.underlyingTransition().isShared()), ModelViolation.CantHaveArcBetweenSharedPlaceAndTransition); |
828 | + require.Not((p2.underlyingPlace().isShared() && t.underlyingTransition().isShared()), ModelViolation.CantHaveArcBetweenSharedPlaceAndTransition); |
829 | + |
830 | + if (require.failed()) { |
831 | + return new Result<>(require.getErrors()); |
832 | + } |
833 | + |
834 | + |
835 | + int groupNr = getNextTransportArcMaxGroupNumber(p1, t); |
836 | + |
837 | + TransportArc tta = new TransportArc(p1.underlyingPlace(), t.underlyingTransition(), p2.underlyingPlace()); |
838 | + |
839 | + TimedTransportArcComponent ttac1 = new TimedTransportArcComponent(p1, t, tta, groupNr); |
840 | + TimedTransportArcComponent ttac2 = new TimedTransportArcComponent(t, p2, tta, groupNr); |
841 | + |
842 | + ttac1.setConnectedTo(ttac2); |
843 | + ttac2.setConnectedTo(ttac1); |
844 | + |
845 | + if (path1 != null) { |
846 | + ttac1.setArcPath(new ArcPath(ttac1, path1)); |
847 | + } |
848 | + if (path2 != null) { |
849 | + ttac2.setArcPath(new ArcPath(ttac2, path2)); |
850 | + } |
851 | + |
852 | + //XXX: the Command should take both arcs |
853 | + Command edit = new AddTransportArcCommand( |
854 | + ttac2, |
855 | + tta, |
856 | + modelNet, |
857 | + c |
858 | + ); |
859 | + edit.redo(); |
860 | + undoManager.addNewEdit(edit); |
861 | + |
862 | + return new Result<>(ttac1); |
863 | |
864 | } |
865 | |
866 | @@ -316,6 +355,31 @@ |
867 | return groupMaxCounter+1; |
868 | } |
869 | |
870 | + public void addToken(DataLayer d, TimedPlaceComponent p, int numberOfTokens) { |
871 | + Require.notNull(d, "Datalayer can't be null"); |
872 | + Require.notNull(p, "TimedPlaceComponent can't be null"); |
873 | + Require.that(numberOfTokens > 0, "Number of tokens to add must be strictly greater than 0"); |
874 | + |
875 | + Command command = new TimedPlaceMarkingEdit(p, numberOfTokens); |
876 | + command.redo(); |
877 | + undoManager.addNewEdit(command); |
878 | + } |
879 | + |
880 | + public void removeToken(DataLayer d, TimedPlaceComponent p, int numberOfTokens) { |
881 | + Require.notNull(d, "Datalayer can't be null"); |
882 | + Require.notNull(p, "TimedPlaceComponent can't be null"); |
883 | + Require.that(numberOfTokens > 0, "Number of tokens to remove must be strictly greater than 0"); |
884 | + |
885 | + //Can't remove more than the number of tokens |
886 | + int tokensToRemove = Math.min(numberOfTokens, p.getNumberOfTokens()); |
887 | + |
888 | + //Ignore if number of tokens to remove is 0 |
889 | + if (tokensToRemove > 0) { |
890 | + Command command = new TimedPlaceMarkingEdit(p, -tokensToRemove); |
891 | + command.redo(); |
892 | + undoManager.addNewEdit(command); |
893 | + } |
894 | + } |
895 | |
896 | public void deleteSelection() { |
897 | // check if queries need to be removed |
898 | @@ -1434,7 +1498,8 @@ |
899 | |
900 | if (!animationmode) { |
901 | if (numberOfActiveTemplates() > 0) { |
902 | - CreateGui.getApp().setGUIMode(GuiFrame.GUIMode.animation); |
903 | + app.ifPresent(o->o.setGUIMode(GuiFrame.GUIMode.animation)); |
904 | + switchToAnimationComponents(true); |
905 | |
906 | setManager(animationModeController); |
907 | |
908 | @@ -1470,11 +1535,18 @@ |
909 | "You need at least one active template to enter simulation mode", |
910 | "Simulation Mode Error", JOptionPane.ERROR_MESSAGE); |
911 | animationmode = false; |
912 | - CreateGui.getApp().setGUIMode(GuiFrame.GUIMode.draw); |
913 | + app.ifPresent(o->o.setGUIMode(GuiFrame.GUIMode.draw)); |
914 | } |
915 | } else { |
916 | drawingSurface().getSelectionObject().clearSelection(); |
917 | - CreateGui.getApp().setGUIMode(GuiFrame.GUIMode.draw); |
918 | + app.ifPresent(o->o.setGUIMode(GuiFrame.GUIMode.draw)); |
919 | + |
920 | + if (isInAnimationMode()) { |
921 | + getAnimator().restoreModel(); |
922 | + } |
923 | + |
924 | + switchToEditorComponents(); |
925 | + |
926 | setManager(notingManager); |
927 | |
928 | drawingSurface().setBackground(Pipe.ELEMENT_FILL_COLOUR); |
929 | @@ -1507,15 +1579,9 @@ |
930 | public void registerEvents() { |
931 | registerEvent( |
932 | e -> e.pno instanceof TimedPlaceComponent && e.a == MouseAction.pressed, |
933 | - e -> placeClicked((TimedPlaceComponent) e.pno) |
934 | + e -> guiModelManager.addToken(getModel(), (TimedPlaceComponent) e.pno, 1) |
935 | ); |
936 | } |
937 | - |
938 | - public void placeClicked(TimedPlaceComponent pno) { |
939 | - Command command = new TimedPlaceMarkingEdit(pno, 1); |
940 | - command.redo(); |
941 | - undoManager.addNewEdit(command); |
942 | - } |
943 | }); |
944 | break; |
945 | case DELTOKEN: |
946 | @@ -1524,15 +1590,9 @@ |
947 | public void registerEvents() { |
948 | registerEvent( |
949 | e -> e.pno instanceof TimedPlaceComponent && e.a == MouseAction.pressed, |
950 | - e -> placeClicked((TimedPlaceComponent) e.pno) |
951 | + e -> guiModelManager.removeToken(getModel(), (TimedPlaceComponent) e.pno, 1) |
952 | ); |
953 | } |
954 | - |
955 | - public void placeClicked(TimedPlaceComponent pno) { |
956 | - Command command = new TimedPlaceMarkingEdit(pno, -1); |
957 | - command.redo(); |
958 | - undoManager.addNewEdit(command); |
959 | - } |
960 | }); |
961 | break; |
962 | case TAPNPLACE: |
963 | @@ -1660,12 +1720,14 @@ |
964 | |
965 | /* GUI Model / Actions */ |
966 | |
967 | - Optional<GuiFrameActions> app = Optional.empty(); |
968 | - MutableReference<SafeGuiFrameActions> safeApp = new MutableReference<>(); |
969 | + private final MutableReference<GuiFrameActions> app = new MutableReference<>(); |
970 | + private final MutableReference<SafeGuiFrameActions> safeApp = new MutableReference<>(); |
971 | @Override |
972 | public void setApp(GuiFrameActions newApp) { |
973 | - this.app = Optional.ofNullable(newApp); |
974 | - undoManager.setApp(newApp); |
975 | + app.setReference(newApp); |
976 | + undoManager.setApp(app); |
977 | + |
978 | + updateFeatureText(); |
979 | |
980 | updateFeatureText(); |
981 | |
982 | @@ -1918,79 +1980,25 @@ |
983 | } |
984 | } |
985 | |
986 | - class CanvasInhibitorarcDrawController extends AbstractDrawingSurfaceManager { |
987 | + final class CanvasInhibitorarcDrawController extends AbstractCanvasArcDrawController { |
988 | |
989 | private TimedTransitionComponent transition; |
990 | private TimedPlaceComponent place; |
991 | - private Arc arc; |
992 | - |
993 | - @Override |
994 | - public void registerEvents() { |
995 | - registerEvent( |
996 | - e->e.pno instanceof TimedPlaceComponent && e.a == MouseAction.pressed, |
997 | - e->placeClicked(((TimedPlaceComponent) e.pno)) |
998 | - ); |
999 | - registerEvent( |
1000 | - e->e.pno instanceof TimedTransitionComponent && e.a == MouseAction.pressed, |
1001 | - e->transitionClicked(((TimedTransitionComponent) e.pno)) |
1002 | - ); |
1003 | - registerEvent( |
1004 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.entered, |
1005 | - e->placetranstionMouseOver(((PlaceTransitionObject) e.pno)) |
1006 | - ); |
1007 | - registerEvent( |
1008 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.exited, |
1009 | - e->placetranstionMouseExited(((PlaceTransitionObject) e.pno)) |
1010 | - ); |
1011 | - registerEvent( |
1012 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.moved, |
1013 | - e->placetransitionMouseMoved(((PlaceTransitionObject) e.pno), e.e) |
1014 | - ); |
1015 | - } |
1016 | - |
1017 | - private void placetransitionMouseMoved(PlaceTransitionObject pno, MouseEvent e) { |
1018 | - if (arc != null) { |
1019 | - if (arc.getSource() == pno || !arc.getSource().areNotSameType(pno)) { |
1020 | - //Dispatch event to parent (drawing surface) |
1021 | - e.translatePoint(pno.getX(),pno.getY()); |
1022 | - pno.getParent().dispatchEvent(e); |
1023 | - } |
1024 | - } |
1025 | - } |
1026 | - |
1027 | - private void placetranstionMouseExited(PlaceTransitionObject pto) { |
1028 | - if (arc != null) { |
1029 | - arc.setTarget(null); |
1030 | - //XXX this is bad, we have to clean up internal state manually, should be refactored //kyrke - 2019-11-14 |
1031 | - // Relates to bug #1849786 |
1032 | - if (pto instanceof Transition) { |
1033 | - ((Transition)pto).removeArcCompareObject(arc); |
1034 | - } |
1035 | - arc.updateArcPosition(); |
1036 | - } |
1037 | - } |
1038 | - |
1039 | - private void placetranstionMouseOver(PlaceTransitionObject pno) { |
1040 | - if (arc != null) { |
1041 | - if (arc.getSource() != pno && arc.getSource().areNotSameType(pno)) { |
1042 | - arc.setTarget(pno); |
1043 | - arc.updateArcPosition(); |
1044 | - } |
1045 | - } |
1046 | - } |
1047 | - |
1048 | - private void transitionClicked(TimedTransitionComponent pno) { |
1049 | + |
1050 | + protected void transitionClicked(TimedTransitionComponent pno, MouseEvent e) { |
1051 | if (place != null && transition == null) { |
1052 | transition = pno; |
1053 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1054 | - guiModelManager.addInhibitorArc(getModel(), place, transition, arc.getArcPath()); |
1055 | + var result = guiModelManager.addInhibitorArc(getModel(), place, transition, arc.getArcPath()); |
1056 | + showPopupIfFailed(result); |
1057 | clearPendingArc(); |
1058 | } |
1059 | } |
1060 | |
1061 | - private void placeClicked(TimedPlaceComponent pno) { |
1062 | + protected void placeClicked(TimedPlaceComponent pno, MouseEvent e) { |
1063 | if (place == null && transition == null) { |
1064 | place = pno; |
1065 | + connectsTo = 2; |
1066 | arc = new TimedInhibitorArcComponent(pno); |
1067 | //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1068 | //to avoid this we change the endpoint to set the end point to the same as the end point |
1069 | @@ -2000,68 +2008,33 @@ |
1070 | arc.requestFocusInWindow(); |
1071 | arc.setSelectable(false); |
1072 | arc.enableDrawingKeyBindings(this::clearPendingArc); |
1073 | - } else if (transition != null && place == null) { |
1074 | - place = pno; |
1075 | - CreateGui.getDrawingSurface().clearAllPrototype(); |
1076 | - guiModelManager.addTimedOutputArc(getModel(), transition, place, arc.getArcPath()); |
1077 | - clearPendingArc(); |
1078 | } |
1079 | } |
1080 | |
1081 | - private void clearPendingArc() { |
1082 | + @Override |
1083 | + protected void clearPendingArc() { |
1084 | + super.clearPendingArc(); |
1085 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1086 | place = null; |
1087 | transition = null; |
1088 | arc = null; |
1089 | } |
1090 | |
1091 | - @Override |
1092 | - public void drawingSurfaceMouseMoved(MouseEvent e) { |
1093 | - if(arc!=null) { |
1094 | - arc.setEndPoint(e.getX(), e.getY(), e.isShiftDown()); |
1095 | - } |
1096 | - } |
1097 | - |
1098 | - @Override |
1099 | - public void drawingSurfaceMousePressed(MouseEvent e) { |
1100 | - if (arc!=null) { |
1101 | - Point p = e.getPoint(); |
1102 | - int x = Zoomer.getUnzoomedValue(p.x, CreateGui.getDrawingSurface().getZoom()); |
1103 | - int y = Zoomer.getUnzoomedValue(p.y, CreateGui.getDrawingSurface().getZoom()); |
1104 | - |
1105 | - boolean shiftDown = e.isShiftDown(); |
1106 | - //XXX: x,y is ignored is overwritten when mouse is moved, this just add a new point to the end of list |
1107 | - arc.getArcPath().addPoint(arc.getArcPath().getEndIndex(), x,y, shiftDown); |
1108 | - } |
1109 | - } |
1110 | - |
1111 | - @Override |
1112 | - public void registerManager(DrawingSurfaceImpl canvas) { |
1113 | - CreateGui.useExtendedBounds = true; |
1114 | - } |
1115 | - |
1116 | - @Override |
1117 | - public void deregisterManager() { |
1118 | - clearPendingArc(); |
1119 | - CreateGui.useExtendedBounds = false; |
1120 | - } |
1121 | - |
1122 | - |
1123 | } |
1124 | - class CanvasArcDrawController extends AbstractDrawingSurfaceManager { |
1125 | - private TimedTransitionComponent transition; |
1126 | - private TimedPlaceComponent place; |
1127 | - private Arc arc; |
1128 | + |
1129 | + abstract class AbstractCanvasArcDrawController extends AbstractDrawingSurfaceManager { |
1130 | + protected Arc arc; |
1131 | + protected int connectsTo = 1; // 0 if nothing, 1 if place, 2 if transition |
1132 | |
1133 | @Override |
1134 | public void registerEvents() { |
1135 | registerEvent( |
1136 | e->e.pno instanceof TimedPlaceComponent && e.a == MouseAction.pressed, |
1137 | - e->placeClicked(((TimedPlaceComponent) e.pno)) |
1138 | + e->placeClicked(((TimedPlaceComponent) e.pno), e.e) |
1139 | ); |
1140 | registerEvent( |
1141 | e->e.pno instanceof TimedTransitionComponent && e.a == MouseAction.pressed, |
1142 | - e->transitionClicked(((TimedTransitionComponent) e.pno)) |
1143 | + e->transitionClicked(((TimedTransitionComponent) e.pno), e.e) |
1144 | ); |
1145 | registerEvent( |
1146 | e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.entered, |
1147 | @@ -2077,7 +2050,78 @@ |
1148 | ); |
1149 | } |
1150 | |
1151 | - private void placetransitionMouseMoved(PlaceTransitionObject pno, MouseEvent e) { |
1152 | + protected abstract void transitionClicked(TimedTransitionComponent pno, MouseEvent e); |
1153 | + protected abstract void placeClicked(TimedPlaceComponent pno, MouseEvent e); |
1154 | + |
1155 | + protected void clearPendingArc() { |
1156 | + connectsTo = 0; |
1157 | + }; |
1158 | + |
1159 | + @Override |
1160 | + public void setupManager() { |
1161 | + CreateGui.useExtendedBounds = true; |
1162 | + } |
1163 | + |
1164 | + @Override |
1165 | + public void teardownManager() { |
1166 | + clearPendingArc(); |
1167 | + CreateGui.useExtendedBounds = false; |
1168 | + } |
1169 | + |
1170 | + @Override |
1171 | + public void drawingSurfaceMouseMoved(MouseEvent e) { |
1172 | + if(arc!=null) { |
1173 | + arc.setEndPoint(e.getX(), e.getY(), e.isShiftDown()); |
1174 | + } |
1175 | + } |
1176 | + |
1177 | + @Override |
1178 | + public void drawingSurfaceMousePressed(MouseEvent e) { |
1179 | + if (arc!=null) { |
1180 | + if (!e.isControlDown()) { |
1181 | + Point p = e.getPoint(); |
1182 | + int x = Zoomer.getUnzoomedValue(p.x, CreateGui.getDrawingSurface().getZoom()); |
1183 | + int y = Zoomer.getUnzoomedValue(p.y, CreateGui.getDrawingSurface().getZoom()); |
1184 | + |
1185 | + boolean shiftDown = e.isShiftDown(); |
1186 | + //XXX: x,y is ignored is overwritten when mouse is moved, this just add a new point to the end of list |
1187 | + arc.getArcPath().addPoint(arc.getArcPath().getEndIndex(), x, y, shiftDown); |
1188 | + } else if (connectsTo != 0) { // Quick draw |
1189 | + Point p = canvas.adjustPointToGridAndZoom(e.getPoint(), canvas.getZoom()); |
1190 | + |
1191 | + if (connectsTo == 1) { // Place |
1192 | + var r = guiModelManager.addNewTimedPlace(getModel(), p); |
1193 | + placeClicked(r.result, e); |
1194 | + } else { //Transition |
1195 | + var r = guiModelManager.addNewTimedTransitions(getModel(), p); |
1196 | + transitionClicked(r.result, e); |
1197 | + } |
1198 | + } |
1199 | + } else if (e.isControlDown()){ // Quick draw |
1200 | + Point p = canvas.adjustPointToGridAndZoom(e.getPoint(), canvas.getZoom()); |
1201 | + var r = guiModelManager.addNewTimedPlace(getModel(), p); |
1202 | + |
1203 | + placeClicked(r.result, e); |
1204 | + } |
1205 | + } |
1206 | + |
1207 | + protected void showPopupIfFailed(Result<?, ModelViolation> result) { |
1208 | + if (result.hasErrors) { |
1209 | + StringBuilder errorMessage = new StringBuilder(); |
1210 | + errorMessage.append("There was an error drawing the arc. Possible problems:"); |
1211 | + for (ModelViolation v : result.errors) { |
1212 | + errorMessage.append("\n - ").append(v.getErrorMessage()); |
1213 | + } |
1214 | + |
1215 | + JOptionPane.showMessageDialog( |
1216 | + CreateGui.getApp(), |
1217 | + errorMessage, |
1218 | + "Error", JOptionPane.ERROR_MESSAGE |
1219 | + ); |
1220 | + } |
1221 | + } |
1222 | + |
1223 | + protected void placetransitionMouseMoved(PlaceTransitionObject pno, MouseEvent e) { |
1224 | if (arc != null) { |
1225 | if (arc.getSource() == pno || !arc.getSource().areNotSameType(pno)) { |
1226 | //Dispatch event to parent (drawing surface) |
1227 | @@ -2087,7 +2131,7 @@ |
1228 | } |
1229 | } |
1230 | |
1231 | - private void placetranstionMouseExited(PlaceTransitionObject pto) { |
1232 | + protected void placetranstionMouseExited(PlaceTransitionObject pto) { |
1233 | if (arc != null) { |
1234 | arc.setTarget(null); |
1235 | //XXX this is bad, we have to clean up internal state manually, should be refactored //kyrke - 2019-11-14 |
1236 | @@ -2099,7 +2143,7 @@ |
1237 | } |
1238 | } |
1239 | |
1240 | - private void placetranstionMouseOver(PlaceTransitionObject pno) { |
1241 | + protected void placetranstionMouseOver(PlaceTransitionObject pno) { |
1242 | if (arc != null) { |
1243 | if (arc.getSource() != pno && arc.getSource().areNotSameType(pno)) { |
1244 | arc.setTarget(pno); |
1245 | @@ -2107,10 +2151,16 @@ |
1246 | } |
1247 | } |
1248 | } |
1249 | - |
1250 | - private void transitionClicked(TimedTransitionComponent pno) { |
1251 | + } |
1252 | + |
1253 | + final class CanvasArcDrawController extends AbstractCanvasArcDrawController { |
1254 | + private TimedTransitionComponent transition; |
1255 | + private TimedPlaceComponent place; |
1256 | + |
1257 | + protected void transitionClicked(TimedTransitionComponent pno, MouseEvent e) { |
1258 | if (place == null && transition == null) { |
1259 | transition = pno; |
1260 | + connectsTo = 1; |
1261 | arc = new TimedOutputArcComponent(pno); |
1262 | |
1263 | //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1264 | @@ -2124,14 +2174,30 @@ |
1265 | } else if (place != null && transition == null) { |
1266 | transition = pno; |
1267 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1268 | - guiModelManager.addTimedInputArc(getModel(), place, transition, arc.getArcPath()); |
1269 | + var result = guiModelManager.addTimedInputArc(getModel(), place, transition, arc.getArcPath()); |
1270 | + showPopupIfFailed(result); |
1271 | clearPendingArc(); |
1272 | + |
1273 | + if (e != null && e.isControlDown()) { |
1274 | + transition = pno; |
1275 | + connectsTo = 1; |
1276 | + arc = new TimedOutputArcComponent(pno); |
1277 | + //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1278 | + //to avoid this we change the endpoint to set the end point to the same as the end point |
1279 | + //needs further refactorings //kyrke 2019-09-05 |
1280 | + arc.setEndPoint(pno.getPositionX(), pno.getPositionY(), false); |
1281 | + CreateGui.getDrawingSurface().addPrototype(arc); |
1282 | + arc.requestFocusInWindow(); |
1283 | + arc.setSelectable(false); |
1284 | + arc.enableDrawingKeyBindings(this::clearPendingArc); |
1285 | + } |
1286 | } |
1287 | } |
1288 | |
1289 | - private void placeClicked(TimedPlaceComponent pno) { |
1290 | + protected void placeClicked(TimedPlaceComponent pno, MouseEvent e) { |
1291 | if (place == null && transition == null) { |
1292 | place = pno; |
1293 | + connectsTo = 2; |
1294 | arc = new TimedInputArcComponent(pno); |
1295 | //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1296 | //to avoid this we change the endpoint to set the end point to the same as the end point |
1297 | @@ -2144,48 +2210,35 @@ |
1298 | } else if (transition != null && place == null) { |
1299 | place = pno; |
1300 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1301 | - guiModelManager.addTimedOutputArc(getModel(), transition, place, arc.getArcPath()); |
1302 | + var result = guiModelManager.addTimedOutputArc(getModel(), transition, place, arc.getArcPath()); |
1303 | + showPopupIfFailed(result); |
1304 | clearPendingArc(); |
1305 | + |
1306 | + if (e!= null && e.isControlDown()) { |
1307 | + place = pno; |
1308 | + connectsTo = 2; |
1309 | + arc = new TimedInputArcComponent(pno); |
1310 | + //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1311 | + //to avoid this we change the endpoint to set the end point to the same as the end point |
1312 | + //needs further refactorings //kyrke 2019-09-05 |
1313 | + arc.setEndPoint(pno.getPositionX(), pno.getPositionY(), false); |
1314 | + CreateGui.getDrawingSurface().addPrototype(arc); |
1315 | + arc.requestFocusInWindow(); |
1316 | + arc.setSelectable(false); |
1317 | + arc.enableDrawingKeyBindings(this::clearPendingArc); |
1318 | + } |
1319 | } |
1320 | } |
1321 | |
1322 | - private void clearPendingArc() { |
1323 | + @Override |
1324 | + protected void clearPendingArc() { |
1325 | + super.clearPendingArc(); |
1326 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1327 | place = null; |
1328 | transition = null; |
1329 | arc = null; |
1330 | } |
1331 | |
1332 | - @Override |
1333 | - public void drawingSurfaceMouseMoved(MouseEvent e) { |
1334 | - if(arc!=null) { |
1335 | - arc.setEndPoint(e.getX(), e.getY(), e.isShiftDown()); |
1336 | - } |
1337 | - } |
1338 | - |
1339 | - @Override |
1340 | - public void drawingSurfaceMousePressed(MouseEvent e) { |
1341 | - if (arc!=null) { |
1342 | - Point p = e.getPoint(); |
1343 | - int x = Zoomer.getUnzoomedValue(p.x, CreateGui.getDrawingSurface().getZoom()); |
1344 | - int y = Zoomer.getUnzoomedValue(p.y, CreateGui.getDrawingSurface().getZoom()); |
1345 | - |
1346 | - boolean shiftDown = e.isShiftDown(); |
1347 | - //XXX: x,y is ignored is overwritten when mouse is moved, this just add a new point to the end of list |
1348 | - arc.getArcPath().addPoint(arc.getArcPath().getEndIndex(), x,y, shiftDown); |
1349 | - } |
1350 | - } |
1351 | - |
1352 | - @Override |
1353 | - public void registerManager(DrawingSurfaceImpl canvas) { |
1354 | - CreateGui.useExtendedBounds = true; |
1355 | - } |
1356 | - |
1357 | - @Override |
1358 | - public void deregisterManager() { |
1359 | - clearPendingArc(); |
1360 | - CreateGui.useExtendedBounds = false; |
1361 | - } |
1362 | } |
1363 | |
1364 | static class CanvasAnimationController extends AbstractDrawingSurfaceManager { |
1365 | @@ -2234,7 +2287,23 @@ |
1366 | ((TimedTransitionComponent) pto).showDInterval(false); |
1367 | } |
1368 | } |
1369 | - } |
1370 | + |
1371 | + @Override |
1372 | + public void teardownManager() { |
1373 | + //Remove all mouse-over menus if we exit animation mode |
1374 | + ArrayList<PetriNetObject> selection = CreateGui.getCurrentTab().drawingSurface().getGuiModel().getPNObjects(); |
1375 | + |
1376 | + for (PetriNetObject pn : selection) { |
1377 | + if (pn instanceof TimedPlaceComponent) { |
1378 | + TimedPlaceComponent place = (TimedPlaceComponent) pn; |
1379 | + place.showAgeOfTokens(false); |
1380 | + } else if (pn instanceof TimedTransitionComponent) { |
1381 | + TimedTransitionComponent transition = (TimedTransitionComponent) pn; |
1382 | + transition.showDInterval(false); |
1383 | + } |
1384 | + } |
1385 | + } |
1386 | + } |
1387 | |
1388 | |
1389 | MutableReference<AbstractDrawingSurfaceManager> managerRef = new MutableReference<>(notingManager); |
1390 | @@ -2257,51 +2326,16 @@ |
1391 | return lens; |
1392 | } |
1393 | |
1394 | - private final class CanvasTransportarcDrawController extends AbstractDrawingSurfaceManager { |
1395 | + |
1396 | + private final class CanvasTransportarcDrawController extends AbstractCanvasArcDrawController { |
1397 | |
1398 | private TimedTransitionComponent transition; |
1399 | private TimedPlaceComponent place1; |
1400 | private TimedPlaceComponent place2; |
1401 | - private Arc arc; |
1402 | private Arc arc1; |
1403 | private Arc arc2; |
1404 | |
1405 | - |
1406 | - @Override |
1407 | - public void registerEvents() { |
1408 | - registerEvent( |
1409 | - e->e.pno instanceof TimedPlaceComponent && e.a == MouseAction.pressed, |
1410 | - e->placeClicked(((TimedPlaceComponent) e.pno)) |
1411 | - ); |
1412 | - registerEvent( |
1413 | - e->e.pno instanceof TimedTransitionComponent && e.a == MouseAction.pressed, |
1414 | - e->transitionClicked(((TimedTransitionComponent) e.pno)) |
1415 | - ); |
1416 | - registerEvent( |
1417 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.entered, |
1418 | - e->placetranstionMouseOver(((PlaceTransitionObject) e.pno)) |
1419 | - ); |
1420 | - registerEvent( |
1421 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.exited, |
1422 | - e->placetranstionMouseExited(((PlaceTransitionObject) e.pno)) |
1423 | - ); |
1424 | - registerEvent( |
1425 | - e->e.pno instanceof PlaceTransitionObject && e.a == MouseAction.moved, |
1426 | - e->placetransitionMouseMoved(((PlaceTransitionObject) e.pno), e.e) |
1427 | - ); |
1428 | - } |
1429 | - |
1430 | - private void placetransitionMouseMoved(PlaceTransitionObject pno, MouseEvent e) { |
1431 | - if (arc != null) { |
1432 | - if (arc.getSource() == pno || !arc.getSource().areNotSameType(pno)) { |
1433 | - //Dispatch event to parent (drawing surface) |
1434 | - e.translatePoint(pno.getX(),pno.getY()); |
1435 | - pno.getParent().dispatchEvent(e); |
1436 | - } |
1437 | - } |
1438 | - } |
1439 | - |
1440 | - private void placetranstionMouseExited(PlaceTransitionObject pto) { |
1441 | + protected void placetranstionMouseExited(PlaceTransitionObject pto) { |
1442 | if (arc != null) { |
1443 | arc.setTarget(null); |
1444 | //XXX this is bad, we have to clean up internal state manually, should be refactored //kyrke - 2019-11-14 |
1445 | @@ -2313,7 +2347,7 @@ |
1446 | } |
1447 | } |
1448 | |
1449 | - private void placetranstionMouseOver(PlaceTransitionObject pno) { |
1450 | + protected void placetranstionMouseOver(PlaceTransitionObject pno) { |
1451 | if (arc != null) { |
1452 | if (arc.getSource() != pno && arc.getSource().areNotSameType(pno)) { |
1453 | arc.setTarget(pno); |
1454 | @@ -2322,9 +2356,10 @@ |
1455 | } |
1456 | } |
1457 | |
1458 | - private void transitionClicked(TimedTransitionComponent pno) { |
1459 | + protected void transitionClicked(TimedTransitionComponent pno, MouseEvent e) { |
1460 | if (place1 != null && transition == null) { |
1461 | transition = pno; |
1462 | + connectsTo = 1; |
1463 | arc2 = arc = new TimedTransportArcComponent(pno, -1, false); |
1464 | |
1465 | //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1466 | @@ -2338,9 +2373,10 @@ |
1467 | } |
1468 | } |
1469 | |
1470 | - private void placeClicked(TimedPlaceComponent pno) { |
1471 | + protected void placeClicked(TimedPlaceComponent pno, MouseEvent e) { |
1472 | if (place1 == null && transition == null) { |
1473 | place1 = pno; |
1474 | + connectsTo = 2; |
1475 | arc1 = arc = new TimedTransportArcComponent(pno, -1, true); |
1476 | //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1477 | //to avoid this we change the endpoint to set the end point to the same as the end point |
1478 | @@ -2353,48 +2389,35 @@ |
1479 | } else if (transition != null && place2 == null) { |
1480 | place2 = pno; |
1481 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1482 | - guiModelManager.addTimedTransportArc(getModel(), place1, transition, place2, arc1.getArcPath(), arc2.getArcPath()); |
1483 | + var result = guiModelManager.addTimedTransportArc(getModel(), place1, transition, place2, arc1.getArcPath(), arc2.getArcPath()); |
1484 | + showPopupIfFailed(result); |
1485 | clearPendingArc(); |
1486 | + |
1487 | + if (e != null && e.isControlDown()) { |
1488 | + place1 = pno; |
1489 | + connectsTo = 2; |
1490 | + arc1 = arc = new TimedTransportArcComponent(pno, -1, true); |
1491 | + //XXX calling zoomUpdate will set the endpoint to 0,0, drawing the arc from source to 0,0 |
1492 | + //to avoid this we change the endpoint to set the end point to the same as the end point |
1493 | + //needs further refactorings //kyrke 2019-09-05 |
1494 | + arc.setEndPoint(pno.getPositionX(), pno.getPositionY(), false); |
1495 | + CreateGui.getDrawingSurface().addPrototype(arc); |
1496 | + arc.requestFocusInWindow(); |
1497 | + arc.setSelectable(false); |
1498 | + arc.enableDrawingKeyBindings(this::clearPendingArc); |
1499 | + } |
1500 | } |
1501 | } |
1502 | |
1503 | - private void clearPendingArc() { |
1504 | + @Override |
1505 | + protected void clearPendingArc() { |
1506 | + super.clearPendingArc(); |
1507 | CreateGui.getDrawingSurface().clearAllPrototype(); |
1508 | place1 = place2 = null; |
1509 | transition = null; |
1510 | arc = arc1 = arc2 = null; |
1511 | } |
1512 | |
1513 | - @Override |
1514 | - public void drawingSurfaceMouseMoved(MouseEvent e) { |
1515 | - if(arc!=null) { |
1516 | - arc.setEndPoint(e.getX(), e.getY(), e.isShiftDown()); |
1517 | - } |
1518 | - } |
1519 | - |
1520 | - @Override |
1521 | - public void drawingSurfaceMousePressed(MouseEvent e) { |
1522 | - if (arc!=null) { |
1523 | - Point p = e.getPoint(); |
1524 | - int x = Zoomer.getUnzoomedValue(p.x, CreateGui.getDrawingSurface().getZoom()); |
1525 | - int y = Zoomer.getUnzoomedValue(p.y, CreateGui.getDrawingSurface().getZoom()); |
1526 | - |
1527 | - boolean shiftDown = e.isShiftDown(); |
1528 | - //XXX: x,y is ignored is overwritten when mouse is moved, this just add a new point to the end of list |
1529 | - arc.getArcPath().addPoint(arc.getArcPath().getEndIndex(), x,y, shiftDown); |
1530 | - } |
1531 | - } |
1532 | - |
1533 | - @Override |
1534 | - public void registerManager(DrawingSurfaceImpl canvas) { |
1535 | - CreateGui.useExtendedBounds = true; |
1536 | - } |
1537 | - |
1538 | - @Override |
1539 | - public void deregisterManager() { |
1540 | - clearPendingArc(); |
1541 | - CreateGui.useExtendedBounds = false; |
1542 | - } |
1543 | } |
1544 | |
1545 | private class CanvasGeneralDrawController extends AbstractDrawingSurfaceManager { |
1546 | @@ -2437,14 +2460,41 @@ |
1547 | e -> ((Arc)e.pno).getArcPath().hidePoints() |
1548 | ); |
1549 | registerEvent( |
1550 | + e->e.pno instanceof TimedOutputArcComponent && e.a == MouseAction.doubleClicked && !e.e.isControlDown(), |
1551 | + e -> ((TimedOutputArcComponent) e.pno).showTimeIntervalEditor() |
1552 | + ); |
1553 | + registerEvent( |
1554 | e->e.pno instanceof Arc && e.a == MouseAction.doubleClicked && e.e.isControlDown(), |
1555 | e->arcDoubleClickedWithContrl(((Arc) e.pno), e.e) |
1556 | ); |
1557 | registerEvent( |
1558 | - e->e.pno instanceof TimedOutputArcComponent && e.a == MouseAction.doubleClicked && !e.e.isControlDown(), |
1559 | - e -> ((TimedOutputArcComponent) e.pno).showTimeIntervalEditor() |
1560 | - ); |
1561 | - |
1562 | + e->e.pno instanceof TimedPlaceComponent && e.a == MouseAction.wheel && e.e.isShiftDown(), |
1563 | + e->timedPlaceMouseWheelWithShift(((TimedPlaceComponent) e.pno), ((MouseWheelEvent) e.e)) |
1564 | + ); |
1565 | + registerEvent( |
1566 | + e->e.pno instanceof TimedTransitionComponent && e.a == MouseAction.wheel && e.e.isShiftDown(), |
1567 | + e->timedTranstionMouseWheelWithShift(((TimedTransitionComponent) e.pno), ((MouseWheelEvent) e.e)) |
1568 | + ); |
1569 | + |
1570 | + } |
1571 | + |
1572 | + private void timedTranstionMouseWheelWithShift(TimedTransitionComponent p, MouseWheelEvent e) { |
1573 | + int rotation = 0; |
1574 | + if (e.getWheelRotation() < 0) { |
1575 | + rotation = -e.getWheelRotation() * 135; |
1576 | + } else { |
1577 | + rotation = e.getWheelRotation() * 45; |
1578 | + } |
1579 | + |
1580 | + CreateGui.getCurrentTab().getUndoManager().addNewEdit(((Transition) p).rotate(rotation)); |
1581 | + } |
1582 | + |
1583 | + private void timedPlaceMouseWheelWithShift(TimedPlaceComponent p, MouseWheelEvent e) { |
1584 | + if (e.getWheelRotation() < 0) { |
1585 | + guiModelManager.addToken(getModel(), p, 1); |
1586 | + } else { |
1587 | + guiModelManager.removeToken(getModel(), p, 1); |
1588 | + } |
1589 | } |
1590 | |
1591 | private void arcDoubleClickedWithContrl(Arc arc, MouseEvent e) { |
1592 | |
1593 | === modified file 'src/dk/aau/cs/gui/TabTransformer.java' |
1594 | --- src/dk/aau/cs/gui/TabTransformer.java 2020-05-06 15:19:14 +0000 |
1595 | +++ src/dk/aau/cs/gui/TabTransformer.java 2020-08-10 09:00:56 +0000 |
1596 | @@ -51,7 +51,7 @@ |
1597 | DataLayer guiModel = template.guiModel(); |
1598 | Place guiSource = guiModel.getPlaceByName(arc.getSource().getName()); |
1599 | Transition guiTarget = guiModel.getTransitionByName(arc.getTarget().getName()); |
1600 | - Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
1601 | + TimedInputArcComponent newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
1602 | guiSource, |
1603 | guiTarget, |
1604 | arc.getWeight().value(), |
1605 | @@ -64,7 +64,7 @@ |
1606 | ArcPath newArcPath = createArcPath(guiModel, oldGuiSource, oldGuiTarget, newArc); |
1607 | |
1608 | // Set arcPath, guiModel and connectors |
1609 | - ((TimedInputArcComponent) newArc).setUnderlyingArc(addedArc); |
1610 | + newArc.setUnderlyingArc(addedArc); |
1611 | newArc.setArcPath(newArcPath); |
1612 | newArc.updateArcPosition(); |
1613 | guiModel.addPetriNetObject(newArc); |
1614 | |
1615 | === modified file 'src/dk/aau/cs/gui/TemplateExplorer.java' |
1616 | --- src/dk/aau/cs/gui/TemplateExplorer.java 2020-08-04 08:07:21 +0000 |
1617 | +++ src/dk/aau/cs/gui/TemplateExplorer.java 2020-08-10 09:00:56 +0000 |
1618 | @@ -19,7 +19,6 @@ |
1619 | |
1620 | import javax.swing.BorderFactory; |
1621 | import javax.swing.DefaultListModel; |
1622 | -import javax.swing.ImageIcon; |
1623 | import javax.swing.JButton; |
1624 | import javax.swing.JCheckBox; |
1625 | import javax.swing.JComponent; |
1626 | |
1627 | === modified file 'src/dk/aau/cs/gui/components/ConstantsListModel.java' |
1628 | --- src/dk/aau/cs/gui/components/ConstantsListModel.java 2020-07-13 13:58:47 +0000 |
1629 | +++ src/dk/aau/cs/gui/components/ConstantsListModel.java 2020-08-10 09:00:56 +0000 |
1630 | @@ -8,7 +8,7 @@ |
1631 | import dk.aau.cs.model.tapn.event.ConstantEvent; |
1632 | import dk.aau.cs.model.tapn.event.ConstantsListener; |
1633 | |
1634 | -public class ConstantsListModel extends AbstractListModel { |
1635 | +public class ConstantsListModel extends AbstractListModel<Constant> { |
1636 | |
1637 | private TimedArcPetriNetNetwork network; |
1638 | |
1639 | |
1640 | === modified file 'src/dk/aau/cs/gui/components/EnabledTransitionsList.java' |
1641 | --- src/dk/aau/cs/gui/components/EnabledTransitionsList.java 2020-06-21 11:02:36 +0000 |
1642 | +++ src/dk/aau/cs/gui/components/EnabledTransitionsList.java 2020-08-10 09:00:56 +0000 |
1643 | @@ -1,11 +1,7 @@ |
1644 | package dk.aau.cs.gui.components; |
1645 | |
1646 | import java.awt.BorderLayout; |
1647 | -import java.awt.Color; |
1648 | -import java.awt.Component; |
1649 | import java.awt.Dimension; |
1650 | -import java.awt.Graphics; |
1651 | -import java.awt.Insets; |
1652 | |
1653 | import java.awt.event.MouseAdapter; |
1654 | import java.awt.event.MouseEvent; |
1655 | @@ -13,20 +9,17 @@ |
1656 | import java.util.Arrays; |
1657 | import java.util.Random; |
1658 | |
1659 | -import javax.swing.DefaultListCellRenderer; |
1660 | import javax.swing.DefaultListModel; |
1661 | -import javax.swing.JLabel; |
1662 | import javax.swing.JList; |
1663 | import javax.swing.JPanel; |
1664 | import javax.swing.JScrollPane; |
1665 | -import javax.swing.border.Border; |
1666 | |
1667 | import dk.aau.cs.util.IntervalOperations; |
1668 | import dk.aau.cs.util.StringComparator; |
1669 | |
1670 | +import org.jetbrains.annotations.NotNull; |
1671 | import pipe.dataLayer.Template; |
1672 | import pipe.gui.CreateGui; |
1673 | -import pipe.gui.GuiFrame; |
1674 | import pipe.gui.graphicElements.Transition; |
1675 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; |
1676 | //TODO clean up!!! |
1677 | @@ -173,7 +166,7 @@ |
1678 | return template.model().getTransitionByName(transition.getName()).isShared(); |
1679 | } |
1680 | |
1681 | - public int compareTo(ListItem o) { |
1682 | + public int compareTo(@NotNull ListItem o) { |
1683 | if(o instanceof TransitionListItem){ |
1684 | return compareTo((TransitionListItem)o); |
1685 | } else { |
1686 | @@ -188,8 +181,8 @@ |
1687 | //Sort according to lower bound |
1688 | int result = thisLower.compareTo(otherLower); |
1689 | //According to strict non strict |
1690 | - if(result == 0 && this.transition.getDInterval().IsLowerBoundNonStrict() != o.transition.getDInterval().IsLowerBoundNonStrict()){ |
1691 | - if(this.transition.getDInterval().IsLowerBoundNonStrict()){ |
1692 | + if(result == 0 && this.transition.getDInterval().isLowerBoundNonStrict() != o.transition.getDInterval().isLowerBoundNonStrict()){ |
1693 | + if(this.transition.getDInterval().isLowerBoundNonStrict()){ |
1694 | result = -1; |
1695 | } else { |
1696 | result = 1; |
1697 | |
1698 | === modified file 'src/dk/aau/cs/gui/components/NonsearchableJComboBox.java' |
1699 | --- src/dk/aau/cs/gui/components/NonsearchableJComboBox.java 2020-04-18 12:27:02 +0000 |
1700 | +++ src/dk/aau/cs/gui/components/NonsearchableJComboBox.java 2020-08-10 09:00:56 +0000 |
1701 | @@ -19,7 +19,7 @@ |
1702 | removeKeyListener(); |
1703 | } |
1704 | |
1705 | - public NonsearchableJComboBox(ComboBoxModel aModel) { |
1706 | + public NonsearchableJComboBox(ComboBoxModel<E> aModel) { |
1707 | super(aModel); |
1708 | removeKeyListener(); |
1709 | } |
1710 | |
1711 | === modified file 'src/dk/aau/cs/gui/components/StatisticsPanel.java' |
1712 | --- src/dk/aau/cs/gui/components/StatisticsPanel.java 2020-08-04 06:34:24 +0000 |
1713 | +++ src/dk/aau/cs/gui/components/StatisticsPanel.java 2020-08-10 09:00:56 +0000 |
1714 | @@ -12,7 +12,6 @@ |
1715 | import javax.swing.JPanel; |
1716 | import javax.swing.JSeparator; |
1717 | |
1718 | -import dk.aau.cs.TCTL.TCTLStateToPathConverter; |
1719 | import dk.aau.cs.model.tapn.TimedPlace; |
1720 | import pipe.gui.*; |
1721 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; |
1722 | |
1723 | === modified file 'src/dk/aau/cs/gui/undo/AddFileBatchProcessingCommand.java' |
1724 | --- src/dk/aau/cs/gui/undo/AddFileBatchProcessingCommand.java 2020-07-13 13:58:47 +0000 |
1725 | +++ src/dk/aau/cs/gui/undo/AddFileBatchProcessingCommand.java 2020-08-10 09:00:56 +0000 |
1726 | @@ -1,8 +1,6 @@ |
1727 | package dk.aau.cs.gui.undo; |
1728 | |
1729 | import dk.aau.cs.gui.BatchProcessingDialog; |
1730 | -import dk.aau.cs.gui.SharedPlacesAndTransitionsPanel; |
1731 | -import dk.aau.cs.model.tapn.SharedPlace; |
1732 | |
1733 | import javax.swing.*; |
1734 | import java.io.File; |
1735 | @@ -10,9 +8,10 @@ |
1736 | |
1737 | public class AddFileBatchProcessingCommand extends Command{ |
1738 | private final DefaultListModel<File> listModel; |
1739 | - List<File> files; |
1740 | - File file; |
1741 | + final List<File> files; |
1742 | + final File file; |
1743 | private final BatchProcessingDialog dialog; |
1744 | + |
1745 | public AddFileBatchProcessingCommand(DefaultListModel<File> listModel, File file, List<File> files, BatchProcessingDialog dialog){ |
1746 | this.listModel = listModel; |
1747 | this.file = file; |
1748 | |
1749 | === modified file 'src/dk/aau/cs/gui/undo/MoveElementDownCommand.java' |
1750 | --- src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 2020-05-05 18:44:30 +0000 |
1751 | +++ src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 2020-08-10 09:00:56 +0000 |
1752 | @@ -1,15 +1,12 @@ |
1753 | package dk.aau.cs.gui.undo; |
1754 | |
1755 | -import pipe.dataLayer.Template; |
1756 | import pipe.gui.widgets.SidePane; |
1757 | |
1758 | -import javax.swing.*; |
1759 | - |
1760 | public class MoveElementDownCommand extends Command{ |
1761 | - int oldIndex; |
1762 | - int newIndex; |
1763 | - SidePane sidePane; |
1764 | - JList<Template> templateList; |
1765 | + final int oldIndex; |
1766 | + final int newIndex; |
1767 | + final SidePane sidePane; |
1768 | + |
1769 | public MoveElementDownCommand(SidePane sidePane, int oldIndex, int newIndex){ |
1770 | this.oldIndex = oldIndex; |
1771 | this.newIndex = newIndex; |
1772 | |
1773 | === modified file 'src/dk/aau/cs/gui/undo/MoveElementUpCommand.java' |
1774 | --- src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 2020-05-03 11:28:45 +0000 |
1775 | +++ src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 2020-08-10 09:00:56 +0000 |
1776 | @@ -1,15 +1,12 @@ |
1777 | package dk.aau.cs.gui.undo; |
1778 | |
1779 | -import pipe.dataLayer.Template; |
1780 | import pipe.gui.widgets.SidePane; |
1781 | |
1782 | -import javax.swing.*; |
1783 | - |
1784 | public class MoveElementUpCommand extends Command{ |
1785 | - int oldIndex; |
1786 | - int newIndex; |
1787 | - SidePane sidePane; |
1788 | - JList<Template> templateList; |
1789 | + final int oldIndex; |
1790 | + final int newIndex; |
1791 | + final SidePane sidePane; |
1792 | + |
1793 | public MoveElementUpCommand(SidePane sidePane, int oldIndex, int newIndex){ |
1794 | this.oldIndex = oldIndex; |
1795 | this.newIndex = newIndex; |
1796 | |
1797 | === modified file 'src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java' |
1798 | --- src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-07-13 13:58:47 +0000 |
1799 | +++ src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-08-10 09:00:56 +0000 |
1800 | @@ -10,15 +10,16 @@ |
1801 | private final int newY; |
1802 | private final int newX; |
1803 | private final PlaceTransitionObject objectToBeMoved; |
1804 | - private int oldY; |
1805 | - private int oldX; |
1806 | - private boolean doUpdate = false; |
1807 | + private final int oldY; |
1808 | + private final int oldX; |
1809 | |
1810 | |
1811 | public MovePlaceTransitionObject(PlaceTransitionObject object, Point point) { |
1812 | objectToBeMoved = object; |
1813 | this.newX = point.x; |
1814 | this.newY = point.y; |
1815 | + this.oldY = objectToBeMoved.getOriginalY(); |
1816 | + this.oldX = objectToBeMoved.getOriginalX(); |
1817 | } |
1818 | |
1819 | @Override |
1820 | @@ -34,19 +35,14 @@ |
1821 | |
1822 | @Override |
1823 | public void redo() { |
1824 | - oldY = objectToBeMoved.getOriginalY(); |
1825 | - oldX = objectToBeMoved.getOriginalX(); |
1826 | - |
1827 | objectToBeMoved.setOriginalX(newX); |
1828 | objectToBeMoved.setOriginalY(newY); |
1829 | |
1830 | - if(doUpdate) { |
1831 | - objectToBeMoved.updateOnMoveOrZoom(); |
1832 | - objectToBeMoved.repaint(); |
1833 | - CreateGui.getDrawingSurface().updatePreferredSize(); |
1834 | - } |
1835 | - doUpdate = true; |
1836 | - |
1837 | + |
1838 | + objectToBeMoved.updateOnMoveOrZoom(); |
1839 | + objectToBeMoved.repaint(); |
1840 | + CreateGui.getDrawingSurface().updatePreferredSize(); |
1841 | + |
1842 | } |
1843 | |
1844 | } |
1845 | |
1846 | === modified file 'src/dk/aau/cs/gui/undo/RemoveFileBatchProcessingCommand.java' |
1847 | --- src/dk/aau/cs/gui/undo/RemoveFileBatchProcessingCommand.java 2020-07-13 13:58:47 +0000 |
1848 | +++ src/dk/aau/cs/gui/undo/RemoveFileBatchProcessingCommand.java 2020-08-10 09:00:56 +0000 |
1849 | @@ -1,8 +1,6 @@ |
1850 | package dk.aau.cs.gui.undo; |
1851 | |
1852 | import dk.aau.cs.gui.BatchProcessingDialog; |
1853 | -import dk.aau.cs.gui.SharedPlacesAndTransitionsPanel; |
1854 | -import dk.aau.cs.model.tapn.SharedPlace; |
1855 | |
1856 | import javax.swing.*; |
1857 | import java.io.File; |
1858 | @@ -10,8 +8,8 @@ |
1859 | |
1860 | public class RemoveFileBatchProcessingCommand extends Command{ |
1861 | private final DefaultListModel<File> listModel; |
1862 | - List<File> files; |
1863 | - File file; |
1864 | + final List<File> files; |
1865 | + final File file; |
1866 | private final BatchProcessingDialog dialog; |
1867 | public RemoveFileBatchProcessingCommand(DefaultListModel<File> listModel, File file, List<File> files, BatchProcessingDialog dialog){ |
1868 | this.listModel = listModel; |
1869 | |
1870 | === modified file 'src/dk/aau/cs/gui/undo/SortConstantsCommand.java' |
1871 | --- src/dk/aau/cs/gui/undo/SortConstantsCommand.java 2012-01-27 13:27:31 +0000 |
1872 | +++ src/dk/aau/cs/gui/undo/SortConstantsCommand.java 2020-08-10 09:00:56 +0000 |
1873 | @@ -6,8 +6,8 @@ |
1874 | |
1875 | public class SortConstantsCommand extends Command{ |
1876 | |
1877 | - TabContent tabContent; |
1878 | - ConstantsPane constantsPane; |
1879 | + final TabContent tabContent; |
1880 | + final ConstantsPane constantsPane; |
1881 | Constant[] oldOrder; |
1882 | |
1883 | public SortConstantsCommand(TabContent tabContent, ConstantsPane constantsPane) { |
1884 | |
1885 | === modified file 'src/dk/aau/cs/gui/undo/SortQueriesCommand.java' |
1886 | --- src/dk/aau/cs/gui/undo/SortQueriesCommand.java 2012-01-27 13:27:31 +0000 |
1887 | +++ src/dk/aau/cs/gui/undo/SortQueriesCommand.java 2020-08-10 09:00:56 +0000 |
1888 | @@ -8,7 +8,7 @@ |
1889 | |
1890 | public class SortQueriesCommand extends Command { |
1891 | |
1892 | - DefaultListModel listModel; |
1893 | + final DefaultListModel listModel; |
1894 | Object[] oldOrder; |
1895 | |
1896 | public SortQueriesCommand(DefaultListModel listModel) { |
1897 | |
1898 | === modified file 'src/dk/aau/cs/gui/undo/SortSharedPlacesCommand.java' |
1899 | --- src/dk/aau/cs/gui/undo/SortSharedPlacesCommand.java 2012-01-27 13:27:31 +0000 |
1900 | +++ src/dk/aau/cs/gui/undo/SortSharedPlacesCommand.java 2020-08-10 09:00:56 +0000 |
1901 | @@ -5,7 +5,7 @@ |
1902 | |
1903 | public class SortSharedPlacesCommand extends Command { |
1904 | |
1905 | - SharedPlacesListModel listModel; |
1906 | + final SharedPlacesListModel listModel; |
1907 | SharedPlace[] oldOrder; |
1908 | |
1909 | public SortSharedPlacesCommand(SharedPlacesListModel listModel) { |
1910 | |
1911 | === modified file 'src/dk/aau/cs/gui/undo/SortSharedTransitionsCommand.java' |
1912 | --- src/dk/aau/cs/gui/undo/SortSharedTransitionsCommand.java 2019-03-22 10:13:18 +0000 |
1913 | +++ src/dk/aau/cs/gui/undo/SortSharedTransitionsCommand.java 2020-08-10 09:00:56 +0000 |
1914 | @@ -5,7 +5,7 @@ |
1915 | |
1916 | public class SortSharedTransitionsCommand extends Command { |
1917 | |
1918 | - SharedTransitionsListModel listModel; |
1919 | + final SharedTransitionsListModel listModel; |
1920 | SharedTransition[] oldOrder; |
1921 | |
1922 | public SortSharedTransitionsCommand(SharedTransitionsListModel listModel) { |
1923 | |
1924 | === modified file 'src/dk/aau/cs/gui/undo/SortTemplatesCommand.java' |
1925 | --- src/dk/aau/cs/gui/undo/SortTemplatesCommand.java 2019-03-23 23:24:37 +0000 |
1926 | +++ src/dk/aau/cs/gui/undo/SortTemplatesCommand.java 2020-08-10 09:00:56 +0000 |
1927 | @@ -10,10 +10,10 @@ |
1928 | |
1929 | public class SortTemplatesCommand extends Command{ |
1930 | TimedArcPetriNet[] oldOrder; |
1931 | - TabContent tabContent; |
1932 | - TemplateExplorer templateExplorer; |
1933 | - JList<Template> templateList; |
1934 | - DefaultListModel<Template> listModel; |
1935 | + final TabContent tabContent; |
1936 | + final TemplateExplorer templateExplorer; |
1937 | + final JList<Template> templateList; |
1938 | + final DefaultListModel<Template> listModel; |
1939 | |
1940 | public SortTemplatesCommand(TabContent tabContent, TemplateExplorer templateExplorer, JList<Template> templateList, DefaultListModel<Template> listModel) { |
1941 | this.templateList = templateList; |
1942 | |
1943 | === modified file 'src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java' |
1944 | --- src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-04-30 12:57:50 +0000 |
1945 | +++ src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-08-10 09:00:56 +0000 |
1946 | @@ -3,8 +3,11 @@ |
1947 | import pipe.gui.graphicElements.PetriNetObjectWithLabel; |
1948 | |
1949 | public class UpdateNameLabelOffsetCommand extends Command { |
1950 | - int newXOffset, newYOffset, oldXOffset, oldYOffset; |
1951 | - PetriNetObjectWithLabel obj; |
1952 | + final int newXOffset; |
1953 | + final int newYOffset; |
1954 | + final int oldXOffset; |
1955 | + final int oldYOffset; |
1956 | + final PetriNetObjectWithLabel obj; |
1957 | |
1958 | public UpdateNameLabelOffsetCommand(int newXOffset, int newYOffset, int oldXOffset, int oldYOffset, PetriNetObjectWithLabel obj) { |
1959 | this.obj = obj; |
1960 | |
1961 | === modified file 'src/dk/aau/cs/io/LoadedModel.java' |
1962 | --- src/dk/aau/cs/io/LoadedModel.java 2020-08-04 08:07:21 +0000 |
1963 | +++ src/dk/aau/cs/io/LoadedModel.java 2020-08-10 09:00:56 +0000 |
1964 | @@ -8,9 +8,9 @@ |
1965 | import pipe.dataLayer.Template; |
1966 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
1967 | |
1968 | - |
1969 | public class LoadedModel implements LoadedBatchProcessingModel { |
1970 | - private final Collection<Template> templates; |
1971 | + |
1972 | + private final Collection<Template> templates; |
1973 | private final Collection<TAPNQuery> queries; |
1974 | private final TimedArcPetriNetNetwork network; |
1975 | private final boolean isTimed; |
1976 | @@ -20,9 +20,9 @@ |
1977 | public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages){ |
1978 | this(network, templates, queries, messages, true, false); |
1979 | } |
1980 | - public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries) { |
1981 | - this(network, templates, queries, List.of()); |
1982 | - } |
1983 | + public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries){ |
1984 | + this(network, templates, queries, List.of(), true, false); |
1985 | + } |
1986 | |
1987 | public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, boolean isTimed, boolean isGame){ |
1988 | this.templates = templates; |
1989 | @@ -36,9 +36,9 @@ |
1990 | public Collection<Template> templates(){ return templates; } |
1991 | public Collection<TAPNQuery> queries(){ return queries; } |
1992 | public TimedArcPetriNetNetwork network(){ return network; } |
1993 | - |
1994 | public Collection<String> getMessages() { return messages; } |
1995 | |
1996 | + |
1997 | public boolean isTimed() { |
1998 | return isTimed; |
1999 | } |
2000 | |
2001 | === modified file 'src/dk/aau/cs/io/PNMLoader.java' |
2002 | --- src/dk/aau/cs/io/PNMLoader.java 2020-07-13 14:30:00 +0000 |
2003 | +++ src/dk/aau/cs/io/PNMLoader.java 2020-08-10 09:00:56 +0000 |
2004 | @@ -275,10 +275,9 @@ |
2005 | Node text = getFirstDirectChild(inscription, "text"); |
2006 | if(text != null){ |
2007 | String weightString = text.getTextContent().trim(); |
2008 | - try{ |
2009 | - if(weightString != null) |
2010 | - weight = Integer.parseInt(weightString); |
2011 | - } catch(NumberFormatException e) {} |
2012 | + try { |
2013 | + weight = Integer.parseInt(weightString); |
2014 | + } catch (NumberFormatException ignored) {} //Default values is 1 |
2015 | } |
2016 | } |
2017 | |
2018 | |
2019 | === modified file 'src/dk/aau/cs/io/TapnLegacyXmlLoader.java' |
2020 | --- src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-07-14 10:37:29 +0000 |
2021 | +++ src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-08-10 09:00:56 +0000 |
2022 | @@ -81,8 +81,10 @@ |
2023 | private boolean firstInhibitorIntervalWarning = true; |
2024 | private boolean firstPlaceRenameWarning = true; |
2025 | private final IdResolver idResolver = new IdResolver(); |
2026 | + |
2027 | private final Collection<String> messages = new ArrayList<>(10); |
2028 | |
2029 | + |
2030 | public TapnLegacyXmlLoader() {} |
2031 | |
2032 | public LoadedModel load(InputStream file) throws FormatException { |
2033 | @@ -204,9 +206,8 @@ |
2034 | String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
2035 | PlaceTransitionObject targetIn, |
2036 | int _endx, int _endy) { |
2037 | - |
2038 | - Arc tempArc; |
2039 | - String[] inscriptionSplit = {}; |
2040 | + |
2041 | + String[] inscriptionSplit = {}; |
2042 | if (inscriptionTempStorage.contains(":")) { |
2043 | inscriptionSplit = inscriptionTempStorage.split(":"); |
2044 | } |
2045 | @@ -214,7 +215,7 @@ |
2046 | if (sourceIn instanceof Place) { |
2047 | isInPreSet = true; |
2048 | } |
2049 | - tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
2050 | + TimedTransportArcComponent tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
2051 | |
2052 | |
2053 | if (isInPreSet) { |
2054 | @@ -231,7 +232,7 @@ |
2055 | |
2056 | TransportArc transArc = new TransportArc(sourcePlace, trans, destPlace, interval); |
2057 | |
2058 | - ((TimedTransportArcComponent) tempArc).setUnderlyingArc(transArc); |
2059 | + tempArc.setUnderlyingArc(transArc); |
2060 | postsetTransportArc.setUnderlyingArc(transArc); |
2061 | guiModel.addPetriNetObject(tempArc); |
2062 | guiModel.addPetriNetObject(postsetTransportArc); |
2063 | @@ -239,8 +240,8 @@ |
2064 | |
2065 | postsetArcs.remove(targetIn); |
2066 | } else { |
2067 | - presetArcs.put((TimedTransitionComponent) targetIn, (TimedTransportArcComponent) tempArc); |
2068 | - transportArcsTimeIntervals.put((TimedTransportArcComponent) tempArc, TimeInterval.parse(inscriptionSplit[0], constants)); |
2069 | + presetArcs.put((TimedTransitionComponent) targetIn, tempArc); |
2070 | + transportArcsTimeIntervals.put(tempArc, TimeInterval.parse(inscriptionSplit[0], constants)); |
2071 | } |
2072 | } else { |
2073 | if (presetArcs.containsKey(sourceIn)) { |
2074 | @@ -257,7 +258,7 @@ |
2075 | TransportArc transArc = new TransportArc(sourcePlace, trans, |
2076 | destPlace, interval); |
2077 | |
2078 | - ((TimedTransportArcComponent) tempArc).setUnderlyingArc(transArc); |
2079 | + tempArc.setUnderlyingArc(transArc); |
2080 | presetTransportArc.setUnderlyingArc(transArc); |
2081 | guiModel.addPetriNetObject(presetTransportArc); |
2082 | guiModel.addPetriNetObject(tempArc); |
2083 | @@ -266,7 +267,7 @@ |
2084 | presetArcs.remove(sourceIn); |
2085 | transportArcsTimeIntervals.remove(presetTransportArc); |
2086 | } else { |
2087 | - postsetArcs.put((TimedTransitionComponent) sourceIn, (TimedTransportArcComponent) tempArc); |
2088 | + postsetArcs.put((TimedTransitionComponent) sourceIn, tempArc); |
2089 | } |
2090 | } |
2091 | return tempArc; |
2092 | @@ -276,15 +277,15 @@ |
2093 | String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
2094 | PlaceTransitionObject targetIn, |
2095 | int _endx, int _endy) throws FormatException { |
2096 | - Arc tempArc; |
2097 | - tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
2098 | + |
2099 | + TimedInputArcComponent tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
2100 | |
2101 | TimedPlace place = tapn.getPlaceByName(sourceIn.getName()); |
2102 | TimedTransition transition = tapn.getTransitionByName(targetIn.getName()); |
2103 | TimeInterval interval = TimeInterval.parse(inscriptionTempStorage, constants); |
2104 | |
2105 | TimedInputArc inputArc = new TimedInputArc(place, transition, interval); |
2106 | - ((TimedInputArcComponent) tempArc).setUnderlyingArc(inputArc); |
2107 | + tempArc.setUnderlyingArc(inputArc); |
2108 | |
2109 | if(tapn.hasArcFromPlaceToTransition(inputArc.source(), inputArc.destination())) { |
2110 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); |
2111 | @@ -300,12 +301,12 @@ |
2112 | String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
2113 | PlaceTransitionObject targetIn, |
2114 | int _endx, int _endy) { |
2115 | - Arc tempArc; |
2116 | - tempArc = new TimedInhibitorArcComponent( |
2117 | - new TimedInputArcComponent( |
2118 | - new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput) |
2119 | - ), |
2120 | - (inscriptionTempStorage != null ? inscriptionTempStorage : "")); |
2121 | + TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent( |
2122 | + new TimedInputArcComponent( |
2123 | + new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput) |
2124 | + ), |
2125 | + (inscriptionTempStorage != null ? inscriptionTempStorage : "") |
2126 | + ); |
2127 | TimedPlace place = tapn.getPlaceByName(sourceIn.getName()); |
2128 | TimedTransition transition = tapn.getTransitionByName(targetIn.getName()); |
2129 | TimeInterval interval = TimeInterval.parse(inscriptionTempStorage, constants); |
2130 | @@ -317,7 +318,7 @@ |
2131 | |
2132 | TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, interval); |
2133 | |
2134 | - ((TimedInhibitorArcComponent) tempArc).setUnderlyingArc(inhibArc); |
2135 | + tempArc.setUnderlyingArc(inhibArc); |
2136 | guiModel.addPetriNetObject(tempArc); |
2137 | tapn.add(inhibArc); |
2138 | |
2139 | @@ -528,55 +529,45 @@ |
2140 | tapn.add(t); |
2141 | } |
2142 | |
2143 | - private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException { |
2144 | - int positionXInput = (int)getPositionAttribute(element, "x"); |
2145 | - int positionYInput = (int)getPositionAttribute(element, "y"); |
2146 | - String idInput = element.getAttribute("id"); |
2147 | - String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name"); |
2148 | - int nameOffsetXInput = (int)getNameOffsetAttribute(element, "x"); |
2149 | - int nameOffsetYInput = (int)getNameOffsetAttribute(element, "y"); |
2150 | - int initialMarkingInput = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element, "initialMarking"); |
2151 | - String invariant = getChildNodesContentOfValueChildNodeAsString(element, "invariant"); |
2152 | - |
2153 | - if (idInput.length() == 0 && nameInput.length() > 0) { |
2154 | - idInput = nameInput; |
2155 | - } |
2156 | - |
2157 | - if (nameInput.length() == 0 && idInput.length() > 0) { |
2158 | - nameInput = idInput; |
2159 | - } |
2160 | - |
2161 | - if(nameInput.toLowerCase().equals("true") || nameInput.toLowerCase().equals("false")) { |
2162 | - nameInput = "_" + nameInput; |
2163 | - if(firstPlaceRenameWarning) { |
2164 | - messages.add(PLACENAME_ERROR_MESSAGE); |
2165 | - firstPlaceRenameWarning = false; |
2166 | - } |
2167 | - } |
2168 | - idResolver.add(tapn.name(), idInput, nameInput); |
2169 | - |
2170 | - Place place = null; |
2171 | - |
2172 | -// if (invariant == null || invariant.equals("")) { |
2173 | -// place = new Place(positionXInput, positionYInput, idInput, |
2174 | -// nameInput, nameOffsetXInput, nameOffsetYInput, |
2175 | -// initialMarkingInput, markingOffsetXInput, |
2176 | -// markingOffsetYInput, capacityInput); |
2177 | -// |
2178 | -// } else { |
2179 | - place = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput); |
2180 | - |
2181 | - LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants)); |
2182 | - tapn.add(p); |
2183 | - |
2184 | - ((TimedPlaceComponent) place).setUnderlyingPlace(p); |
2185 | - guiModel.addPetriNetObject(place); |
2186 | - |
2187 | - for (int i = 0; i < initialMarkingInput; i++) { |
2188 | - marking.add(new TimedToken(p, new BigDecimal(0.0))); |
2189 | - } |
2190 | - } |
2191 | -// } |
2192 | + private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException { |
2193 | + int positionXInput = (int) getPositionAttribute(element, "x"); |
2194 | + int positionYInput = (int) getPositionAttribute(element, "y"); |
2195 | + String idInput = element.getAttribute("id"); |
2196 | + String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name"); |
2197 | + int nameOffsetXInput = (int) getNameOffsetAttribute(element, "x"); |
2198 | + int nameOffsetYInput = (int) getNameOffsetAttribute(element, "y"); |
2199 | + int initialMarkingInput = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element, "initialMarking"); |
2200 | + String invariant = getChildNodesContentOfValueChildNodeAsString(element, "invariant"); |
2201 | + |
2202 | + if (idInput.length() == 0 && nameInput.length() > 0) { |
2203 | + idInput = nameInput; |
2204 | + } |
2205 | + |
2206 | + if (nameInput.length() == 0 && idInput.length() > 0) { |
2207 | + nameInput = idInput; |
2208 | + } |
2209 | + |
2210 | + if (nameInput.toLowerCase().equals("true") || nameInput.toLowerCase().equals("false")) { |
2211 | + nameInput = "_" + nameInput; |
2212 | + if (firstPlaceRenameWarning) { |
2213 | + messages.add(PLACENAME_ERROR_MESSAGE); |
2214 | + firstPlaceRenameWarning = false; |
2215 | + } |
2216 | + } |
2217 | + idResolver.add(tapn.name(), idInput, nameInput); |
2218 | + |
2219 | + TimedPlaceComponent place = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput); |
2220 | + |
2221 | + LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants)); |
2222 | + tapn.add(p); |
2223 | + |
2224 | + place.setUnderlyingPlace(p); |
2225 | + guiModel.addPetriNetObject(place); |
2226 | + |
2227 | + for (int i = 0; i < initialMarkingInput; i++) { |
2228 | + marking.add(new TimedToken(p, new BigDecimal(0.0))); |
2229 | + } |
2230 | + } |
2231 | |
2232 | private void parseAndAddArcAsOldFormat(Element inputArcElement) throws FormatException { |
2233 | String idInput = inputArcElement.getAttribute("id"); |
2234 | |
2235 | === modified file 'src/dk/aau/cs/io/TapnXmlLoader.java' |
2236 | --- src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-06 07:05:34 +0000 |
2237 | +++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-10 09:00:56 +0000 |
2238 | @@ -136,7 +136,6 @@ |
2239 | parseFeature(doc, network); |
2240 | |
2241 | return new LoadedModel(network, templates, queries,messages, isTimed, isGame); |
2242 | - |
2243 | } |
2244 | |
2245 | private void parseBound(Document doc, TimedArcPetriNetNetwork network){ |
2246 | @@ -647,15 +646,14 @@ |
2247 | String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
2248 | PlaceTransitionObject targetIn, |
2249 | int _endx, int _endy, Template template, ConstantStore constants, Weight weight) throws FormatException { |
2250 | - Arc tempArc; |
2251 | - tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
2252 | + TimedInputArcComponent tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
2253 | |
2254 | TimedPlace place = template.model().getPlaceByName(sourceIn.getName()); |
2255 | TimedTransition transition = template.model().getTransitionByName(targetIn.getName()); |
2256 | TimeInterval interval = TimeInterval.parse(inscriptionTempStorage, constants); |
2257 | |
2258 | TimedInputArc inputArc = new TimedInputArc(place, transition, interval, weight); |
2259 | - ((TimedInputArcComponent) tempArc).setUnderlyingArc(inputArc); |
2260 | + tempArc.setUnderlyingArc(inputArc); |
2261 | |
2262 | if(template.model().hasArcFromPlaceToTransition(inputArc.source(), inputArc.destination())) { |
2263 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); |
2264 | |
2265 | === modified file 'src/dk/aau/cs/io/TraceImportExport.java' |
2266 | --- src/dk/aau/cs/io/TraceImportExport.java 2020-06-17 20:30:35 +0000 |
2267 | +++ src/dk/aau/cs/io/TraceImportExport.java 2020-08-10 09:00:56 +0000 |
2268 | @@ -175,7 +175,6 @@ |
2269 | TimedArcPetriNetTrace traceComposed = traceParser.parseTrace(br); |
2270 | TAPNTraceDecomposer decomposer = new TAPNTraceDecomposer(traceComposed, CreateGui.getCurrentTab().network(), model.value2()); |
2271 | |
2272 | - CreateGui.getApp().setGUIMode(pipe.gui.GuiFrame.GUIMode.animation); |
2273 | CreateGui.getAnimator().setTrace(decomposer.decompose()); |
2274 | |
2275 | } catch (FileNotFoundException e) { |
2276 | |
2277 | === modified file 'src/dk/aau/cs/model/NTA/trace/UppaalTrace.java' |
2278 | --- src/dk/aau/cs/model/NTA/trace/UppaalTrace.java 2020-07-13 13:58:47 +0000 |
2279 | +++ src/dk/aau/cs/model/NTA/trace/UppaalTrace.java 2020-08-10 09:00:56 +0000 |
2280 | @@ -1,5 +1,7 @@ |
2281 | package dk.aau.cs.model.NTA.trace; |
2282 | |
2283 | +import org.jetbrains.annotations.NotNull; |
2284 | + |
2285 | import java.util.ArrayList; |
2286 | import java.util.Iterator; |
2287 | import java.util.List; |
2288 | @@ -21,7 +23,7 @@ |
2289 | firingActions.add(action); |
2290 | } |
2291 | |
2292 | - public Iterator<TAFiringAction> iterator() { |
2293 | + public @NotNull Iterator<TAFiringAction> iterator() { |
2294 | return firingActions.iterator(); |
2295 | } |
2296 | |
2297 | |
2298 | === modified file 'src/dk/aau/cs/model/tapn/ConstantStore.java' |
2299 | --- src/dk/aau/cs/model/tapn/ConstantStore.java 2019-03-22 13:57:03 +0000 |
2300 | +++ src/dk/aau/cs/model/tapn/ConstantStore.java 2020-08-10 09:00:56 +0000 |
2301 | @@ -112,8 +112,8 @@ |
2302 | Bound lower = interval.lowerBound(); |
2303 | Bound upper = interval.upperBound(); |
2304 | |
2305 | - int diff = interval.IsLowerBoundNonStrict() |
2306 | - && interval.IsUpperBoundNonStrict() ? 0 : 1; |
2307 | + int diff = interval.isLowerBoundNonStrict() |
2308 | + && interval.isUpperBoundNonStrict() ? 0 : 1; |
2309 | |
2310 | if (lower instanceof ConstantBound && upper instanceof ConstantBound) { |
2311 | Constant lowerConstant = getConstantByName(((ConstantBound) lower).name()); |
2312 | |
2313 | === modified file 'src/dk/aau/cs/model/tapn/LocalTimedMarking.java' |
2314 | --- src/dk/aau/cs/model/tapn/LocalTimedMarking.java 2020-07-13 13:58:47 +0000 |
2315 | +++ src/dk/aau/cs/model/tapn/LocalTimedMarking.java 2020-08-10 09:00:56 +0000 |
2316 | @@ -7,7 +7,6 @@ |
2317 | import java.util.Map.Entry; |
2318 | |
2319 | import dk.aau.cs.model.NTA.trace.TraceToken; |
2320 | -import dk.aau.cs.model.tapn.TimedPlace.PlaceType; |
2321 | import dk.aau.cs.model.tapn.simulation.FiringMode; |
2322 | import dk.aau.cs.util.Require; |
2323 | import dk.aau.cs.util.Tuple; |
2324 | |
2325 | === modified file 'src/dk/aau/cs/model/tapn/NetworkMarking.java' |
2326 | --- src/dk/aau/cs/model/tapn/NetworkMarking.java 2020-06-21 12:14:21 +0000 |
2327 | +++ src/dk/aau/cs/model/tapn/NetworkMarking.java 2020-08-10 09:00:56 +0000 |
2328 | @@ -8,7 +8,6 @@ |
2329 | |
2330 | import dk.aau.cs.model.NTA.trace.TraceToken; |
2331 | import pipe.gui.CreateGui; |
2332 | -import dk.aau.cs.model.tapn.TimedPlace.PlaceType; |
2333 | import dk.aau.cs.model.tapn.simulation.FiringMode; |
2334 | import dk.aau.cs.util.Require; |
2335 | import dk.aau.cs.util.Tuple; |
2336 | |
2337 | === modified file 'src/dk/aau/cs/model/tapn/TimeInterval.java' |
2338 | --- src/dk/aau/cs/model/tapn/TimeInterval.java 2020-07-13 13:58:47 +0000 |
2339 | +++ src/dk/aau/cs/model/tapn/TimeInterval.java 2020-08-10 09:00:56 +0000 |
2340 | @@ -25,8 +25,7 @@ |
2341 | this.upper = upper; |
2342 | this.isUpperIncluded = isUpperIncluded; |
2343 | |
2344 | - Require.that(isValidInterval(), "The constructed interval " |
2345 | - + toString() + " is empty."); |
2346 | + Require.that(isValidInterval(), "The constructed interval " + toString() + " is empty."); |
2347 | } |
2348 | |
2349 | public TimeInterval(TimeInterval interval) { |
2350 | @@ -101,11 +100,11 @@ |
2351 | this.upper = upper; |
2352 | } |
2353 | |
2354 | - public boolean IsLowerBoundNonStrict() { |
2355 | + public boolean isLowerBoundNonStrict() { |
2356 | return isLowerIncluded; |
2357 | } |
2358 | |
2359 | - public boolean IsUpperBoundNonStrict() { |
2360 | + public boolean isUpperBoundNonStrict() { |
2361 | return isUpperIncluded; |
2362 | } |
2363 | |
2364 | |
2365 | === modified file 'src/dk/aau/cs/model/tapn/TimedArcPetriNet.java' |
2366 | --- src/dk/aau/cs/model/tapn/TimedArcPetriNet.java 2020-08-06 13:08:24 +0000 |
2367 | +++ src/dk/aau/cs/model/tapn/TimedArcPetriNet.java 2020-08-10 09:00:56 +0000 |
2368 | @@ -436,7 +436,7 @@ |
2369 | numberOfOrphanPlaces += t.getOrphanPlaces().size(); |
2370 | //Test if all inputarcs is untimed and get the number of untimed input arcs |
2371 | for(TimedInputArc in : t.inputArcs()){ |
2372 | - if(!(in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){ |
2373 | + if(!(in.interval().lowerBound().value() == 0 && in.interval().isLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){ |
2374 | networkUntimed = false; |
2375 | } else { |
2376 | numberOfUntimedInputArcs++; |
2377 | @@ -447,7 +447,7 @@ |
2378 | } |
2379 | //Test if all tansportarcs is untimed and get the number of untimed transport arcs |
2380 | for(TransportArc in : t.transportArcs()){ |
2381 | - if(!(in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){ |
2382 | + if(!(in.interval().lowerBound().value() == 0 && in.interval().isLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){ |
2383 | networkUntimed = false; |
2384 | } else { |
2385 | numberOfUntimedTransportArcs++; |
2386 | @@ -658,13 +658,13 @@ |
2387 | |
2388 | public boolean isNonStrict(){ |
2389 | for(TimedInputArc t : inputArcs){ |
2390 | - if(!t.interval().IsLowerBoundNonStrict() || (!t.interval().IsUpperBoundNonStrict() && !(t.interval().upperBound() instanceof InfBound))){ |
2391 | + if(!t.interval().isLowerBoundNonStrict() || (!t.interval().isUpperBoundNonStrict() && !(t.interval().upperBound() instanceof InfBound))){ |
2392 | return false; |
2393 | } |
2394 | } |
2395 | |
2396 | for(TransportArc t : transportArcs){ |
2397 | - if(!t.interval().IsLowerBoundNonStrict() || (!t.interval().IsUpperBoundNonStrict() && !(t.interval().upperBound() instanceof InfBound))){ |
2398 | + if(!t.interval().isLowerBoundNonStrict() || (!t.interval().isUpperBoundNonStrict() && !(t.interval().upperBound() instanceof InfBound))){ |
2399 | return false; |
2400 | } |
2401 | } |
2402 | |
2403 | === modified file 'src/dk/aau/cs/model/tapn/TimedInputArc.java' |
2404 | --- src/dk/aau/cs/model/tapn/TimedInputArc.java 2020-07-13 13:58:47 +0000 |
2405 | +++ src/dk/aau/cs/model/tapn/TimedInputArc.java 2020-08-10 09:00:56 +0000 |
2406 | @@ -127,15 +127,15 @@ |
2407 | newUpper = BigDecimal.ZERO; |
2408 | } |
2409 | |
2410 | - if (newUpper.compareTo(newLower) == 0 && (interval.IsLowerBoundNonStrict() || overrideLowerInclusion) && interval.IsUpperBoundNonStrict()){ |
2411 | + if (newUpper.compareTo(newLower) == 0 && (interval.isLowerBoundNonStrict() || overrideLowerInclusion) && interval.isUpperBoundNonStrict()){ |
2412 | temp = new TimeInterval(true, new RatBound(newLower), new RatBound(newUpper), true); |
2413 | } else if (newLower.compareTo(newUpper) < 0){ |
2414 | - temp = new TimeInterval(interval.IsLowerBoundNonStrict() || overrideLowerInclusion, new RatBound(newLower), new RatBound(newUpper), interval.IsUpperBoundNonStrict()); |
2415 | + temp = new TimeInterval(interval.isLowerBoundNonStrict() || overrideLowerInclusion, new RatBound(newLower), new RatBound(newUpper), interval.isUpperBoundNonStrict()); |
2416 | } else { //new bounds are empty |
2417 | temp = null; |
2418 | } |
2419 | } else { //upper bound is inf |
2420 | - temp = new TimeInterval(interval.IsLowerBoundNonStrict(), new RatBound(newLower), interval.upperBound(), false); |
2421 | + temp = new TimeInterval(interval.isLowerBoundNonStrict(), new RatBound(newLower), interval.upperBound(), false); |
2422 | } |
2423 | } |
2424 | |
2425 | |
2426 | === modified file 'src/dk/aau/cs/model/tapn/TransportArc.java' |
2427 | --- src/dk/aau/cs/model/tapn/TransportArc.java 2020-07-13 13:58:47 +0000 |
2428 | +++ src/dk/aau/cs/model/tapn/TransportArc.java 2020-08-10 09:00:56 +0000 |
2429 | @@ -153,15 +153,15 @@ |
2430 | newUpper = BigDecimal.ZERO; |
2431 | } |
2432 | |
2433 | - if (newUpper.compareTo(newLower) == 0 && interval.IsLowerBoundNonStrict() && interval.IsUpperBoundNonStrict()){ |
2434 | + if (newUpper.compareTo(newLower) == 0 && interval.isLowerBoundNonStrict() && interval.isUpperBoundNonStrict()){ |
2435 | temp = new TimeInterval(true, new RatBound(newLower), new RatBound(newUpper), true); |
2436 | } else if (newLower.compareTo(newUpper) < 0){ |
2437 | - temp = new TimeInterval(interval.IsLowerBoundNonStrict() || overrideLowerInclusion, new RatBound(newLower), new RatBound(newUpper), interval.IsUpperBoundNonStrict()); |
2438 | + temp = new TimeInterval(interval.isLowerBoundNonStrict() || overrideLowerInclusion, new RatBound(newLower), new RatBound(newUpper), interval.isUpperBoundNonStrict()); |
2439 | } else { //new bounds are empty |
2440 | temp = null; |
2441 | } |
2442 | } else { //upper bound is inf |
2443 | - temp = new TimeInterval(interval.IsLowerBoundNonStrict(), new RatBound(newLower), interval.upperBound(), false); |
2444 | + temp = new TimeInterval(interval.isLowerBoundNonStrict(), new RatBound(newLower), interval.upperBound(), false); |
2445 | } |
2446 | } |
2447 | |
2448 | |
2449 | === modified file 'src/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java' |
2450 | --- src/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java 2020-04-18 12:27:02 +0000 |
2451 | +++ src/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java 2020-08-10 09:00:56 +0000 |
2452 | @@ -88,7 +88,7 @@ |
2453 | JPanel buttonPanel = createButtonPanel(); |
2454 | BigDecimal value = IntervalOperations.getRatBound(dInterval.lowerBound()).getBound(); |
2455 | |
2456 | - if(!dInterval.IsLowerBoundNonStrict()){ |
2457 | + if(!dInterval.isLowerBoundNonStrict()){ |
2458 | value = value.add(delayGranularity); |
2459 | value = value.stripTrailingZeros(); |
2460 | } |
2461 | |
2462 | === modified file 'src/dk/aau/cs/model/tapn/simulation/RandomDelayMode.java' |
2463 | --- src/dk/aau/cs/model/tapn/simulation/RandomDelayMode.java 2019-03-22 11:36:50 +0000 |
2464 | +++ src/dk/aau/cs/model/tapn/simulation/RandomDelayMode.java 2020-08-10 09:00:56 +0000 |
2465 | @@ -39,11 +39,11 @@ |
2466 | BigDecimal result; |
2467 | |
2468 | if(dInterval.upperBound() instanceof Bound.InfBound){ |
2469 | - TimeInterval range = new TimeInterval(dInterval.IsLowerBoundNonStrict(), new IntBound(0), Bound.Infinity, dInterval.IsUpperBoundNonStrict()); |
2470 | + TimeInterval range = new TimeInterval(dInterval.isLowerBoundNonStrict(), new IntBound(0), Bound.Infinity, dInterval.isUpperBoundNonStrict()); |
2471 | result = exponentialDistribution(range, transition); |
2472 | } else { |
2473 | //This is safe as the difference between the bounds is always ints - and constants in the model is ints as well |
2474 | - TimeInterval range = new TimeInterval(dInterval.IsLowerBoundNonStrict(), new IntBound(0), new RatBound(upper.subtract(lower)), dInterval.IsUpperBoundNonStrict()); |
2475 | + TimeInterval range = new TimeInterval(dInterval.isLowerBoundNonStrict(), new IntBound(0), new RatBound(upper.subtract(lower)), dInterval.isUpperBoundNonStrict()); |
2476 | result = randomBigDecimal(range); |
2477 | } |
2478 | |
2479 | |
2480 | === modified file 'src/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java' |
2481 | --- src/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java 2019-03-22 10:13:18 +0000 |
2482 | +++ src/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java 2020-08-10 09:00:56 +0000 |
2483 | @@ -26,7 +26,7 @@ |
2484 | public BigDecimal GetDelay(TimedTransition transition, |
2485 | TimeInterval dInterval, BigDecimal delayGranularity) { |
2486 | |
2487 | - if(dInterval.IsLowerBoundNonStrict()){ |
2488 | + if(dInterval.isLowerBoundNonStrict()){ |
2489 | return IntervalOperations.getRatBound(dInterval.lowerBound()).getBound(); |
2490 | } else { |
2491 | return IntervalOperations.getRatBound(dInterval.lowerBound()).getBound().add(delayGranularity, new MathContext(Pipe.AGE_PRECISION)); |
2492 | |
2493 | === modified file 'src/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java' |
2494 | --- src/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java 2020-07-13 13:58:47 +0000 |
2495 | +++ src/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java 2020-08-10 09:00:56 +0000 |
2496 | @@ -7,6 +7,7 @@ |
2497 | import dk.aau.cs.model.tapn.TimedToken; |
2498 | import dk.aau.cs.util.Require; |
2499 | import dk.aau.cs.verification.VerifyTAPN.TraceType; |
2500 | +import org.jetbrains.annotations.NotNull; |
2501 | |
2502 | public class TimedArcPetriNetTrace implements Iterable<TimedArcPetriNetStep> { |
2503 | private boolean nextIsLoop; |
2504 | @@ -31,7 +32,7 @@ |
2505 | steps.add(step); |
2506 | } |
2507 | |
2508 | - public Iterator<TimedArcPetriNetStep> iterator() { |
2509 | + public @NotNull Iterator<TimedArcPetriNetStep> iterator() { |
2510 | return steps.iterator(); |
2511 | } |
2512 | |
2513 | |
2514 | === modified file 'src/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java' |
2515 | --- src/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java 2020-07-13 13:58:47 +0000 |
2516 | +++ src/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java 2020-08-10 09:00:56 +0000 |
2517 | @@ -5,6 +5,7 @@ |
2518 | import java.util.List; |
2519 | |
2520 | import dk.aau.cs.verification.VerifyTAPN.TraceType; |
2521 | +import org.jetbrains.annotations.NotNull; |
2522 | |
2523 | public class TimedTAPNNetworkTrace implements TAPNNetworkTrace { |
2524 | private final List<TAPNNetworkTraceStep> steps = new ArrayList<TAPNNetworkTraceStep>(); |
2525 | @@ -22,7 +23,7 @@ |
2526 | steps.add(step); |
2527 | } |
2528 | |
2529 | - public Iterator<TAPNNetworkTraceStep> iterator() { |
2530 | + public @NotNull Iterator<TAPNNetworkTraceStep> iterator() { |
2531 | return steps.iterator(); |
2532 | } |
2533 | |
2534 | |
2535 | === modified file 'src/dk/aau/cs/model/tapn/simulation/UntimedTAPNNetworkTrace.java' |
2536 | --- src/dk/aau/cs/model/tapn/simulation/UntimedTAPNNetworkTrace.java 2020-07-13 13:58:47 +0000 |
2537 | +++ src/dk/aau/cs/model/tapn/simulation/UntimedTAPNNetworkTrace.java 2020-08-10 09:00:56 +0000 |
2538 | @@ -1,5 +1,7 @@ |
2539 | package dk.aau.cs.model.tapn.simulation; |
2540 | |
2541 | +import org.jetbrains.annotations.NotNull; |
2542 | + |
2543 | import java.util.ArrayList; |
2544 | import java.util.Iterator; |
2545 | import java.util.List; |
2546 | @@ -11,7 +13,7 @@ |
2547 | steps.add(step); |
2548 | } |
2549 | |
2550 | - public Iterator<TAPNNetworkTraceStep> iterator() { |
2551 | + public @NotNull Iterator<TAPNNetworkTraceStep> iterator() { |
2552 | return steps.iterator(); |
2553 | } |
2554 | |
2555 | |
2556 | === modified file 'src/dk/aau/cs/translations/tapn/BroadcastTranslation.java' |
2557 | --- src/dk/aau/cs/translations/tapn/BroadcastTranslation.java 2020-08-04 08:07:21 +0000 |
2558 | +++ src/dk/aau/cs/translations/tapn/BroadcastTranslation.java 2020-08-10 09:00:56 +0000 |
2559 | @@ -644,9 +644,9 @@ |
2560 | |
2561 | StringBuilder builder = new StringBuilder(); |
2562 | boolean lowerBoundAdded = false; |
2563 | - if(!(interval.lowerBound().value() == 0 && interval.IsLowerBoundNonStrict())) { |
2564 | + if(!(interval.lowerBound().value() == 0 && interval.isLowerBoundNonStrict())) { |
2565 | builder.append(TOKEN_CLOCK_NAME); |
2566 | - if(interval.IsLowerBoundNonStrict()) |
2567 | + if(interval.isLowerBoundNonStrict()) |
2568 | builder.append(" >= "); |
2569 | else |
2570 | builder.append(" > "); |
2571 | @@ -659,7 +659,7 @@ |
2572 | if(lowerBoundAdded) builder.append(" && "); |
2573 | builder.append(TOKEN_CLOCK_NAME); |
2574 | |
2575 | - if(interval.IsUpperBoundNonStrict()) |
2576 | + if(interval.isUpperBoundNonStrict()) |
2577 | builder.append(" <= "); |
2578 | else |
2579 | builder.append(" < "); |
2580 | |
2581 | === modified file 'src/dk/aau/cs/translations/tapn/CombiTranslation.java' |
2582 | --- src/dk/aau/cs/translations/tapn/CombiTranslation.java 2020-07-13 13:58:47 +0000 |
2583 | +++ src/dk/aau/cs/translations/tapn/CombiTranslation.java 2020-08-10 09:00:56 +0000 |
2584 | @@ -1158,9 +1158,9 @@ |
2585 | |
2586 | StringBuilder builder = new StringBuilder(); |
2587 | boolean lowerBoundAdded = false; |
2588 | - if(!(interval.lowerBound().value() == 0 && interval.IsLowerBoundNonStrict())) { |
2589 | + if(!(interval.lowerBound().value() == 0 && interval.isLowerBoundNonStrict())) { |
2590 | builder.append(TOKEN_CLOCK_NAME); |
2591 | - if(interval.IsLowerBoundNonStrict()) |
2592 | + if(interval.isLowerBoundNonStrict()) |
2593 | builder.append(" >= "); |
2594 | else |
2595 | builder.append(" > "); |
2596 | @@ -1173,7 +1173,7 @@ |
2597 | if(lowerBoundAdded) builder.append(" && "); |
2598 | builder.append(TOKEN_CLOCK_NAME); |
2599 | |
2600 | - if(interval.IsUpperBoundNonStrict()) |
2601 | + if(interval.isUpperBoundNonStrict()) |
2602 | builder.append(" <= "); |
2603 | else |
2604 | builder.append(" < "); |
2605 | |
2606 | === modified file 'src/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java' |
2607 | --- src/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java 2020-08-04 08:07:21 +0000 |
2608 | +++ src/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java 2020-08-10 09:00:56 +0000 |
2609 | @@ -674,9 +674,9 @@ |
2610 | StringBuilder builder = new StringBuilder(); |
2611 | |
2612 | boolean lowerBoundAdded = false; |
2613 | - if(!(interval.lowerBound().value() == 0 && interval.IsLowerBoundNonStrict())) { |
2614 | + if(!(interval.lowerBound().value() == 0 && interval.isLowerBoundNonStrict())) { |
2615 | builder.append(CLOCK_NAME); |
2616 | - if(interval.IsLowerBoundNonStrict()) |
2617 | + if(interval.isLowerBoundNonStrict()) |
2618 | builder.append(" >= "); |
2619 | else |
2620 | builder.append(" > "); |
2621 | @@ -689,7 +689,7 @@ |
2622 | if(lowerBoundAdded) builder.append(" && "); |
2623 | builder.append(CLOCK_NAME); |
2624 | |
2625 | - if(interval.IsUpperBoundNonStrict()) |
2626 | + if(interval.isUpperBoundNonStrict()) |
2627 | builder.append(" <= "); |
2628 | else |
2629 | builder.append(" < "); |
2630 | |
2631 | === modified file 'src/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java' |
2632 | --- src/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java 2020-08-04 08:07:21 +0000 |
2633 | +++ src/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java 2020-08-10 09:00:56 +0000 |
2634 | @@ -372,9 +372,9 @@ |
2635 | |
2636 | StringBuilder builder = new StringBuilder(); |
2637 | boolean lowerBoundAdded = false; |
2638 | - if(!(interval.lowerBound().value() == 0 && interval.IsLowerBoundNonStrict())) { |
2639 | + if(!(interval.lowerBound().value() == 0 && interval.isLowerBoundNonStrict())) { |
2640 | builder.append(TOKEN_CLOCK_NAME); |
2641 | - if(interval.IsLowerBoundNonStrict()) |
2642 | + if(interval.isLowerBoundNonStrict()) |
2643 | builder.append(" >= "); |
2644 | else |
2645 | builder.append(" > "); |
2646 | @@ -387,7 +387,7 @@ |
2647 | if(lowerBoundAdded) builder.append(" && "); |
2648 | builder.append(TOKEN_CLOCK_NAME); |
2649 | |
2650 | - if(interval.IsUpperBoundNonStrict()) |
2651 | + if(interval.isUpperBoundNonStrict()) |
2652 | builder.append(" <= "); |
2653 | else |
2654 | builder.append(" < "); |
2655 | |
2656 | === modified file 'src/dk/aau/cs/translations/tapn/StandardTranslation.java' |
2657 | --- src/dk/aau/cs/translations/tapn/StandardTranslation.java 2020-08-04 08:07:21 +0000 |
2658 | +++ src/dk/aau/cs/translations/tapn/StandardTranslation.java 2020-08-10 09:00:56 +0000 |
2659 | @@ -311,9 +311,9 @@ |
2660 | StringBuilder builder = new StringBuilder(); |
2661 | |
2662 | boolean lowerBoundAdded = false; |
2663 | - if(!(interval.lowerBound().value() == 0 && interval.IsLowerBoundNonStrict())) { |
2664 | + if(!(interval.lowerBound().value() == 0 && interval.isLowerBoundNonStrict())) { |
2665 | builder.append(TOKEN_CLOCK_NAME); |
2666 | - if(interval.IsLowerBoundNonStrict()) |
2667 | + if(interval.isLowerBoundNonStrict()) |
2668 | builder.append(" >= "); |
2669 | else |
2670 | builder.append(" > "); |
2671 | @@ -326,7 +326,7 @@ |
2672 | if(lowerBoundAdded) builder.append(" && "); |
2673 | builder.append(TOKEN_CLOCK_NAME); |
2674 | |
2675 | - if(interval.IsUpperBoundNonStrict()) |
2676 | + if(interval.isUpperBoundNonStrict()) |
2677 | builder.append(" <= "); |
2678 | else |
2679 | builder.append(" < "); |
2680 | |
2681 | === modified file 'src/dk/aau/cs/util/IntervalOperations.java' |
2682 | --- src/dk/aau/cs/util/IntervalOperations.java 2012-09-19 18:15:59 +0000 |
2683 | +++ src/dk/aau/cs/util/IntervalOperations.java 2020-08-10 09:00:56 +0000 |
2684 | @@ -40,7 +40,7 @@ |
2685 | TimeInterval lower = min(i1, i2, BoundToCheck.lower); |
2686 | TimeInterval upper = max(i1, i2, BoundToCheck.upper); |
2687 | |
2688 | - return new TimeInterval(lower.IsLowerBoundNonStrict(), lower.lowerBound(), upper.upperBound(), upper.IsUpperBoundNonStrict()); |
2689 | + return new TimeInterval(lower.isLowerBoundNonStrict(), lower.lowerBound(), upper.upperBound(), upper.isUpperBoundNonStrict()); |
2690 | } |
2691 | |
2692 | |
2693 | @@ -56,8 +56,8 @@ |
2694 | BigDecimal iUp = getRatBound(upper.upperBound()).getBound(); |
2695 | BigDecimal iLow = getRatBound(lower.lowerBound()).getBound(); |
2696 | |
2697 | - if(iUp.compareTo(iLow) > 0 || iUp.compareTo(iLow) == 0 && lower.IsLowerBoundNonStrict() && upper.IsUpperBoundNonStrict() || (upper.upperBound().value() < 0)){ |
2698 | - return new TimeInterval(lower.IsLowerBoundNonStrict(), lower.lowerBound(), upper.upperBound(), upper.IsUpperBoundNonStrict()); |
2699 | + if(iUp.compareTo(iLow) > 0 || iUp.compareTo(iLow) == 0 && lower.isLowerBoundNonStrict() && upper.isUpperBoundNonStrict() || (upper.upperBound().value() < 0)){ |
2700 | + return new TimeInterval(lower.isLowerBoundNonStrict(), lower.lowerBound(), upper.upperBound(), upper.isUpperBoundNonStrict()); |
2701 | } else { |
2702 | return null; |
2703 | } |
2704 | @@ -75,7 +75,7 @@ |
2705 | BigDecimal b1 = getRatBound(i1.lowerBound()).getBound(); |
2706 | BigDecimal b2 = getRatBound(i2.lowerBound()).getBound(); |
2707 | |
2708 | - if(b1.compareTo(b2) < 0 || b1.compareTo(b2) == 0 && i1.IsLowerBoundNonStrict() && !i2.IsLowerBoundNonStrict()){ |
2709 | + if(b1.compareTo(b2) < 0 || b1.compareTo(b2) == 0 && i1.isLowerBoundNonStrict() && !i2.isLowerBoundNonStrict()){ |
2710 | return i1; |
2711 | } else { |
2712 | return i2; |
2713 | @@ -84,7 +84,7 @@ |
2714 | b1 = getRatBound(i1.upperBound()).getBound(); |
2715 | b2 = getRatBound(i2.upperBound()).getBound(); |
2716 | if(b1.compareTo(BigDecimal.ZERO) >= 0 && b2.compareTo(BigDecimal.ZERO) >= 0){ |
2717 | - if(b1.compareTo(b2) < 0 || b1.compareTo(b2) == 0 && !i1.IsUpperBoundNonStrict() && i2.IsUpperBoundNonStrict()){ |
2718 | + if(b1.compareTo(b2) < 0 || b1.compareTo(b2) == 0 && !i1.isUpperBoundNonStrict() && i2.isUpperBoundNonStrict()){ |
2719 | return i1; |
2720 | } else { |
2721 | return i2; |
2722 | @@ -146,10 +146,10 @@ |
2723 | output.add(intersection(IS1.get(i), IS2.get(j))); |
2724 | } |
2725 | |
2726 | - if(i1up.compareTo(i2up) == -1 || (i2up.compareTo(i1up) == 0 && (IS2.get(j).IsUpperBoundNonStrict() == IS1.get(i).IsUpperBoundNonStrict() || !IS1.get(i).IsUpperBoundNonStrict()))){ |
2727 | + if(i1up.compareTo(i2up) == -1 || (i2up.compareTo(i1up) == 0 && (IS2.get(j).isUpperBoundNonStrict() == IS1.get(i).isUpperBoundNonStrict() || !IS1.get(i).isUpperBoundNonStrict()))){ |
2728 | incrementI = true; |
2729 | } |
2730 | - if(i2up.compareTo(i1up) == -1 || (i2up.compareTo(i1up) == 0 && (IS2.get(j).IsUpperBoundNonStrict() == IS1.get(i).IsUpperBoundNonStrict() || !IS2.get(j).IsUpperBoundNonStrict()))){ |
2731 | + if(i2up.compareTo(i1up) == -1 || (i2up.compareTo(i1up) == 0 && (IS2.get(j).isUpperBoundNonStrict() == IS1.get(i).isUpperBoundNonStrict() || !IS2.get(j).isUpperBoundNonStrict()))){ |
2732 | j++; |
2733 | } |
2734 | |
2735 | @@ -196,14 +196,14 @@ |
2736 | if(IS2.get(j).lowerBound() instanceof RatBound){ i2lo = ((RatBound)IS2.get(j).lowerBound());} |
2737 | else{i2lo = new RatBound(new BigDecimal(IS2.get(j).lowerBound().value(), new MathContext(Pipe.AGE_PRECISION)));} |
2738 | |
2739 | - if(intersection(IS1.get(i), IS2.get(j)) != null || (i1lo.compareTo(i2up)==0 && (IS1.get(i).IsLowerBoundNonStrict()||IS2.get(j).IsUpperBoundNonStrict())) |
2740 | - || (i2lo.compareTo(i1up)==0 && (IS2.get(j).IsLowerBoundNonStrict()||IS1.get(i).IsUpperBoundNonStrict()))){ |
2741 | + if(intersection(IS1.get(i), IS2.get(j)) != null || (i1lo.compareTo(i2up)==0 && (IS1.get(i).isLowerBoundNonStrict()||IS2.get(j).isUpperBoundNonStrict())) |
2742 | + || (i2lo.compareTo(i1up)==0 && (IS2.get(j).isLowerBoundNonStrict()||IS1.get(i).isUpperBoundNonStrict()))){ |
2743 | |
2744 | temp = union(temp, union(IS1.get(i), IS2.get(j))); |
2745 | |
2746 | - if(i1up.compareTo(i2up) == 1 || (i1up.compareTo(i2up) == 0 && !IS2.get(j).IsUpperBoundNonStrict() && IS1.get(i).IsUpperBoundNonStrict())){ |
2747 | + if(i1up.compareTo(i2up) == 1 || (i1up.compareTo(i2up) == 0 && !IS2.get(j).isUpperBoundNonStrict() && IS1.get(i).isUpperBoundNonStrict())){ |
2748 | j++; |
2749 | - } else if(i2up.compareTo(i1up) == 1 || (i2up.compareTo(i1up) == 0 && !IS1.get(i).IsUpperBoundNonStrict() && IS2.get(j).IsUpperBoundNonStrict())){ |
2750 | + } else if(i2up.compareTo(i1up) == 1 || (i2up.compareTo(i1up) == 0 && !IS1.get(i).isUpperBoundNonStrict() && IS2.get(j).isUpperBoundNonStrict())){ |
2751 | i++; |
2752 | } else { |
2753 | break; |
2754 | |
2755 | === modified file 'src/dk/aau/cs/util/MemoryMonitor.java' |
2756 | --- src/dk/aau/cs/util/MemoryMonitor.java 2020-04-18 15:39:19 +0000 |
2757 | +++ src/dk/aau/cs/util/MemoryMonitor.java 2020-08-10 09:00:56 +0000 |
2758 | @@ -1,8 +1,10 @@ |
2759 | package dk.aau.cs.util; |
2760 | |
2761 | import com.sun.jna.*; |
2762 | +import dk.aau.cs.debug.Logger; |
2763 | |
2764 | import java.io.BufferedReader; |
2765 | +import java.io.IOException; |
2766 | import java.io.InputStreamReader; |
2767 | import java.lang.reflect.Field; |
2768 | import java.text.DecimalFormat; |
2769 | @@ -14,14 +16,7 @@ |
2770 | |
2771 | public class MemoryMonitor { |
2772 | |
2773 | - interface Kernel32 extends Library { |
2774 | - |
2775 | - static Kernel32 INSTANCE = Native.loadLibrary("kernel32", Kernel32.class); |
2776 | - |
2777 | - int GetProcessId(Long hProcess); |
2778 | - } |
2779 | - |
2780 | - private static int PID = -1; |
2781 | + private static long PID = -1; |
2782 | private static Semaphore busy = new Semaphore(1); |
2783 | private static double peakMemory = -1; |
2784 | private static Boolean cumulativePeakMemory = false; |
2785 | @@ -37,7 +32,7 @@ |
2786 | } |
2787 | |
2788 | public static void attach(Process p){ |
2789 | - PID = getPid(p); |
2790 | + PID = p.pid(); |
2791 | |
2792 | if( ! cumulativePeakMemory) { |
2793 | peakMemory = -1; |
2794 | @@ -79,17 +74,19 @@ |
2795 | if(m.matches()){ |
2796 | memory = Double.parseDouble(m.group(1).replace(".", "").replace(",", ""))/1024; |
2797 | } |
2798 | - } catch (Exception e) { |
2799 | + } catch (IOException e) { |
2800 | + Logger.log(e); |
2801 | } |
2802 | }else{ |
2803 | - try { |
2804 | + try { |
2805 | Process p = Runtime.getRuntime().exec("ps -p "+PID+" -o rss"); |
2806 | BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); |
2807 | - |
2808 | - String s = input.readLine(); |
2809 | - s = input.readLine(); //Actual memory usage is second line output |
2810 | + |
2811 | + input.readLine(); //Actual memory usage is second line output |
2812 | + String s = input.readLine(); |
2813 | memory = Double.parseDouble(s.replace(" ", ""))/1024; |
2814 | - } catch (Exception e) { |
2815 | + } catch (IOException e) { |
2816 | + Logger.log(e); |
2817 | } |
2818 | } |
2819 | |
2820 | @@ -105,24 +102,6 @@ |
2821 | } |
2822 | } |
2823 | |
2824 | - private static int getPid(Process p) { |
2825 | - Field f; |
2826 | - |
2827 | - try{ |
2828 | - if (Platform.isWindows()) { |
2829 | - f = p.getClass().getDeclaredField("handle"); |
2830 | - f.setAccessible(true); |
2831 | - return Kernel32.INSTANCE.GetProcessId((Long) f.get(p)); |
2832 | - } else { |
2833 | - f = p.getClass().getDeclaredField("pid"); |
2834 | - f.setAccessible(true); |
2835 | - return (int) (Integer) f.get(p); |
2836 | - } |
2837 | - }catch(Exception e){ |
2838 | - return -1; |
2839 | - } |
2840 | - } |
2841 | - |
2842 | public static String getPeakMemory(){ |
2843 | return peakMemory == -1? "N/A":getFormatter().format(Math.ceil(peakMemory)) + " MB"; |
2844 | } |
2845 | |
2846 | === modified file 'src/dk/aau/cs/verification/TAPNComposer.java' |
2847 | --- src/dk/aau/cs/verification/TAPNComposer.java 2020-08-04 08:19:44 +0000 |
2848 | +++ src/dk/aau/cs/verification/TAPNComposer.java 2020-08-10 09:00:56 +0000 |
2849 | @@ -380,7 +380,7 @@ |
2850 | Place guiSource = guiModel.getPlaceByName(mapping.map(sourceTemplate, arc.source().name())); |
2851 | Transition guiTarget = guiModel.getTransitionByName(mapping.map(targetTemplate, arc.destination().name())); |
2852 | |
2853 | - Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
2854 | + TimedInputArcComponent newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
2855 | guiSource, |
2856 | guiTarget, |
2857 | arc.getWeight().value(), |
2858 | @@ -394,7 +394,7 @@ |
2859 | ArcPath newArcPath = createArcPath(currentGuiModel, oldGuiSource, oldGuiTarget, newArc, offset.value1() * greatestWidth, offset.value2() * greatestHeight); |
2860 | |
2861 | // Set arcPath, guiModel and connectors |
2862 | - ((TimedInputArcComponent) newArc).setUnderlyingArc(addedArc); |
2863 | + newArc.setUnderlyingArc(addedArc); |
2864 | newArc.setArcPath(newArcPath); |
2865 | newArc.updateArcPosition(); |
2866 | guiModel.addPetriNetObject(newArc); |
2867 | @@ -600,7 +600,7 @@ |
2868 | if (this.guiModels != null) { |
2869 | Place guiSource = guiModel.getPlaceByName(mapping.map(sourceTemplate, arc.source().name())); |
2870 | Transition guiTarget = guiModel.getTransitionByName(mapping.map(destinationTemplate, arc.destination().name())); |
2871 | - Arc newArc = new TimedInhibitorArcComponent(new TimedOutputArcComponent( |
2872 | + TimedInhibitorArcComponent newArc = new TimedInhibitorArcComponent(new TimedOutputArcComponent( |
2873 | guiSource, |
2874 | guiTarget, |
2875 | arc.getWeight().value(), |
2876 | @@ -612,7 +612,7 @@ |
2877 | Transition oldGuiTarget = currentGuiModel.getTransitionByName(arc.destination().name()); |
2878 | ArcPath newArcPath = createArcPath(currentGuiModel, oldGuiSource, oldGuiTarget, newArc, offset.value1() * greatestWidth, offset.value2() * greatestHeight); |
2879 | |
2880 | - ((TimedInhibitorArcComponent) newArc).setUnderlyingArc(addedArc); |
2881 | + newArc.setUnderlyingArc(addedArc); |
2882 | newArc.setArcPath(newArcPath); |
2883 | newArc.updateArcPosition(); |
2884 | guiModel.addPetriNetObject(newArc); |
2885 | |
2886 | === modified file 'src/dk/aau/cs/verification/VerificationResult.java' |
2887 | --- src/dk/aau/cs/verification/VerificationResult.java 2020-04-18 16:08:44 +0000 |
2888 | +++ src/dk/aau/cs/verification/VerificationResult.java 2020-08-10 09:00:56 +0000 |
2889 | @@ -96,7 +96,7 @@ |
2890 | public static class transitionTupleComparator implements Comparator<Tuple<String,Integer>> { |
2891 | |
2892 | public int compare(Tuple<String,Integer> tuple1,Tuple<String,Integer> tuple2) { |
2893 | - return (tuple1.value2() > tuple2.value2() ? -1 : (tuple1.value2() == tuple2.value2() ? 0 : 1)); |
2894 | + return tuple2.value2() - tuple1.value2(); |
2895 | } |
2896 | } |
2897 | |
2898 | |
2899 | === modified file 'src/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java' |
2900 | --- src/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java 2020-06-29 10:58:39 +0000 |
2901 | +++ src/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java 2020-08-10 09:00:56 +0000 |
2902 | @@ -2,7 +2,6 @@ |
2903 | |
2904 | import pipe.gui.canvas.DrawingSurfaceImpl; |
2905 | import pipe.gui.graphicElements.GraphicalElement; |
2906 | -import pipe.gui.graphicElements.PetriNetObject; |
2907 | |
2908 | import java.awt.event.MouseEvent; |
2909 | import java.awt.event.MouseWheelEvent; |
2910 | @@ -53,13 +52,19 @@ |
2911 | private final Map<Predicate<DrawingSurfaceEvent>, Consumer<DrawingSurfaceEvent>> filter = new LinkedHashMap<>(); |
2912 | private final AbstractDrawingSurfaceManager next = null; |
2913 | |
2914 | - public void registerManager(DrawingSurfaceImpl canvas){ |
2915 | + public final void registerManager(DrawingSurfaceImpl canvas){ |
2916 | this.canvas = canvas; |
2917 | + setupManager(); |
2918 | } |
2919 | - public void deregisterManager(){ |
2920 | + |
2921 | + public final void deregisterManager(){ |
2922 | this.canvas = null; |
2923 | + teardownManager(); |
2924 | } |
2925 | |
2926 | + public void setupManager(){} |
2927 | + public void teardownManager(){} |
2928 | + |
2929 | public AbstractDrawingSurfaceManager() { |
2930 | registerEvents(); |
2931 | } |
2932 | |
2933 | === modified file 'src/net/tapaal/resourcemanager/ResourceManager.java' |
2934 | --- src/net/tapaal/resourcemanager/ResourceManager.java 2020-07-13 13:58:47 +0000 |
2935 | +++ src/net/tapaal/resourcemanager/ResourceManager.java 2020-08-10 09:00:56 +0000 |
2936 | @@ -8,8 +8,6 @@ |
2937 | import javax.imageio.ImageIO; |
2938 | import javax.swing.ImageIcon; |
2939 | |
2940 | -import pipe.gui.CreateGui; |
2941 | - |
2942 | public class ResourceManager { |
2943 | public static final String imgPath = "resources/Images/"; |
2944 | |
2945 | |
2946 | === modified file 'src/net/tapaal/swinghelpers/ExtendedJTabbedPane.java' |
2947 | --- src/net/tapaal/swinghelpers/ExtendedJTabbedPane.java 2020-04-18 13:49:06 +0000 |
2948 | +++ src/net/tapaal/swinghelpers/ExtendedJTabbedPane.java 2020-08-10 09:00:56 +0000 |
2949 | @@ -1,5 +1,7 @@ |
2950 | package net.tapaal.swinghelpers; |
2951 | |
2952 | +import org.jetbrains.annotations.NotNull; |
2953 | + |
2954 | import javax.swing.*; |
2955 | import java.awt.*; |
2956 | import java.util.Iterator; |
2957 | @@ -13,7 +15,7 @@ |
2958 | * TODO: check that input type is T?!??!? |
2959 | * |
2960 | */ |
2961 | -public abstract class ExtendedJTabbedPane<T> extends JTabbedPane implements Iterable<T>{ |
2962 | +public abstract class ExtendedJTabbedPane<T extends Component> extends JTabbedPane implements Iterable<T>{ |
2963 | |
2964 | public ExtendedJTabbedPane() { |
2965 | } |
2966 | @@ -80,7 +82,7 @@ |
2967 | } |
2968 | |
2969 | @Override |
2970 | - public Iterator<T> iterator() { |
2971 | + public @NotNull Iterator<T> iterator() { |
2972 | return new TabIterator(); |
2973 | } |
2974 | |
2975 | @@ -95,6 +97,8 @@ |
2976 | |
2977 | @Override |
2978 | public T next() { |
2979 | + //XXX - known unsafe call, in theory someone could add something not of type T |
2980 | + //noinspection unchecked |
2981 | T toReturn = (T) getTabComponentAt(position); |
2982 | position += 1; |
2983 | return toReturn; |
2984 | |
2985 | === added file 'src/net/tapaal/swinghelpers/GridBagHelper.java' |
2986 | --- src/net/tapaal/swinghelpers/GridBagHelper.java 1970-01-01 00:00:00 +0000 |
2987 | +++ src/net/tapaal/swinghelpers/GridBagHelper.java 2020-08-10 09:00:56 +0000 |
2988 | @@ -0,0 +1,82 @@ |
2989 | +package net.tapaal.swinghelpers; |
2990 | + |
2991 | +import java.awt.*; |
2992 | + |
2993 | +public class GridBagHelper { |
2994 | + |
2995 | + |
2996 | + |
2997 | + |
2998 | + public enum Anchor { |
2999 | + NORTH(11), |
3000 | + EAST(13), |
3001 | + WEST(17), |
3002 | + NORTHWEST(18); |
3003 | + |
3004 | + public final int value; |
3005 | + |
3006 | + Anchor(int value) { |
3007 | + this.value = value; |
3008 | + } |
3009 | + } |
3010 | + |
3011 | + public enum Fill { |
3012 | + HORIZONTAL(2); |
3013 | + |
3014 | + public final int value; |
3015 | + |
3016 | + Fill(int value) { |
3017 | + |
3018 | + this.value = value; |
3019 | + } |
3020 | + } |
3021 | + |
3022 | + public static GridBagConstraints as(int gridx, int gridy, Anchor anchor, Fill fill, Insets inset) { |
3023 | + var gridBagConstraints = new GridBagConstraints(); |
3024 | + gridBagConstraints.gridx = gridx; |
3025 | + gridBagConstraints.gridy = gridy; |
3026 | + |
3027 | + if (anchor != null) { |
3028 | + gridBagConstraints.anchor = anchor.value; |
3029 | + } |
3030 | + |
3031 | + if (fill != null) { |
3032 | + gridBagConstraints.fill = fill.value; |
3033 | + } |
3034 | + |
3035 | + if (inset != null) { |
3036 | + gridBagConstraints.insets = inset; |
3037 | + } |
3038 | + |
3039 | + return gridBagConstraints; |
3040 | + } |
3041 | + public static GridBagConstraints as(int gridx, int gridy, Anchor anchor, Insets inset) { |
3042 | + return as(gridx, gridy, anchor, null, inset); |
3043 | + } |
3044 | + |
3045 | + public static GridBagConstraints as(int gridx, int gridy, Fill fill, Insets inset) { |
3046 | + return as(gridx, gridy, null, fill, inset); |
3047 | + } |
3048 | + |
3049 | + public static GridBagConstraints as(int gridx, int gridy, Anchor anchor) { |
3050 | + return as(gridx, gridy, anchor, null); |
3051 | + } |
3052 | + |
3053 | + public static GridBagConstraints as(int gridx, int gridy, Insets inset) { |
3054 | + return as(gridx, gridy, null, null, inset); |
3055 | + } |
3056 | + |
3057 | + public static GridBagConstraints as(int gridx, int gridy) { |
3058 | + return as(gridx, gridy, null, null, null); |
3059 | + } |
3060 | + public static GridBagConstraints as(int gridx, int gridy, int gridwidth, Anchor anchor, Insets inset) { |
3061 | + return as(gridx, gridy, gridwidth, 1, anchor, inset); |
3062 | + } |
3063 | + public static GridBagConstraints as(int gridx, int gridy, int gridwidth, int gridtheight, Anchor anchor, Insets inset) { |
3064 | + var r = as(gridx, gridy, anchor, null, inset ); |
3065 | + r.gridwidth = gridwidth; |
3066 | + r.gridheight = gridtheight; |
3067 | + return r; |
3068 | + } |
3069 | + |
3070 | +} |
3071 | |
3072 | === modified file 'src/pipe/dataLayer/Template.java' |
3073 | --- src/pipe/dataLayer/Template.java 2020-07-27 07:17:11 +0000 |
3074 | +++ src/pipe/dataLayer/Template.java 2020-08-10 09:00:56 +0000 |
3075 | @@ -2,7 +2,6 @@ |
3076 | |
3077 | import pipe.gui.Zoomer; |
3078 | import dk.aau.cs.model.tapn.TimedArcPetriNet; |
3079 | -import dk.aau.cs.util.Require; |
3080 | |
3081 | public class Template { |
3082 | private final TimedArcPetriNet net; |
3083 | |
3084 | === modified file 'src/pipe/gui/AnimationControlSidePanel.java' |
3085 | --- src/pipe/gui/AnimationControlSidePanel.java 2020-05-25 07:16:04 +0000 |
3086 | +++ src/pipe/gui/AnimationControlSidePanel.java 2020-08-10 09:00:56 +0000 |
3087 | @@ -61,7 +61,7 @@ |
3088 | setLayout(new GridBagLayout()); |
3089 | GridBagConstraints c = new GridBagConstraints(); |
3090 | |
3091 | - firermodebox = new NonsearchableJComboBox<>(animator.FIRINGMODES); |
3092 | + firermodebox = new NonsearchableJComboBox<>(Animator.FIRINGMODES); |
3093 | updateFiringModeComboBox(); |
3094 | |
3095 | firermodebox.addActionListener(evt -> animator.setFiringmode((String) firermodebox.getSelectedItem())); |
3096 | |
3097 | === modified file 'src/pipe/gui/AnimationSettingsDialog.java' |
3098 | --- src/pipe/gui/AnimationSettingsDialog.java 2020-05-18 14:15:24 +0000 |
3099 | +++ src/pipe/gui/AnimationSettingsDialog.java 2020-08-10 09:00:56 +0000 |
3100 | @@ -4,8 +4,6 @@ |
3101 | import java.awt.GridBagConstraints; |
3102 | import java.awt.GridBagLayout; |
3103 | import java.awt.Insets; |
3104 | -import java.awt.event.ActionEvent; |
3105 | -import java.awt.event.ActionListener; |
3106 | |
3107 | import javax.swing.JButton; |
3108 | import javax.swing.JDialog; |
3109 | |
3110 | === modified file 'src/pipe/gui/Animator.java' |
3111 | --- src/pipe/gui/Animator.java 2020-06-18 11:31:04 +0000 |
3112 | +++ src/pipe/gui/Animator.java 2020-08-10 09:00:56 +0000 |
3113 | @@ -314,7 +314,7 @@ |
3114 | BigDecimal delayGranularity = tab.getDelayEnabledTransitionControl().getValue(); |
3115 | //Make sure the granularity is small enough |
3116 | BigDecimal lowerBound = IntervalOperations.getRatBound(dInterval.lowerBound()).getBound(); |
3117 | - if(!dInterval.IsLowerBoundNonStrict() && !dInterval.isIncluded(lowerBound.add(delayGranularity))){ |
3118 | + if(!dInterval.isLowerBoundNonStrict() && !dInterval.isIncluded(lowerBound.add(delayGranularity))){ |
3119 | do{ |
3120 | delayGranularity = delayGranularity.divide(BigDecimal.TEN); |
3121 | } while (delayGranularity.compareTo(new BigDecimal("0.00001")) >= 0 && !dInterval.isIncluded(lowerBound.add(delayGranularity))); |
3122 | |
3123 | === modified file 'src/pipe/gui/CreateGui.java' |
3124 | --- src/pipe/gui/CreateGui.java 2020-06-29 06:55:51 +0000 |
3125 | +++ src/pipe/gui/CreateGui.java 2020-08-10 09:00:56 +0000 |
3126 | @@ -1,17 +1,17 @@ |
3127 | package pipe.gui; |
3128 | |
3129 | +import java.awt.*; |
3130 | import java.io.InputStream; |
3131 | import java.util.ArrayList; |
3132 | import java.util.List; |
3133 | - |
3134 | import com.sun.jna.Platform; |
3135 | +import dk.aau.cs.debug.Logger; |
3136 | import net.tapaal.TAPAAL; |
3137 | +import net.tapaal.resourcemanager.ResourceManager; |
3138 | import pipe.dataLayer.DataLayer; |
3139 | import pipe.gui.canvas.DrawingSurfaceImpl; |
3140 | -import pipe.gui.handler.SpecialMacHandler; |
3141 | import dk.aau.cs.gui.TabContent; |
3142 | |
3143 | - |
3144 | public class CreateGui { |
3145 | |
3146 | private final static GuiFrame appGui = new GuiFrame(TAPAAL.getProgramName()); |
3147 | @@ -21,13 +21,31 @@ |
3148 | |
3149 | public static void init() { |
3150 | |
3151 | - if (Platform.isMac()){ |
3152 | - try { |
3153 | - SpecialMacHandler.postprocess(); |
3154 | - } catch (NoClassDefFoundError e) { |
3155 | - //Failed loading special mac handler, ignore and run program without MacOS integration |
3156 | - } |
3157 | - } |
3158 | + try { |
3159 | + Desktop.getDesktop().setAboutHandler(e -> appGuiController.showAbout()); |
3160 | + } catch (SecurityException | UnsupportedOperationException ignored) { |
3161 | + Logger.log("Failed to set native about handler"); |
3162 | + } |
3163 | + |
3164 | + try { |
3165 | + Desktop.getDesktop().setQuitHandler( |
3166 | + (e, response) -> { |
3167 | + appGuiController.exit(); |
3168 | + response.cancelQuit(); //If we get here the request was canceled. |
3169 | + } |
3170 | + ); |
3171 | + |
3172 | + } catch (SecurityException | UnsupportedOperationException ignored) { |
3173 | + Logger.log("Failed to set native quit handler"); |
3174 | + } |
3175 | + |
3176 | + try { |
3177 | + Image appImage = ResourceManager.getIcon("icon.png").getImage(); |
3178 | + Taskbar.getTaskbar().setIconImage(appImage); |
3179 | + |
3180 | + } catch (SecurityException | UnsupportedOperationException ignored) { |
3181 | + Logger.log("Failed to set DockIcon"); |
3182 | + } |
3183 | |
3184 | appGui.setVisible(true); |
3185 | appGuiController.checkForUpdate(false); |
3186 | |
3187 | === modified file 'src/pipe/gui/DelayEnabledTransitionControl.java' |
3188 | --- src/pipe/gui/DelayEnabledTransitionControl.java 2020-06-21 11:29:58 +0000 |
3189 | +++ src/pipe/gui/DelayEnabledTransitionControl.java 2020-08-10 09:00:56 +0000 |
3190 | @@ -3,22 +3,17 @@ |
3191 | import java.awt.Dimension; |
3192 | import java.awt.GridBagConstraints; |
3193 | import java.awt.GridBagLayout; |
3194 | -import java.awt.Insets; |
3195 | import java.math.BigDecimal; |
3196 | import java.math.MathContext; |
3197 | import java.util.Hashtable; |
3198 | |
3199 | import javax.swing.BorderFactory; |
3200 | -import javax.swing.JButton; |
3201 | import javax.swing.JCheckBox; |
3202 | import javax.swing.JComboBox; |
3203 | -import javax.swing.JDialog; |
3204 | import javax.swing.JLabel; |
3205 | import javax.swing.JPanel; |
3206 | import javax.swing.JSlider; |
3207 | |
3208 | -import pipe.gui.widgets.EscapableDialog; |
3209 | - |
3210 | import dk.aau.cs.model.tapn.simulation.DelayMode; |
3211 | import dk.aau.cs.model.tapn.simulation.ManualDelayMode; |
3212 | import dk.aau.cs.model.tapn.simulation.RandomDelayMode; |
3213 | @@ -59,7 +54,7 @@ |
3214 | setValue(defaultGranularity); |
3215 | |
3216 | DelayMode[] items = {ShortestDelayMode.getInstance(), RandomDelayMode.getInstance(), ManualDelayMode.getInstance()}; |
3217 | - delayMode = new JComboBox(items); |
3218 | + delayMode = new JComboBox<>(items); |
3219 | setDelayMode(defaultDelayMode); |
3220 | |
3221 | setRandomTransitionMode(defaultIsRandomTrasition); |
3222 | |
3223 | === modified file 'src/pipe/gui/ExportBatchDialog.java' |
3224 | --- src/pipe/gui/ExportBatchDialog.java 2020-07-13 13:58:47 +0000 |
3225 | +++ src/pipe/gui/ExportBatchDialog.java 2020-08-10 09:00:56 +0000 |
3226 | @@ -78,8 +78,8 @@ |
3227 | private JButton exportFilesButton; |
3228 | private JPanel chooserPanel; |
3229 | private JTextField destinationPathField; |
3230 | - private JList fileList; |
3231 | - private DefaultListModel listModel; |
3232 | + private JList<File> fileList; |
3233 | + private DefaultListModel<File> listModel; |
3234 | private final List<File> files = new ArrayList<File>(); |
3235 | private String lastExportPath; |
3236 | private String lastSelectPath; |
3237 | @@ -287,8 +287,8 @@ |
3238 | JPanel fileListPanel = new JPanel(new GridBagLayout()); |
3239 | fileListPanel.setBorder(BorderFactory.createTitledBorder("Files")); |
3240 | |
3241 | - listModel = new DefaultListModel(); |
3242 | - fileList = new JList(listModel); |
3243 | + listModel = new DefaultListModel<>(); |
3244 | + fileList = new JList<>(listModel); |
3245 | fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
3246 | fileList.setSelectedIndex(0); |
3247 | fileList.addKeyListener(new KeyAdapter() { |
3248 | @@ -300,7 +300,7 @@ |
3249 | } |
3250 | }); |
3251 | |
3252 | - fileList.setCellRenderer(new FileNameCellRenderer()); |
3253 | + fileList.setCellRenderer(new FileNameCellRenderer<>()); |
3254 | GridBagConstraints gbc = new GridBagConstraints(); |
3255 | |
3256 | JScrollPane scrollpane = new JScrollPane(fileList); |
3257 | |
3258 | === modified file 'src/pipe/gui/GuiFrame.java' |
3259 | --- src/pipe/gui/GuiFrame.java 2020-08-04 08:19:44 +0000 |
3260 | +++ src/pipe/gui/GuiFrame.java 2020-08-10 09:00:56 +0000 |
3261 | @@ -9,17 +9,16 @@ |
3262 | import java.awt.event.WindowEvent; |
3263 | import java.io.*; |
3264 | import java.net.*; |
3265 | +import java.nio.charset.StandardCharsets; |
3266 | import java.util.*; |
3267 | import java.util.jar.JarEntry; |
3268 | import java.util.jar.JarFile; |
3269 | -import javax.imageio.ImageIO; |
3270 | import javax.swing.*; |
3271 | |
3272 | -import com.apple.eawt.Application; |
3273 | +import com.sun.jna.Platform; |
3274 | import dk.aau.cs.gui.*; |
3275 | import dk.aau.cs.verification.VerifyTAPN.VerifyPN; |
3276 | import net.tapaal.Preferences; |
3277 | -import com.sun.jna.Platform; |
3278 | import net.tapaal.TAPAAL; |
3279 | import net.tapaal.helpers.Reference.MutableReference; |
3280 | import net.tapaal.helpers.Reference.Reference; |
3281 | @@ -27,10 +26,6 @@ |
3282 | import net.tapaal.swinghelpers.ToggleButtonWithoutText; |
3283 | import pipe.gui.Pipe.ElementType; |
3284 | import pipe.gui.action.GuiAction; |
3285 | -import pipe.gui.graphicElements.PetriNetObject; |
3286 | -import pipe.gui.graphicElements.tapn.TimedPlaceComponent; |
3287 | -import pipe.gui.graphicElements.tapn.TimedTransitionComponent; |
3288 | -import pipe.gui.handler.SpecialMacHandler; |
3289 | import pipe.gui.widgets.WorkflowDialog; |
3290 | import dk.aau.cs.debug.Logger; |
3291 | import dk.aau.cs.gui.smartDraw.SmartDrawDialog; |
3292 | @@ -45,7 +40,7 @@ |
3293 | // for zoom combobox and dropdown |
3294 | private final int[] zoomLevels = {40, 60, 80, 100, 120, 140, 160, 180, 200, 300}; |
3295 | |
3296 | - private String frameTitle; |
3297 | + private final String frameTitle; |
3298 | |
3299 | private Pipe.ElementType mode; |
3300 | |
3301 | @@ -53,9 +48,9 @@ |
3302 | |
3303 | final MutableReference<GuiFrameControllerActions> guiFrameController = new MutableReference<>(); |
3304 | |
3305 | - private ExtendedJTabbedPane<TabContent> appTab; |
3306 | + private final ExtendedJTabbedPane<TabContent> appTab; |
3307 | |
3308 | - private StatusBar statusBar; |
3309 | + private final StatusBar statusBar; |
3310 | private JMenuBar menuBar; |
3311 | private JToolBar drawingToolBar; |
3312 | private final JLabel featureInfoText = new JLabel(); |
3313 | @@ -351,7 +346,7 @@ |
3314 | guiFrameController.ifPresent(GuiFrameControllerActions::toggleQueries); |
3315 | } |
3316 | }; |
3317 | - private GuiAction showConstantsAction = new GuiAction("Display constants", "Show/hide global constants.", KeyStroke.getKeyStroke('4', shortcutkey), true) { |
3318 | + private final GuiAction showConstantsAction = new GuiAction("Display constants", "Show/hide global constants.", KeyStroke.getKeyStroke('4', shortcutkey), true) { |
3319 | public void actionPerformed(ActionEvent e) { |
3320 | guiFrameController.ifPresent(GuiFrameControllerActions::toggleConstants); |
3321 | } |
3322 | @@ -386,7 +381,7 @@ |
3323 | guiFrameController.ifPresent(GuiFrameControllerActions::showSimpleWorkspace); |
3324 | } |
3325 | }; |
3326 | - private GuiAction saveWorkSpaceAction = new GuiAction("Save workspace", "Save the current workspace as the default one", false) { |
3327 | + private final GuiAction saveWorkSpaceAction = new GuiAction("Save workspace", "Save the current workspace as the default one", false) { |
3328 | public void actionPerformed(ActionEvent e) { |
3329 | guiFrameController.ifPresent(GuiFrameControllerActions::saveWorkspace); |
3330 | } |
3331 | @@ -444,22 +439,22 @@ |
3332 | currentTab.ifPresent(TabContentActions::stepBackwards); |
3333 | } |
3334 | }; |
3335 | - private GuiAction timeAction = new GuiAction("Delay one time unit", "Let time pass one time unit", "W") { |
3336 | + private final GuiAction timeAction = new GuiAction("Delay one time unit", "Let time pass one time unit", "W") { |
3337 | public void actionPerformed(ActionEvent e) { |
3338 | currentTab.ifPresent(TabContentActions::timeDelay); |
3339 | } |
3340 | }; |
3341 | - private GuiAction delayFireAction = new GuiAction("Delay and fire", "Delay and fire selected transition", "F") { |
3342 | + private final GuiAction delayFireAction = new GuiAction("Delay and fire", "Delay and fire selected transition", "F") { |
3343 | public void actionPerformed(ActionEvent e) { |
3344 | currentTab.ifPresent(TabContentActions::delayAndFire); |
3345 | } |
3346 | }; |
3347 | - private GuiAction prevcomponentAction = new GuiAction("Previous component", "Previous component", "pressed UP") { |
3348 | + private final GuiAction prevcomponentAction = new GuiAction("Previous component", "Previous component", "pressed UP") { |
3349 | public void actionPerformed(ActionEvent e) { |
3350 | currentTab.ifPresent(TabContentActions::previousComponent); |
3351 | } |
3352 | }; |
3353 | - private GuiAction nextcomponentAction = new GuiAction("Next component", "Next component", "pressed DOWN") { |
3354 | + private final GuiAction nextcomponentAction = new GuiAction("Next component", "Next component", "pressed DOWN") { |
3355 | public void actionPerformed(ActionEvent e) { |
3356 | currentTab.ifPresent(TabContentActions::nextComponent); |
3357 | } |
3358 | @@ -488,10 +483,7 @@ |
3359 | this.setMinimumSize(new Dimension(825, 480)); |
3360 | |
3361 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); |
3362 | - |
3363 | - //XXX: Moved appTab from creategui needs further refacotring |
3364 | - //kyrke 2018-05-20 |
3365 | - appTab = new ExtendedJTabbedPane<TabContent>() { |
3366 | + appTab= new ExtendedJTabbedPane<TabContent>() { |
3367 | @Override |
3368 | public Component generator() { |
3369 | return new TabComponent(this) { |
3370 | @@ -556,23 +548,8 @@ |
3371 | Logger.log("Error loading L&F: " + exc); |
3372 | } |
3373 | |
3374 | - if (Platform.isMac()) { |
3375 | - |
3376 | - try { |
3377 | - new SpecialMacHandler(guiFrameController); |
3378 | - } catch (NoClassDefFoundError e) { |
3379 | - //Failed loading special mac handler, ignore and run program without MacOS integration |
3380 | - } |
3381 | - |
3382 | - //XXX Refactor to sperate function, only a test to see of this fixes issues for TAPAAL on Java9 bug #1764383 |
3383 | - Application app = Application.getApplication(); |
3384 | - try { |
3385 | - Image appImage; |
3386 | - appImage = ImageIO.read(Thread.currentThread().getContextClassLoader().getResource(ResourceManager.imgPath + "icon.png")); |
3387 | - app.setDockIconImage(appImage); |
3388 | - } catch (IOException e) { |
3389 | - Logger.log("Error loading Image"); |
3390 | - } |
3391 | + |
3392 | + if (Platform.isMac()){ |
3393 | |
3394 | //Set specific settings |
3395 | System.setProperty("apple.laf.useScreenMenuBar", "true"); |
3396 | @@ -603,11 +580,9 @@ |
3397 | private void buildMenus() { |
3398 | menuBar = new JMenuBar(); |
3399 | |
3400 | - int shortcutkey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); |
3401 | - |
3402 | - menuBar.add(buildMenuFiles(shortcutkey)); |
3403 | - menuBar.add(buildMenuEdit(shortcutkey)); |
3404 | - menuBar.add(buildMenuView(shortcutkey)); |
3405 | + menuBar.add(buildMenuFiles()); |
3406 | + menuBar.add(buildMenuEdit()); |
3407 | + menuBar.add(buildMenuView()); |
3408 | menuBar.add(buildMenuDraw()); |
3409 | menuBar.add(buildMenuAnimation()); |
3410 | menuBar.add(buildMenuTools()); |
3411 | @@ -617,7 +592,7 @@ |
3412 | |
3413 | } |
3414 | |
3415 | - private JMenu buildMenuEdit(int shortcutkey) { |
3416 | + private JMenu buildMenuEdit() { |
3417 | |
3418 | /* Edit Menu */ |
3419 | JMenu editMenu = new JMenu("Edit"); |
3420 | @@ -672,7 +647,7 @@ |
3421 | return drawMenu; |
3422 | } |
3423 | |
3424 | - private JMenu buildMenuView(int shortcutkey) { |
3425 | + private JMenu buildMenuView() { |
3426 | /* ViewMenu */ |
3427 | JMenu viewMenu = new JMenu("View"); |
3428 | viewMenu.setMnemonic('V'); |
3429 | @@ -786,8 +761,6 @@ |
3430 | |
3431 | toolsMenu.add(netStatisticsAction).setMnemonic('i'); |
3432 | |
3433 | - |
3434 | - //JMenuItem batchProcessing = new JMenuItem("Batch processing"); |
3435 | JMenuItem batchProcessing = new JMenuItem(batchProcessingAction); |
3436 | batchProcessing.setMnemonic('b'); |
3437 | toolsMenu.add(batchProcessing); |
3438 | @@ -800,7 +773,6 @@ |
3439 | smartDrawDialog.setMnemonic('D'); |
3440 | toolsMenu.add(smartDrawDialog); |
3441 | |
3442 | - //Stip off timing information |
3443 | JMenuItem stripTimeDialog = new JMenuItem(stripTimeDialogAction); |
3444 | stripTimeDialog.setMnemonic('e'); |
3445 | toolsMenu.add(stripTimeDialog); |
3446 | @@ -940,8 +912,6 @@ |
3447 | } |
3448 | }; |
3449 | |
3450 | - //JMenuItem newItem = new JMenuItem(a); |
3451 | - |
3452 | zoomMenu.add(newZoomAction); |
3453 | } |
3454 | |
3455 | @@ -1262,16 +1232,8 @@ |
3456 | // Enable all draw actions |
3457 | startAction.setSelected(false); |
3458 | |
3459 | - if (getCurrentTab().isInAnimationMode()) { |
3460 | - getCurrentTab().getAnimator().restoreModel(); |
3461 | - hideComponentWindow(); |
3462 | - } |
3463 | - |
3464 | - getCurrentTab().switchToEditorComponents(); |
3465 | - |
3466 | break; |
3467 | case animation: |
3468 | - getCurrentTab().switchToAnimationComponents(true); |
3469 | startAction.setSelected(true); |
3470 | |
3471 | break; |
3472 | @@ -1299,20 +1261,6 @@ |
3473 | a.dispose(); |
3474 | } |
3475 | |
3476 | - private void hideComponentWindow() { |
3477 | - ArrayList<PetriNetObject> selection = getCurrentTab().drawingSurface().getGuiModel().getPNObjects(); |
3478 | - |
3479 | - for (PetriNetObject pn : selection) { |
3480 | - if (pn instanceof TimedPlaceComponent) { |
3481 | - TimedPlaceComponent place = (TimedPlaceComponent) pn; |
3482 | - place.showAgeOfTokens(false); |
3483 | - } else if (pn instanceof TimedTransitionComponent) { |
3484 | - TimedTransitionComponent transition = (TimedTransitionComponent) pn; |
3485 | - transition.showDInterval(false); |
3486 | - } |
3487 | - } |
3488 | - } |
3489 | - |
3490 | //XXX temp while refactoring, kyrke - 2019-07-25, should only be called from TabContent |
3491 | @Override |
3492 | public void updateMode(Pipe.ElementType _mode) { |
3493 | @@ -1384,7 +1332,7 @@ |
3494 | |
3495 | @Override |
3496 | public void setShowToolTipsSelected(boolean b) { |
3497 | - showTokenAgeAction.setSelected(b); |
3498 | + showToolTipsAction.setSelected(b); |
3499 | } |
3500 | |
3501 | @Override |
3502 | @@ -1444,7 +1392,7 @@ |
3503 | return false; |
3504 | } |
3505 | |
3506 | - private JMenu buildMenuFiles(int shortcutkey) { |
3507 | + private JMenu buildMenuFiles() { |
3508 | JMenu fileMenu = new JMenu("File"); |
3509 | fileMenu.setMnemonic('F'); |
3510 | |
3511 | @@ -1575,7 +1523,7 @@ |
3512 | /* A JAR path */ |
3513 | String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf('!')); // strip out only the JAR |
3514 | // file |
3515 | - JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8")); |
3516 | + JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8)); |
3517 | Enumeration<JarEntry> entries = jar.entries(); // gives ALL entries in jar |
3518 | Set<String> result = new HashSet<String>(); // avoid duplicates in case it is a subdirectory |
3519 | while (entries.hasMoreElements()) { |
3520 | @@ -1626,10 +1574,10 @@ |
3521 | return appTab.getTitleAt(appTab.getSelectedIndex()); |
3522 | } |
3523 | |
3524 | + //XXX: Needs further cleanup |
3525 | + @Deprecated |
3526 | public boolean isShowingDelayEnabledTransitions() { |
3527 | - //XXX: |
3528 | - return true; |
3529 | - //return showDelayEnabledTransitions; |
3530 | + return showDelayEnabledTransitionsAction.isSelected(); |
3531 | } |
3532 | |
3533 | public boolean showZeroToInfinityIntervals() { |
3534 | |
3535 | === modified file 'src/pipe/gui/GuiFrameController.java' |
3536 | --- src/pipe/gui/GuiFrameController.java 2020-08-03 14:00:57 +0000 |
3537 | +++ src/pipe/gui/GuiFrameController.java 2020-08-10 09:00:56 +0000 |
3538 | @@ -33,8 +33,8 @@ |
3539 | |
3540 | public class GuiFrameController implements GuiFrameControllerActions{ |
3541 | |
3542 | - GuiFrame guiFrameDirectAccess; //XXX - while refactoring shold only use guiFrameActions |
3543 | - GuiFrameActions guiFrame; |
3544 | + final GuiFrame guiFrameDirectAccess; //XXX - while refactoring shold only use guiFrameActions |
3545 | + final GuiFrameActions guiFrame; |
3546 | |
3547 | final MutableReference<TabContentActions> currentTab = new MutableReference<>(); |
3548 | |
3549 | @@ -88,6 +88,7 @@ |
3550 | DelayEnabledTransitionControl.setDefaultIsRandomTransition(prefs.getDelayEnabledTransitionIsRandomTransition()); |
3551 | |
3552 | showToolTips = prefs.getShowToolTips(); |
3553 | + setDisplayToolTips(showToolTips); |
3554 | guiFrame.setShowToolTipsSelected(showToolTips); |
3555 | |
3556 | showZeroToInfinityIntervals = prefs.getShowZeroInfIntervals(); |
3557 | @@ -109,6 +110,8 @@ |
3558 | |
3559 | guiFrame.attachTabToGuiFrame(tab); |
3560 | guiFrame.changeToTab(tab); |
3561 | + //XXX fixes an issue where on first open of a net the time intervals are not shown |
3562 | + tab.drawingSurface().repaintAll(); |
3563 | |
3564 | } |
3565 | |
3566 | @@ -484,7 +487,7 @@ |
3567 | @Override |
3568 | public void showBatchProcessingDialog() { |
3569 | if (showSavePendingChangesDialogForAllTabs()) { |
3570 | - BatchProcessingDialog.showBatchProcessingDialog(new JList(new DefaultListModel())); |
3571 | + BatchProcessingDialog.showBatchProcessingDialog(new JList<>(new DefaultListModel<>())); |
3572 | } |
3573 | } |
3574 | |
3575 | @@ -670,7 +673,8 @@ |
3576 | |
3577 | @Override |
3578 | public void toggleDisplayToolTips() { |
3579 | - setDisplayToolTips(!showToolTips); |
3580 | + showToolTips = !showToolTips; |
3581 | + setDisplayToolTips(showToolTips); |
3582 | } |
3583 | |
3584 | private void setDisplayToolTips(boolean b) { |
3585 | |
3586 | === modified file 'src/pipe/gui/Pipe.java' |
3587 | --- src/pipe/gui/Pipe.java 2020-04-18 13:17:20 +0000 |
3588 | +++ src/pipe/gui/Pipe.java 2020-08-10 09:00:56 +0000 |
3589 | @@ -62,19 +62,19 @@ |
3590 | |
3591 | public static final int NAMELABEL_OFFSET = 12; |
3592 | |
3593 | - public static int DEFAULT_BUFFER_CAPACITY = 50; |
3594 | + public static final int DEFAULT_BUFFER_CAPACITY = 50; |
3595 | |
3596 | public static final int ZOOM_DELTA = 10; |
3597 | public static final int ZOOM_MAX = 300; |
3598 | public static final int ZOOM_MIN = 40; |
3599 | public static final int ZOOM_DEFAULT = 100; |
3600 | |
3601 | - public static Color BACKGROUND_COLOR = new Color(255, 255, 255, 200); |
3602 | - public static Color ANIMATION_BACKGROUND_COLOR = new Color(246, 250, 255); |
3603 | + public static final Color BACKGROUND_COLOR = new Color(255, 255, 255, 200); |
3604 | + public static final Color ANIMATION_BACKGROUND_COLOR = new Color(246, 250, 255); |
3605 | |
3606 | - public static Color QUERY_SATISFIED_COLOR = new Color(44, 103, 0); |
3607 | - public static Color QUERY_NOT_SATISFIED_COLOR = new Color(204, 0, 0); |
3608 | - public static Color QUERY_INCONCLUSIVE_COLOR = new Color(255, 153, 0); |
3609 | + public static final Color QUERY_SATISFIED_COLOR = new Color(44, 103, 0); |
3610 | + public static final Color QUERY_NOT_SATISFIED_COLOR = new Color(204, 0, 0); |
3611 | + public static final Color QUERY_INCONCLUSIVE_COLOR = new Color(255, 153, 0); |
3612 | |
3613 | public static final String verifytaMinRev = "4.1.19"; |
3614 | public static final String verifytapnMinRev = "1.3.0"; |
3615 | |
3616 | === modified file 'src/pipe/gui/RunVerification.java' |
3617 | --- src/pipe/gui/RunVerification.java 2020-07-13 13:58:47 +0000 |
3618 | +++ src/pipe/gui/RunVerification.java 2020-08-10 09:00:56 +0000 |
3619 | @@ -22,7 +22,6 @@ |
3620 | import javax.swing.table.TableModel; |
3621 | import javax.swing.table.TableRowSorter; |
3622 | |
3623 | -import pipe.gui.GuiFrame.GUIMode; |
3624 | import dk.aau.cs.Messenger; |
3625 | import dk.aau.cs.model.tapn.simulation.TAPNNetworkTrace; |
3626 | import dk.aau.cs.util.MemoryMonitor; |
3627 | @@ -62,8 +61,6 @@ |
3628 | ); |
3629 | |
3630 | if (result.getTrace() != null) { |
3631 | - CreateGui.getApp().setGUIMode(GUIMode.animation); |
3632 | - |
3633 | CreateGui.getAnimator().setTrace(result.getTrace()); |
3634 | } |
3635 | } |
3636 | |
3637 | === modified file 'src/pipe/gui/SelectionManager.java' |
3638 | --- src/pipe/gui/SelectionManager.java 2020-07-13 13:58:47 +0000 |
3639 | +++ src/pipe/gui/SelectionManager.java 2020-08-10 09:00:56 +0000 |
3640 | @@ -12,7 +12,6 @@ |
3641 | import java.awt.event.MouseWheelEvent; |
3642 | import java.util.ArrayList; |
3643 | import java.util.List; |
3644 | -import java.util.stream.Collectors; |
3645 | |
3646 | import org.jetbrains.annotations.Nullable; |
3647 | import pipe.gui.canvas.DrawingSurfaceImpl; |
3648 | |
3649 | === modified file 'src/pipe/gui/action/GuiAction.java' |
3650 | --- src/pipe/gui/action/GuiAction.java 2020-05-27 13:07:27 +0000 |
3651 | +++ src/pipe/gui/action/GuiAction.java 2020-08-10 09:00:56 +0000 |
3652 | @@ -10,7 +10,6 @@ |
3653 | import javax.swing.KeyStroke; |
3654 | |
3655 | import net.tapaal.resourcemanager.ResourceManager; |
3656 | -import pipe.gui.CreateGui; |
3657 | |
3658 | /** |
3659 | * GuiAction class |
3660 | |
3661 | === modified file 'src/pipe/gui/action/SplitArcAction.java' |
3662 | --- src/pipe/gui/action/SplitArcAction.java 2020-07-13 13:58:47 +0000 |
3663 | +++ src/pipe/gui/action/SplitArcAction.java 2020-08-10 09:00:56 +0000 |
3664 | @@ -17,7 +17,7 @@ |
3665 | public class SplitArcAction extends javax.swing.AbstractAction { |
3666 | |
3667 | private final Arc selected; |
3668 | - Point2D.Double mouseposition; |
3669 | + private final Point2D.Double mouseposition; |
3670 | |
3671 | public SplitArcAction(Arc arc, Point mousepos) { |
3672 | selected = arc; |
3673 | |
3674 | === modified file 'src/pipe/gui/canvas/Canvas.java' |
3675 | --- src/pipe/gui/canvas/Canvas.java 2020-06-19 08:55:38 +0000 |
3676 | +++ src/pipe/gui/canvas/Canvas.java 2020-08-10 09:00:56 +0000 |
3677 | @@ -1,7 +1,6 @@ |
3678 | package pipe.gui.canvas; |
3679 | |
3680 | import pipe.gui.graphicElements.GraphicalElement; |
3681 | -import pipe.gui.graphicElements.PetriNetObject; |
3682 | |
3683 | public interface Canvas { |
3684 | |
3685 | |
3686 | === modified file 'src/pipe/gui/canvas/DrawingSurfaceImpl.java' |
3687 | --- src/pipe/gui/canvas/DrawingSurfaceImpl.java 2020-08-04 06:34:24 +0000 |
3688 | +++ src/pipe/gui/canvas/DrawingSurfaceImpl.java 2020-08-10 09:00:56 +0000 |
3689 | @@ -11,14 +11,12 @@ |
3690 | import javax.swing.event.MouseInputAdapter; |
3691 | |
3692 | import dk.aau.cs.gui.TabContent; |
3693 | -import dk.aau.cs.gui.undo.Command; |
3694 | import net.tapaal.gui.DrawingSurfaceManager.AbstractDrawingSurfaceManager; |
3695 | import net.tapaal.helpers.Reference.Reference; |
3696 | import pipe.dataLayer.DataLayer; |
3697 | import pipe.gui.*; |
3698 | import pipe.gui.Pipe.ElementType; |
3699 | import pipe.gui.graphicElements.*; |
3700 | -import pipe.gui.graphicElements.tapn.*; |
3701 | import pipe.gui.undo.*; |
3702 | import dk.aau.cs.gui.NameGenerator; |
3703 | import dk.aau.cs.model.tapn.TimedArcPetriNet; |
3704 | |
3705 | === modified file 'src/pipe/gui/canvas/PrototypeCanvas.java' |
3706 | --- src/pipe/gui/canvas/PrototypeCanvas.java 2020-06-19 08:55:38 +0000 |
3707 | +++ src/pipe/gui/canvas/PrototypeCanvas.java 2020-08-10 09:00:56 +0000 |
3708 | @@ -1,7 +1,6 @@ |
3709 | package pipe.gui.canvas; |
3710 | |
3711 | import pipe.gui.graphicElements.GraphicalElement; |
3712 | -import pipe.gui.graphicElements.PetriNetObject; |
3713 | |
3714 | /** |
3715 | * ProtypeCanvas is used by controllers to draw objects that are not (yet) committed to the medel |
3716 | |
3717 | === modified file 'src/pipe/gui/graphicElements/AnnotationNote.java' |
3718 | --- src/pipe/gui/graphicElements/AnnotationNote.java 2020-07-13 13:58:47 +0000 |
3719 | +++ src/pipe/gui/graphicElements/AnnotationNote.java 2020-08-10 09:00:56 +0000 |
3720 | @@ -315,14 +315,18 @@ |
3721 | public ResizePoint(Note obj, int type) { |
3722 | myNote = obj; |
3723 | setOpaque(false); |
3724 | - setBounds(-SIZE - 1, -SIZE - 1, 2 * SIZE |
3725 | - + Pipe.ANNOTATION_SIZE_OFFSET + 1, 2 * SIZE |
3726 | - + Pipe.ANNOTATION_SIZE_OFFSET + 1); |
3727 | + setBounds( |
3728 | + -SIZE - 1, -SIZE - 1, |
3729 | + 2 * SIZE + Pipe.ANNOTATION_SIZE_OFFSET + 1, |
3730 | + 2 * SIZE + Pipe.ANNOTATION_SIZE_OFFSET + 1 |
3731 | + ); |
3732 | typeMask = type; |
3733 | } |
3734 | |
3735 | - public void setLocation(double x, double y) { |
3736 | - super.setLocation((int) (x - SIZE), (int) (y - SIZE)); |
3737 | + //Adjust the point a bit to hit center on corner of box |
3738 | + @Override |
3739 | + public void setLocation(int x, int y) { |
3740 | + super.setLocation(x - SIZE, y - SIZE); |
3741 | } |
3742 | |
3743 | private void drag(int x, int y) { |
3744 | |
3745 | === modified file 'src/pipe/gui/graphicElements/Arc.java' |
3746 | --- src/pipe/gui/graphicElements/Arc.java 2020-06-30 06:41:30 +0000 |
3747 | +++ src/pipe/gui/graphicElements/Arc.java 2020-08-10 09:00:56 +0000 |
3748 | @@ -5,11 +5,9 @@ |
3749 | import java.awt.event.KeyEvent; |
3750 | import java.awt.geom.AffineTransform; |
3751 | import java.awt.geom.Point2D; |
3752 | -import java.util.function.Supplier; |
3753 | |
3754 | import javax.swing.*; |
3755 | |
3756 | -import pipe.gui.CreateGui; |
3757 | import pipe.gui.Grid; |
3758 | import pipe.gui.Pipe; |
3759 | import pipe.gui.Zoomer; |
3760 | @@ -368,7 +366,6 @@ |
3761 | * Handles keyboard input when drawing arcs in the GUI. Keys are bound to action names, |
3762 | * and action names are mapped to action objects. The key bindings are disabled when the |
3763 | * arc object is deleted, or the arc is connected to a place/transition. |
3764 | - * @param action |
3765 | */ |
3766 | public void enableDrawingKeyBindings(Runnable action) { |
3767 | InputMap iMap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); |
3768 | |
3769 | === modified file 'src/pipe/gui/graphicElements/Place.java' |
3770 | --- src/pipe/gui/graphicElements/Place.java 2020-06-29 06:55:51 +0000 |
3771 | +++ src/pipe/gui/graphicElements/Place.java 2020-08-10 09:00:56 +0000 |
3772 | @@ -19,20 +19,20 @@ |
3773 | protected static final int DIAMETER = Pipe.PLACE_TRANSITION_HEIGHT; |
3774 | |
3775 | // Token Width and Height |
3776 | - protected static int tWidth = 5; |
3777 | - protected static int tHeight = 5; |
3778 | + protected static final int tWidth = 5; |
3779 | + protected static final int tHeight = 5; |
3780 | |
3781 | // Token dot position offsets |
3782 | - protected static int tLeftX = 7; |
3783 | - protected static int tRightX = 19; |
3784 | - protected static int tTopY = 7; |
3785 | - protected static int tBotY = 19; |
3786 | - protected static int tMiddleX = 13; |
3787 | - protected static int tMiddleY = 13; |
3788 | + protected static final int tLeftX = 7; |
3789 | + protected static final int tRightX = 19; |
3790 | + protected static final int tTopY = 7; |
3791 | + protected static final int tBotY = 19; |
3792 | + protected static final int tMiddleX = 13; |
3793 | + protected static final int tMiddleY = 13; |
3794 | |
3795 | // Ellipse2D.Double place |
3796 | - protected static Ellipse2D.Double placeEllipse = new Ellipse2D.Double(0, 0, DIAMETER, DIAMETER); |
3797 | - protected static Shape proximityPlace = (new BasicStroke(Pipe.PLACE_TRANSITION_PROXIMITY_RADIUS)).createStrokedShape(placeEllipse); |
3798 | + protected static final Ellipse2D.Double placeEllipse = new Ellipse2D.Double(0, 0, DIAMETER, DIAMETER); |
3799 | + protected static final Shape proximityPlace = (new BasicStroke(Pipe.PLACE_TRANSITION_PROXIMITY_RADIUS)).createStrokedShape(placeEllipse); |
3800 | |
3801 | |
3802 | public Place( |
3803 | |
3804 | === modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java' |
3805 | --- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-06-23 13:43:53 +0000 |
3806 | +++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-08-10 09:00:56 +0000 |
3807 | @@ -5,7 +5,6 @@ |
3808 | |
3809 | import java.awt.*; |
3810 | import java.awt.geom.Point2D; |
3811 | -import java.util.Iterator; |
3812 | import java.util.LinkedList; |
3813 | |
3814 | /** |
3815 | |
3816 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java' |
3817 | --- src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-06-12 14:09:08 +0000 |
3818 | +++ src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-08-10 09:00:56 +0000 |
3819 | @@ -4,7 +4,6 @@ |
3820 | |
3821 | import pipe.gui.CreateGui; |
3822 | import pipe.gui.Pipe; |
3823 | -import pipe.gui.graphicElements.Place; |
3824 | import pipe.gui.graphicElements.PlaceTransitionObject; |
3825 | import pipe.gui.handler.TimedArcHandler; |
3826 | import pipe.gui.undo.ArcTimeIntervalEdit; |
3827 | |
3828 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java' |
3829 | --- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-06-21 13:12:27 +0000 |
3830 | +++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-08-10 09:00:56 +0000 |
3831 | @@ -27,11 +27,9 @@ |
3832 | import pipe.gui.Pipe; |
3833 | import pipe.gui.graphicElements.Place; |
3834 | import pipe.gui.handler.PlaceHandler; |
3835 | -import pipe.gui.undo.TimedPlaceInvariantEdit; |
3836 | import pipe.gui.widgets.EscapableDialog; |
3837 | import pipe.gui.widgets.PlaceEditorPanel; |
3838 | import dk.aau.cs.gui.Context; |
3839 | -import dk.aau.cs.gui.undo.Command; |
3840 | import dk.aau.cs.model.tapn.Bound.InfBound; |
3841 | import dk.aau.cs.model.tapn.Constant; |
3842 | import dk.aau.cs.model.tapn.Bound; |
3843 | |
3844 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java' |
3845 | --- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-08-04 08:19:44 +0000 |
3846 | +++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-08-10 09:00:56 +0000 |
3847 | @@ -90,8 +90,7 @@ |
3848 | @Override |
3849 | public void showEditor() { |
3850 | // Build interface |
3851 | - EscapableDialog guiDialog = new EscapableDialog(CreateGui.getApp(), |
3852 | - "Edit Transition", true); |
3853 | + EscapableDialog guiDialog = new EscapableDialog(CreateGui.getApp(), "Edit Transition", true); |
3854 | |
3855 | Container contentPane = guiDialog.getContentPane(); |
3856 | |
3857 | |
3858 | === modified file 'src/pipe/gui/handler/ArcHandler.java' |
3859 | --- src/pipe/gui/handler/ArcHandler.java 2020-07-09 12:55:25 +0000 |
3860 | +++ src/pipe/gui/handler/ArcHandler.java 2020-08-10 09:00:56 +0000 |
3861 | @@ -1,18 +1,11 @@ |
3862 | package pipe.gui.handler; |
3863 | |
3864 | import java.awt.event.MouseEvent; |
3865 | -import java.awt.geom.Point2D; |
3866 | import javax.swing.*; |
3867 | |
3868 | import net.tapaal.TAPAAL; |
3869 | -import pipe.gui.CreateGui; |
3870 | -import pipe.gui.Zoomer; |
3871 | import pipe.gui.action.SplitArcAction; |
3872 | import pipe.gui.graphicElements.Arc; |
3873 | -import pipe.gui.graphicElements.PlaceTransitionObject; |
3874 | -import pipe.gui.graphicElements.tapn.TimedInputArcComponent; |
3875 | -import pipe.gui.graphicElements.tapn.TimedOutputArcComponent; |
3876 | -import pipe.gui.graphicElements.tapn.TimedTransportArcComponent; |
3877 | |
3878 | /** |
3879 | * Class used to implement methods corresponding to mouse events on arcs. |
3880 | |
3881 | === modified file 'src/pipe/gui/handler/PetriNetObjectHandler.java' |
3882 | --- src/pipe/gui/handler/PetriNetObjectHandler.java 2020-06-29 12:11:25 +0000 |
3883 | +++ src/pipe/gui/handler/PetriNetObjectHandler.java 2020-08-10 09:00:56 +0000 |
3884 | @@ -11,11 +11,7 @@ |
3885 | import pipe.gui.Grid; |
3886 | import pipe.gui.Pipe.ElementType; |
3887 | |
3888 | -import pipe.gui.graphicElements.AnnotationNote; |
3889 | -import pipe.gui.graphicElements.Arc; |
3890 | import pipe.gui.graphicElements.PetriNetObject; |
3891 | -import pipe.gui.graphicElements.tapn.TimedPlaceComponent; |
3892 | -import pipe.gui.graphicElements.tapn.TimedTransitionComponent; |
3893 | |
3894 | /** |
3895 | * Class used to implement methods corresponding to mouse events on all |
3896 | @@ -67,18 +63,6 @@ |
3897 | return popup; |
3898 | } |
3899 | |
3900 | - /** |
3901 | - * Displays the popup menu |
3902 | - */ |
3903 | - private void checkForPopup(MouseEvent e) { |
3904 | - if (SwingUtilities.isRightMouseButton(e) && CreateGui.getApp().getMode() == ElementType.SELECT) { |
3905 | - JPopupMenu m = getPopup(e); |
3906 | - if (m != null && !(myObject instanceof TimedPlaceComponent || myObject instanceof TimedTransitionComponent || myObject instanceof Arc || myObject instanceof AnnotationNote)) { |
3907 | - m.show(myObject, e.getX(), e.getY()); |
3908 | - } |
3909 | - } |
3910 | - } |
3911 | - |
3912 | @Override |
3913 | public void mousePressed(MouseEvent e) { |
3914 | if(CreateGui.getCurrentTab().isInAnimationMode()) return; |
3915 | @@ -93,10 +77,7 @@ |
3916 | } |
3917 | dragInit = e.getPoint(); |
3918 | } |
3919 | - |
3920 | - if (CreateGui.getApp().isEditionAllowed()) { |
3921 | - checkForPopup(e); |
3922 | - } |
3923 | + |
3924 | } |
3925 | |
3926 | /** |
3927 | @@ -106,10 +87,6 @@ |
3928 | @Override |
3929 | public void mouseReleased(MouseEvent e) { |
3930 | if(CreateGui.getCurrentTab().isInAnimationMode()) return; |
3931 | - // Have to check for popup here as well as on pressed for crossplatform!! |
3932 | - if (CreateGui.getApp().isEditionAllowed()) { |
3933 | - checkForPopup(e); |
3934 | - } |
3935 | |
3936 | if (!SwingUtilities.isLeftMouseButton(e)) { |
3937 | return; |
3938 | |
3939 | === modified file 'src/pipe/gui/handler/PlaceHandler.java' |
3940 | --- src/pipe/gui/handler/PlaceHandler.java 2020-06-29 10:58:39 +0000 |
3941 | +++ src/pipe/gui/handler/PlaceHandler.java 2020-08-10 09:00:56 +0000 |
3942 | @@ -1,19 +1,12 @@ |
3943 | package pipe.gui.handler; |
3944 | |
3945 | import java.awt.event.MouseEvent; |
3946 | -import java.awt.event.MouseWheelEvent; |
3947 | |
3948 | import javax.swing.JMenuItem; |
3949 | import javax.swing.JPopupMenu; |
3950 | -import javax.swing.SwingUtilities; |
3951 | |
3952 | -import pipe.gui.CreateGui; |
3953 | -import pipe.gui.Zoomer; |
3954 | -import pipe.gui.Pipe.ElementType; |
3955 | import pipe.gui.action.ShowHideInfoAction; |
3956 | -import pipe.gui.graphicElements.PetriNetObjectWithLabel; |
3957 | import pipe.gui.graphicElements.Place; |
3958 | -import pipe.gui.graphicElements.tapn.TimedPlaceComponent; |
3959 | |
3960 | /** |
3961 | * Class used to implement methods corresponding to mouse events on places. |
3962 | @@ -49,17 +42,4 @@ |
3963 | return popup; |
3964 | } |
3965 | |
3966 | - @Override |
3967 | - public void mouseWheelMoved(MouseWheelEvent e) { |
3968 | - if (!(CreateGui.getApp().isEditionAllowed()) || e.isControlDown() || !(myObject.isSelected()) || !(myObject instanceof TimedPlaceComponent)) { |
3969 | - return; |
3970 | - } |
3971 | - |
3972 | - TimedPlaceComponent p = (TimedPlaceComponent) myObject; |
3973 | - if (e.getWheelRotation() < 0) { |
3974 | - p.underlyingPlace().addTokens(1); |
3975 | - } else { |
3976 | - p.underlyingPlace().removeTokens(1); |
3977 | - } |
3978 | - } |
3979 | } |
3980 | |
3981 | === removed file 'src/pipe/gui/handler/SpecialMacHandler.java' |
3982 | === modified file 'src/pipe/gui/handler/TimedArcHandler.java' |
3983 | --- src/pipe/gui/handler/TimedArcHandler.java 2020-08-04 07:41:30 +0000 |
3984 | +++ src/pipe/gui/handler/TimedArcHandler.java 2020-08-10 09:00:56 +0000 |
3985 | @@ -5,13 +5,8 @@ |
3986 | import javax.swing.JMenuItem; |
3987 | import javax.swing.JPopupMenu; |
3988 | |
3989 | -import dk.aau.cs.model.tapn.TimedOutputArc; |
3990 | -import pipe.gui.action.SplitArcAction; |
3991 | import pipe.gui.graphicElements.Arc; |
3992 | -import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent; |
3993 | -import pipe.gui.graphicElements.tapn.TimedInputArcComponent; |
3994 | import pipe.gui.graphicElements.tapn.TimedOutputArcComponent; |
3995 | -import pipe.gui.graphicElements.tapn.TimedTransportArcComponent; |
3996 | |
3997 | public class TimedArcHandler extends ArcHandler { |
3998 | |
3999 | |
4000 | === modified file 'src/pipe/gui/handler/TransitionHandler.java' |
4001 | --- src/pipe/gui/handler/TransitionHandler.java 2020-06-29 10:58:39 +0000 |
4002 | +++ src/pipe/gui/handler/TransitionHandler.java 2020-08-10 09:00:56 +0000 |
4003 | @@ -1,15 +1,10 @@ |
4004 | package pipe.gui.handler; |
4005 | |
4006 | import java.awt.event.MouseEvent; |
4007 | -import java.awt.event.MouseWheelEvent; |
4008 | |
4009 | import javax.swing.JMenuItem; |
4010 | import javax.swing.JPopupMenu; |
4011 | -import javax.swing.SwingUtilities; |
4012 | |
4013 | -import pipe.gui.CreateGui; |
4014 | -import pipe.gui.Zoomer; |
4015 | -import pipe.gui.Pipe.ElementType; |
4016 | import pipe.gui.action.ShowHideInfoAction; |
4017 | import pipe.gui.graphicElements.Transition; |
4018 | |
4019 | @@ -23,24 +18,6 @@ |
4020 | super(obj); |
4021 | } |
4022 | |
4023 | - @Override |
4024 | - public void mouseWheelMoved(MouseWheelEvent e) { |
4025 | - |
4026 | - if (!(CreateGui.getApp().isEditionAllowed()) || e.isControlDown() || !(myObject.isSelected())) { |
4027 | - return; |
4028 | - } |
4029 | - |
4030 | - int rotation = 0; |
4031 | - if (e.getWheelRotation() < 0) { |
4032 | - rotation = -e.getWheelRotation() * 135; |
4033 | - } else { |
4034 | - rotation = e.getWheelRotation() * 45; |
4035 | - } |
4036 | - |
4037 | - CreateGui.getCurrentTab().getUndoManager().addNewEdit(((Transition) myObject).rotate(rotation)); |
4038 | - |
4039 | - } |
4040 | - |
4041 | /** |
4042 | * Creates the popup menu that the user will see when they right click on a |
4043 | * component |
4044 | |
4045 | === modified file 'src/pipe/gui/undo/AddArcPathPointEdit.java' |
4046 | --- src/pipe/gui/undo/AddArcPathPointEdit.java 2020-04-18 14:41:05 +0000 |
4047 | +++ src/pipe/gui/undo/AddArcPathPointEdit.java 2020-08-10 09:00:56 +0000 |
4048 | @@ -16,10 +16,10 @@ |
4049 | */ |
4050 | public class AddArcPathPointEdit extends Command { |
4051 | |
4052 | - ArcPath arcPath; |
4053 | - ArcPathPoint point; |
4054 | + final ArcPath arcPath; |
4055 | + final ArcPathPoint point; |
4056 | private final DataLayer guiModel; |
4057 | - Integer index; |
4058 | + final Integer index; |
4059 | |
4060 | /** Creates a new instance of AddArcPathPointEdit */ |
4061 | public AddArcPathPointEdit(Arc _arc, ArcPathPoint _point, DataLayer guiModel) { |
4062 | |
4063 | === modified file 'src/pipe/gui/undo/AddTemplateCommand.java' |
4064 | --- src/pipe/gui/undo/AddTemplateCommand.java 2020-04-18 14:41:05 +0000 |
4065 | +++ src/pipe/gui/undo/AddTemplateCommand.java 2020-08-10 09:00:56 +0000 |
4066 | @@ -5,7 +5,7 @@ |
4067 | import dk.aau.cs.gui.undo.Command; |
4068 | |
4069 | public class AddTemplateCommand extends Command { |
4070 | - protected Template template; |
4071 | + protected final Template template; |
4072 | protected final TemplateExplorer templateExplorer; |
4073 | private final int listIndex; |
4074 | |
4075 | |
4076 | === modified file 'src/pipe/gui/undo/AnnotationBorderEdit.java' |
4077 | --- src/pipe/gui/undo/AnnotationBorderEdit.java 2011-09-22 13:02:33 +0000 |
4078 | +++ src/pipe/gui/undo/AnnotationBorderEdit.java 2020-08-10 09:00:56 +0000 |
4079 | @@ -13,7 +13,7 @@ |
4080 | */ |
4081 | public class AnnotationBorderEdit extends Command { |
4082 | |
4083 | - Note note; |
4084 | + final Note note; |
4085 | |
4086 | /** Creates a new instance of placeRateEdit */ |
4087 | public AnnotationBorderEdit(Note _note) { |
4088 | |
4089 | === modified file 'src/pipe/gui/undo/AnnotationTextEdit.java' |
4090 | --- src/pipe/gui/undo/AnnotationTextEdit.java 2019-10-23 13:12:24 +0000 |
4091 | +++ src/pipe/gui/undo/AnnotationTextEdit.java 2020-08-10 09:00:56 +0000 |
4092 | @@ -13,9 +13,9 @@ |
4093 | */ |
4094 | public final class AnnotationTextEdit extends Command { |
4095 | |
4096 | - AnnotationNote annotationNote; |
4097 | - String oldText; |
4098 | - String newText; |
4099 | + final AnnotationNote annotationNote; |
4100 | + final String oldText; |
4101 | + final String newText; |
4102 | |
4103 | /** Creates a new instance of placeRateEdit */ |
4104 | public AnnotationTextEdit(AnnotationNote _annotationNote, String _oldText, |
4105 | |
4106 | === modified file 'src/pipe/gui/undo/ArcPathPointTypeEdit.java' |
4107 | --- src/pipe/gui/undo/ArcPathPointTypeEdit.java 2011-09-22 13:02:33 +0000 |
4108 | +++ src/pipe/gui/undo/ArcPathPointTypeEdit.java 2020-08-10 09:00:56 +0000 |
4109 | @@ -13,7 +13,7 @@ |
4110 | */ |
4111 | public class ArcPathPointTypeEdit extends Command { |
4112 | |
4113 | - ArcPathPoint arcPathPoint; |
4114 | + final ArcPathPoint arcPathPoint; |
4115 | |
4116 | /** Creates a new instance of placeWeightEdit */ |
4117 | public ArcPathPointTypeEdit(ArcPathPoint _arcPathPoint) { |
4118 | |
4119 | === modified file 'src/pipe/gui/undo/ArcTimeIntervalEdit.java' |
4120 | --- src/pipe/gui/undo/ArcTimeIntervalEdit.java 2020-04-18 14:41:05 +0000 |
4121 | +++ src/pipe/gui/undo/ArcTimeIntervalEdit.java 2020-08-10 09:00:56 +0000 |
4122 | @@ -7,10 +7,10 @@ |
4123 | |
4124 | public class ArcTimeIntervalEdit extends Command { |
4125 | private final TimedOutputArcComponent arc; |
4126 | - TimeInterval oldTimeInterval; |
4127 | - TimeInterval newTimeInterval; |
4128 | - Weight oldWeight; |
4129 | - Weight newWeight; |
4130 | + final TimeInterval oldTimeInterval; |
4131 | + final TimeInterval newTimeInterval; |
4132 | + final Weight oldWeight; |
4133 | + final Weight newWeight; |
4134 | |
4135 | public ArcTimeIntervalEdit(TimedOutputArcComponent arc, |
4136 | TimeInterval oldTimeInterval, TimeInterval newTimeInterval, Weight oldWeight, Weight newWeight) { |
4137 | |
4138 | === modified file 'src/pipe/gui/undo/TransitionRotationEdit.java' |
4139 | --- src/pipe/gui/undo/TransitionRotationEdit.java 2011-09-25 09:35:57 +0000 |
4140 | +++ src/pipe/gui/undo/TransitionRotationEdit.java 2020-08-10 09:00:56 +0000 |
4141 | @@ -12,8 +12,8 @@ |
4142 | */ |
4143 | public class TransitionRotationEdit extends Command { |
4144 | |
4145 | - Transition transition; |
4146 | - Integer angle; |
4147 | + final Transition transition; |
4148 | + final Integer angle; |
4149 | |
4150 | /** Creates a new instance of placePriorityEdit */ |
4151 | public TransitionRotationEdit(Transition _transition, Integer _angle) { |
4152 | |
4153 | === modified file 'src/pipe/gui/undo/TranslatePetriNetObjectEdit.java' |
4154 | --- src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-07-03 07:08:59 +0000 |
4155 | +++ src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-08-10 09:00:56 +0000 |
4156 | @@ -15,10 +15,10 @@ |
4157 | */ |
4158 | public class TranslatePetriNetObjectEdit extends Command { |
4159 | |
4160 | - PetriNetObject pnObject; |
4161 | - Integer transX; |
4162 | - Integer transY; |
4163 | - DrawingSurfaceImpl ds; |
4164 | + final PetriNetObject pnObject; |
4165 | + final Integer transX; |
4166 | + final Integer transY; |
4167 | + final DrawingSurfaceImpl ds; |
4168 | |
4169 | /** Creates a new instance of */ |
4170 | public TranslatePetriNetObjectEdit(PetriNetObject _pnObject, Integer _transX, Integer _transY, DrawingSurfaceImpl drawingSurface) { |
4171 | |
4172 | === modified file 'src/pipe/gui/undo/UndoManager.java' |
4173 | --- src/pipe/gui/undo/UndoManager.java 2020-06-29 06:47:48 +0000 |
4174 | +++ src/pipe/gui/undo/UndoManager.java 2020-08-10 09:00:56 +0000 |
4175 | @@ -4,12 +4,13 @@ |
4176 | package pipe.gui.undo; |
4177 | |
4178 | import java.util.ArrayList; |
4179 | -import java.util.Optional; |
4180 | + |
4181 | import dk.aau.cs.gui.undo.Command; |
4182 | +import net.tapaal.helpers.Reference.MutableReference; |
4183 | +import net.tapaal.helpers.Reference.Reference; |
4184 | import pipe.gui.CreateGui; |
4185 | import pipe.gui.GuiFrameActions; |
4186 | import pipe.gui.Pipe; |
4187 | -import pipe.gui.handler.PlaceTransitionObjectHandler; |
4188 | |
4189 | /** |
4190 | * Class to handle undo & redo functionality |
4191 | @@ -27,9 +28,9 @@ |
4192 | |
4193 | private final ArrayList<ArrayList<Command>> edits = new ArrayList<ArrayList<Command>>(UNDO_BUFFER_CAPACITY); |
4194 | |
4195 | - private Optional<GuiFrameActions> app = Optional.empty(); |
4196 | - public void setApp(GuiFrameActions app) { |
4197 | - this.app = Optional.ofNullable(app); |
4198 | + private Reference<GuiFrameActions> app = new MutableReference<>(); |
4199 | + public void setApp(Reference<GuiFrameActions> app) { |
4200 | + this.app = app; |
4201 | |
4202 | // Undo/Redo is enabled based on undo/redo manager |
4203 | setUndoRedoStatus(); |
4204 | |
4205 | === modified file 'src/pipe/gui/widgets/CTLQueryDialog.java' |
4206 | --- src/pipe/gui/widgets/CTLQueryDialog.java 2020-08-07 09:07:44 +0000 |
4207 | +++ src/pipe/gui/widgets/CTLQueryDialog.java 2020-08-10 09:00:56 +0000 |
4208 | @@ -218,19 +218,21 @@ |
4209 | private final HashMap<TimedArcPetriNet, DataLayer> guiModels; |
4210 | private QueryConstructionUndoManager undoManager; |
4211 | private UndoableEditSupport undoSupport; |
4212 | - private boolean isNetDegree2; |
4213 | - private boolean hasInhibitorArcs; |
4214 | - private InclusionPlaces inclusionPlaces; |
4215 | - private TabContent.TAPNLens lens; |
4216 | - |
4217 | - private String name_verifyTAPN = "TAPAAL: Continous Engine (verifytapn)"; |
4218 | - private String name_COMBI = "UPPAAL: Optimized Broadcast Reduction"; |
4219 | - private String name_OPTIMIZEDSTANDARD = "UPPAAL: Optimised Standard Reduction"; |
4220 | - private String name_STANDARD = "UPPAAL: Standard Reduction"; |
4221 | + |
4222 | + private final boolean isNetDegree2; |
4223 | + private final boolean hasInhibitorArcs; |
4224 | + private final InclusionPlaces inclusionPlaces; |
4225 | + private final TabContent.TAPNLens lens; |
4226 | + |
4227 | + |
4228 | + private final String name_verifyTAPN = "TAPAAL: Continous Engine (verifytapn)"; |
4229 | + private final String name_COMBI = "UPPAAL: Optimized Broadcast Reduction"; |
4230 | + private final String name_OPTIMIZEDSTANDARD = "UPPAAL: Optimised Standard Reduction"; |
4231 | + private final String name_STANDARD = "UPPAAL: Standard Reduction"; |
4232 | private String name_BROADCAST = "UPPAAL: Broadcast Reduction"; |
4233 | - private String name_BROADCASTDEG2 = "UPPAAL: Broadcast Degree 2 Reduction"; |
4234 | - private String name_DISCRETE = "TAPAAL: Discrete Engine (verifydtapn)"; |
4235 | - private String name_UNTIMED = "TAPAAL: Untimed Engine (verifypn)"; |
4236 | + private final String name_BROADCASTDEG2 = "UPPAAL: Broadcast Degree 2 Reduction"; |
4237 | + private final String name_DISCRETE = "TAPAAL: Discrete Engine (verifydtapn)"; |
4238 | + private final String name_UNTIMED = "TAPAAL: Untimed Engine (verifypn)"; |
4239 | |
4240 | private boolean userChangedAtomicPropSelection = true; |
4241 | |
4242 | @@ -2575,8 +2577,8 @@ |
4243 | |
4244 | public class QueryConstructionEdit extends AbstractUndoableEdit { |
4245 | |
4246 | - private TCTLAbstractProperty original; |
4247 | - private TCTLAbstractProperty replacement; |
4248 | + private final TCTLAbstractProperty original; |
4249 | + private final TCTLAbstractProperty replacement; |
4250 | |
4251 | public TCTLAbstractProperty getOriginal() { |
4252 | return original; |
4253 | |
4254 | === modified file 'src/pipe/gui/widgets/ConstantsDialogPanel.java' |
4255 | --- src/pipe/gui/widgets/ConstantsDialogPanel.java 2020-04-18 12:27:02 +0000 |
4256 | +++ src/pipe/gui/widgets/ConstantsDialogPanel.java 2020-08-10 09:00:56 +0000 |
4257 | @@ -5,7 +5,6 @@ |
4258 | import java.awt.GridBagLayout; |
4259 | import java.awt.Insets; |
4260 | import java.awt.event.KeyEvent; |
4261 | -import java.io.IOException; |
4262 | import java.util.regex.Pattern; |
4263 | |
4264 | import javax.swing.JButton; |
4265 | @@ -23,68 +22,48 @@ |
4266 | import dk.aau.cs.model.tapn.Constant; |
4267 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
4268 | |
4269 | -/* |
4270 | - * LeftConstantsPane.java |
4271 | - * |
4272 | - * Created on 08-10-2009, 13:51:42 |
4273 | - */ |
4274 | - |
4275 | -/** |
4276 | - * |
4277 | - * @author Morten Jacobsen |
4278 | - */ |
4279 | public class ConstantsDialogPanel extends javax.swing.JPanel { |
4280 | |
4281 | - private JRootPane rootPane; |
4282 | - private TimedArcPetriNetNetwork model; |
4283 | + private final TimedArcPetriNetNetwork model; |
4284 | private int lowerBound; |
4285 | private int upperBound; |
4286 | private int initialValue = 0; |
4287 | private EscapableDialog dialog; |
4288 | |
4289 | - JPanel nameTextFieldPane; |
4290 | - JTextField nameTextField; |
4291 | + JTextField nameTextField; |
4292 | Dimension size; |
4293 | - JLabel nameLabel; |
4294 | - JPanel valueSpinnerPane; |
4295 | - JLabel valueLabel; |
4296 | + JLabel nameLabel; |
4297 | + JLabel valueLabel; |
4298 | CustomJSpinner valueSpinner; |
4299 | JPanel container; |
4300 | JPanel buttonContainer; |
4301 | JButton okButton; |
4302 | JButton cancelButton; |
4303 | |
4304 | - private String oldName; |
4305 | - |
4306 | - public ConstantsDialogPanel() throws IOException { |
4307 | - initComponents(); |
4308 | - } |
4309 | - |
4310 | - public ConstantsDialogPanel(JRootPane pane, TimedArcPetriNetNetwork model) throws IOException { |
4311 | - initComponents(); |
4312 | - rootPane = pane; |
4313 | - this.model = model; |
4314 | - oldName = ""; |
4315 | - nameTextField.setText(oldName); |
4316 | - } |
4317 | - |
4318 | - public ConstantsDialogPanel(JRootPane pane, TimedArcPetriNetNetwork model, |
4319 | - Constant constant) throws IOException { |
4320 | - rootPane = pane; |
4321 | - this.model = model; |
4322 | - |
4323 | - initialValue = constant.value(); |
4324 | - initComponents(); |
4325 | - |
4326 | - oldName = constant.name(); |
4327 | - lowerBound = constant.lowerBound(); |
4328 | - upperBound = constant.upperBound(); |
4329 | + private final String oldName; |
4330 | + |
4331 | + public ConstantsDialogPanel(TimedArcPetriNetNetwork model) { |
4332 | + this(model, null); |
4333 | + } |
4334 | + |
4335 | + public ConstantsDialogPanel(TimedArcPetriNetNetwork model, Constant constant) { |
4336 | + this.model = model; |
4337 | + |
4338 | + if (constant != null) { |
4339 | + initialValue = constant.value(); |
4340 | + oldName = constant.name(); |
4341 | + lowerBound = constant.lowerBound(); |
4342 | + upperBound = constant.upperBound(); |
4343 | + } else { |
4344 | + oldName = ""; |
4345 | + } |
4346 | + initComponents(); |
4347 | + |
4348 | nameTextField.setText(oldName); |
4349 | } |
4350 | |
4351 | public void showDialog() { |
4352 | - dialog = new EscapableDialog(CreateGui.getApp(), |
4353 | - "Edit Constant", true); |
4354 | + dialog = new EscapableDialog(CreateGui.getApp(), "Edit Constant", true); |
4355 | dialog.add(container); |
4356 | dialog.getRootPane().setDefaultButton(okButton); |
4357 | dialog.setResizable(false); |
4358 | @@ -93,7 +72,7 @@ |
4359 | dialog.setVisible(true); |
4360 | } |
4361 | |
4362 | - private void initComponents() throws IOException { |
4363 | + private void initComponents() { |
4364 | container = new JPanel(); |
4365 | container.setLayout(new GridBagLayout()); |
4366 | size = new Dimension(330, 25); |
4367 | |
4368 | === modified file 'src/pipe/gui/widgets/ConstantsPane.java' |
4369 | --- src/pipe/gui/widgets/ConstantsPane.java 2020-08-04 08:07:21 +0000 |
4370 | +++ src/pipe/gui/widgets/ConstantsPane.java 2020-08-10 09:00:56 +0000 |
4371 | @@ -18,7 +18,6 @@ |
4372 | |
4373 | |
4374 | import javax.swing.BorderFactory; |
4375 | -import javax.swing.ImageIcon; |
4376 | import javax.swing.JButton; |
4377 | import javax.swing.JList; |
4378 | import javax.swing.JOptionPane; |
4379 | @@ -51,7 +50,7 @@ |
4380 | private JScrollPane constantsScroller; |
4381 | private final JPanel buttonsPanel; |
4382 | |
4383 | - private final JList constantsList; |
4384 | + private final JList<Constant> constantsList; |
4385 | private final ConstantsListModel listModel; |
4386 | private JButton editBtn; |
4387 | private JButton removeBtn; |
4388 | @@ -95,7 +94,7 @@ |
4389 | |
4390 | }); |
4391 | |
4392 | - constantsList = new NonsearchableJList(listModel); |
4393 | + constantsList = new NonsearchableJList<>(listModel); |
4394 | constantsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
4395 | constantsList.addListSelectionListener(new ListSelectionListener() { |
4396 | public void valueChanged(ListSelectionEvent e) { |
4397 | @@ -141,7 +140,7 @@ |
4398 | highlightConstant(index); |
4399 | |
4400 | if (arg0.getButton() == MouseEvent.BUTTON1 && arg0.getClickCount() == 2) { |
4401 | - showEditConstantDialog(c,index); |
4402 | + showEditConstantDialog(c); |
4403 | } |
4404 | } |
4405 | } |
4406 | @@ -295,7 +294,7 @@ |
4407 | editBtn.setToolTipText(toolTipEditConstant); |
4408 | editBtn.addActionListener(e -> { |
4409 | Constant c = (Constant) constantsList.getSelectedValue(); |
4410 | - showEditConstantDialog(c,constantsList.getSelectedIndex()); |
4411 | + showEditConstantDialog(c); |
4412 | }); |
4413 | GridBagConstraints gbc = new GridBagConstraints(); |
4414 | gbc.gridx = 0; |
4415 | @@ -407,44 +406,9 @@ |
4416 | constantsPanel.add(sortButton,gbc); |
4417 | } |
4418 | |
4419 | - private void showEditConstantDialog(Constant constant) { |
4420 | - ConstantsDialogPanel panel = null; |
4421 | - if (constant != null) |
4422 | - try { |
4423 | - panel = new ConstantsDialogPanel(new JRootPane(), |
4424 | - parent.network(), constant); |
4425 | - } catch (IOException e) { |
4426 | - // TODO Auto-generated catch block |
4427 | - e.printStackTrace(); |
4428 | - } |
4429 | - else |
4430 | - try { |
4431 | - panel = new ConstantsDialogPanel(new JRootPane(), |
4432 | - parent.network()); |
4433 | - } catch (IOException e) { |
4434 | - // TODO Auto-generated catch block |
4435 | - e.printStackTrace(); |
4436 | - } |
4437 | - panel.showDialog(); |
4438 | - showConstants(); |
4439 | - } |
4440 | + private void showEditConstantDialog(Constant constant) { |
4441 | + ConstantsDialogPanel panel = new ConstantsDialogPanel(parent.network(), constant); |
4442 | |
4443 | - private void showEditConstantDialog(Constant constant, int selectedIndex) { |
4444 | - ConstantsDialogPanel panel = null; |
4445 | - if (constant != null) |
4446 | - try { |
4447 | - panel = new ConstantsDialogPanel(new JRootPane(), |
4448 | - parent.network(), constant); |
4449 | - } catch (IOException e) { |
4450 | - e.printStackTrace(); |
4451 | - } |
4452 | - else |
4453 | - try { |
4454 | - panel = new ConstantsDialogPanel(new JRootPane(), |
4455 | - parent.network()); |
4456 | - } catch (IOException e) { |
4457 | - e.printStackTrace(); |
4458 | - } |
4459 | panel.showDialog(); |
4460 | showConstants(); |
4461 | } |
4462 | @@ -457,8 +421,9 @@ |
4463 | "You cannot remove a constant that is used in the net.\nRemove all references " |
4464 | + "to the constant in the net and try again.", |
4465 | "Constant in use", JOptionPane.ERROR_MESSAGE); |
4466 | - } else |
4467 | - parent.getUndoManager().addNewEdit(edit); |
4468 | + } else { |
4469 | + parent.getUndoManager().addNewEdit(edit); |
4470 | + } |
4471 | |
4472 | //showConstants(); |
4473 | } |
4474 | @@ -485,7 +450,7 @@ |
4475 | } |
4476 | |
4477 | @Override |
4478 | - public JList getJList() { |
4479 | + public JList<Constant> getJList() { |
4480 | return constantsList; |
4481 | } |
4482 | } |
4483 | |
4484 | === modified file 'src/pipe/gui/widgets/EngineDialogPanel.java' |
4485 | --- src/pipe/gui/widgets/EngineDialogPanel.java 2020-07-13 13:58:47 +0000 |
4486 | +++ src/pipe/gui/widgets/EngineDialogPanel.java 2020-08-10 09:00:56 +0000 |
4487 | @@ -33,23 +33,23 @@ |
4488 | |
4489 | JButton closeButton; |
4490 | |
4491 | - JLabel tapaalLocationLabel = new JLabel("Located: "); |
4492 | - JLabel tapaalVersionLabel = new JLabel("Version: "); |
4493 | - JLabel dtapaalLocationLabel = new JLabel("Located: "); |
4494 | - JLabel dtapaalVersionLabel = new JLabel("Version: "); |
4495 | - JLabel untimedLocationLabel = new JLabel("Located: "); |
4496 | - JLabel untimedVersionLabel = new JLabel("Version: "); |
4497 | - JLabel uppaalLocationLabel = new JLabel("Located: "); |
4498 | - JLabel uppaalVersionLabel = new JLabel("Version: "); |
4499 | + final JLabel tapaalLocationLabel = new JLabel("Located: "); |
4500 | + final JLabel tapaalVersionLabel = new JLabel("Version: "); |
4501 | + final JLabel dtapaalLocationLabel = new JLabel("Located: "); |
4502 | + final JLabel dtapaalVersionLabel = new JLabel("Version: "); |
4503 | + final JLabel untimedLocationLabel = new JLabel("Located: "); |
4504 | + final JLabel untimedVersionLabel = new JLabel("Version: "); |
4505 | + final JLabel uppaalLocationLabel = new JLabel("Located: "); |
4506 | + final JLabel uppaalVersionLabel = new JLabel("Version: "); |
4507 | |
4508 | - JLabel tapaalLocationLabelVal = new JLabel("Not setup"); |
4509 | - JLabel tapaalVersionLabelVal = new JLabel("N/A"); |
4510 | - JLabel dtapaalLocationLabelVal = new JLabel("Not setup"); |
4511 | - JLabel dtapaalVersionLabelVal = new JLabel("N/A"); |
4512 | - JLabel untimedLocationLabelVal = new JLabel("Not setup"); |
4513 | - JLabel untimedVersionLabelVal = new JLabel("N/A"); |
4514 | - JLabel uppaalLocationLabelVal = new JLabel("Not setup"); |
4515 | - JLabel uppaalVersionLabelVal = new JLabel("N/A"); |
4516 | + final JLabel tapaalLocationLabelVal = new JLabel("Not setup"); |
4517 | + final JLabel tapaalVersionLabelVal = new JLabel("N/A"); |
4518 | + final JLabel dtapaalLocationLabelVal = new JLabel("Not setup"); |
4519 | + final JLabel dtapaalVersionLabelVal = new JLabel("N/A"); |
4520 | + final JLabel untimedLocationLabelVal = new JLabel("Not setup"); |
4521 | + final JLabel untimedVersionLabelVal = new JLabel("N/A"); |
4522 | + final JLabel uppaalLocationLabelVal = new JLabel("Not setup"); |
4523 | + final JLabel uppaalVersionLabelVal = new JLabel("N/A"); |
4524 | |
4525 | private final Dimension minimumSize = new Dimension(320,1); |
4526 | private final Insets panelInsets = new Insets(5, 5, 5, 5); |
4527 | |
4528 | === modified file 'src/pipe/gui/widgets/GuardDialogue.java' |
4529 | --- src/pipe/gui/widgets/GuardDialogue.java 2020-07-13 13:58:47 +0000 |
4530 | +++ src/pipe/gui/widgets/GuardDialogue.java 2020-08-10 09:00:56 +0000 |
4531 | @@ -61,11 +61,11 @@ |
4532 | private JComboBox<String> rightDelimiter; |
4533 | |
4534 | private JCheckBox leftUseConstant; |
4535 | - private WidthAdjustingComboBox leftConstantsComboBox; |
4536 | + private WidthAdjustingComboBox<String> leftConstantsComboBox; |
4537 | private JCheckBox rightUseConstant; |
4538 | - private WidthAdjustingComboBox rightConstantsComboBox; |
4539 | + private WidthAdjustingComboBox<String> rightConstantsComboBox; |
4540 | private JCheckBox weightUseConstant; |
4541 | - private WidthAdjustingComboBox weightConstantsComboBox; |
4542 | + private WidthAdjustingComboBox<String> weightConstantsComboBox; |
4543 | |
4544 | private final int maxNumberOfPlacesToShowAtOnce = 20; |
4545 | |
4546 | @@ -261,8 +261,8 @@ |
4547 | |
4548 | Arrays.sort(constantArray, String.CASE_INSENSITIVE_ORDER); |
4549 | |
4550 | - weightConstantsComboBox = new WidthAdjustingComboBox(maxNumberOfPlacesToShowAtOnce); |
4551 | - weightConstantsComboBox.setModel(new DefaultComboBoxModel(constantArray)); |
4552 | + weightConstantsComboBox = new WidthAdjustingComboBox<>(maxNumberOfPlacesToShowAtOnce); |
4553 | + weightConstantsComboBox.setModel(new DefaultComboBoxModel<>(constantArray)); |
4554 | weightConstantsComboBox.setMaximumRowCount(20); |
4555 | weightConstantsComboBox.setVisible(false); |
4556 | weightConstantsComboBox.setPreferredSize(intervalBoxDims); |
4557 | @@ -320,22 +320,22 @@ |
4558 | guardEditPanel.add(label, gridBagConstraints); |
4559 | |
4560 | String[] left = { "[", "(" }; |
4561 | - leftDelimiter = new JComboBox(); |
4562 | + leftDelimiter = new JComboBox<>(); |
4563 | Dimension dims = new Dimension(55, 25); |
4564 | leftDelimiter.setPreferredSize(dims); |
4565 | leftDelimiter.setMinimumSize(dims); |
4566 | leftDelimiter.setMaximumSize(dims); |
4567 | - leftDelimiter.setModel(new DefaultComboBoxModel(left)); |
4568 | + leftDelimiter.setModel(new DefaultComboBoxModel<>(left)); |
4569 | gridBagConstraints.gridx = 1; |
4570 | gridBagConstraints.gridy = 1; |
4571 | guardEditPanel.add(leftDelimiter, gridBagConstraints); |
4572 | |
4573 | String[] right = { "]", ")" }; |
4574 | - rightDelimiter = new JComboBox(); |
4575 | + rightDelimiter = new JComboBox<>(); |
4576 | rightDelimiter.setPreferredSize(dims); |
4577 | rightDelimiter.setMinimumSize(dims); |
4578 | rightDelimiter.setMaximumSize(dims); |
4579 | - rightDelimiter.setModel(new DefaultComboBoxModel(right)); |
4580 | + rightDelimiter.setModel(new DefaultComboBoxModel<>(right)); |
4581 | gridBagConstraints.gridx = 5; |
4582 | gridBagConstraints.gridy = 1; |
4583 | guardEditPanel.add(rightDelimiter, gridBagConstraints); |
4584 | @@ -417,8 +417,8 @@ |
4585 | guardEditPanel.add(leftUseConstant, gridBagConstraints); |
4586 | |
4587 | |
4588 | - leftConstantsComboBox = new WidthAdjustingComboBox(maxNumberOfPlacesToShowAtOnce); |
4589 | - leftConstantsComboBox.setModel(new DefaultComboBoxModel(constantArray)); |
4590 | + leftConstantsComboBox = new WidthAdjustingComboBox<>(maxNumberOfPlacesToShowAtOnce); |
4591 | + leftConstantsComboBox.setModel(new DefaultComboBoxModel<>(constantArray)); |
4592 | // leftConstantsComboBox = new JComboBox(constants.toArray()); |
4593 | leftConstantsComboBox.setMaximumRowCount(20); |
4594 | leftConstantsComboBox.setVisible(false); |
4595 | @@ -450,8 +450,8 @@ |
4596 | gridBagConstraints.gridy = 0; |
4597 | guardEditPanel.add(rightUseConstant, gridBagConstraints); |
4598 | |
4599 | - rightConstantsComboBox = new WidthAdjustingComboBox(maxNumberOfPlacesToShowAtOnce); |
4600 | - rightConstantsComboBox.setModel(new DefaultComboBoxModel(constantArray)); |
4601 | + rightConstantsComboBox = new WidthAdjustingComboBox<>(maxNumberOfPlacesToShowAtOnce); |
4602 | + rightConstantsComboBox.setModel(new DefaultComboBoxModel<>(constantArray)); |
4603 | rightConstantsComboBox.setMaximumRowCount(20); |
4604 | rightConstantsComboBox.setVisible(false); |
4605 | // rightConstantsComboBox.setMaximumSize(intervalBoxDims); |
4606 | |
4607 | === modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java' |
4608 | --- src/pipe/gui/widgets/PlaceEditorPanel.java 2020-07-13 13:58:47 +0000 |
4609 | +++ src/pipe/gui/widgets/PlaceEditorPanel.java 2020-08-10 09:00:56 +0000 |
4610 | @@ -23,6 +23,7 @@ |
4611 | import javax.swing.event.ChangeListener; |
4612 | |
4613 | import net.tapaal.swinghelpers.CustomJSpinner; |
4614 | +import net.tapaal.swinghelpers.GridBagHelper; |
4615 | import net.tapaal.swinghelpers.WidthAdjustingComboBox; |
4616 | import pipe.dataLayer.Template; |
4617 | import pipe.gui.CreateGui; |
4618 | @@ -51,13 +52,16 @@ |
4619 | import dk.aau.cs.model.tapn.TransportArc; |
4620 | import dk.aau.cs.util.RequireException; |
4621 | |
4622 | +import static net.tapaal.swinghelpers.GridBagHelper.Anchor.*; |
4623 | +import static net.tapaal.swinghelpers.GridBagHelper.Fill.HORIZONTAL; |
4624 | + |
4625 | public class PlaceEditorPanel extends javax.swing.JPanel { |
4626 | |
4627 | private final JRootPane rootPane; |
4628 | |
4629 | private JCheckBox sharedCheckBox; |
4630 | private JCheckBox makeNewSharedCheckBox; |
4631 | - private WidthAdjustingComboBox sharedPlacesComboBox; |
4632 | + private WidthAdjustingComboBox<TimedPlace> sharedPlacesComboBox; |
4633 | |
4634 | private final TimedPlaceComponent place; |
4635 | private final Context context; |
4636 | @@ -78,30 +82,19 @@ |
4637 | setLayout(new java.awt.GridBagLayout()); |
4638 | |
4639 | initBasicPropertiesPanel(); |
4640 | - GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); |
4641 | - gridBagConstraints.gridx = 0; |
4642 | - gridBagConstraints.gridy = 0; |
4643 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4644 | - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
4645 | - gridBagConstraints.insets = new Insets(5, 8, 0, 8); |
4646 | + GridBagConstraints gridBagConstraints = GridBagHelper.as(0,0, WEST, HORIZONTAL, new Insets(5, 8, 0, 8)); |
4647 | add(basicPropertiesPanel, gridBagConstraints); |
4648 | |
4649 | initTimeInvariantPanel(); |
4650 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4651 | - gridBagConstraints.gridx = 0; |
4652 | - gridBagConstraints.gridy = 1; |
4653 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4654 | - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
4655 | - gridBagConstraints.insets = new Insets(0, 8, 0, 8); |
4656 | + |
4657 | + gridBagConstraints = GridBagHelper.as(0,1, WEST, HORIZONTAL, new Insets(0, 8, 0, 8)); |
4658 | add(timeInvariantPanel, gridBagConstraints); |
4659 | |
4660 | initButtonPanel(); |
4661 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4662 | - gridBagConstraints.gridx = 0; |
4663 | - gridBagConstraints.gridy = 2; |
4664 | + |
4665 | + gridBagConstraints = GridBagHelper.as(0,2, new Insets(0, 8, 5, 8)); |
4666 | gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
4667 | - // gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
4668 | - gridBagConstraints.insets = new Insets(0, 8, 5, 8); |
4669 | + //gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
4670 | add(buttonPanel, gridBagConstraints); |
4671 | } |
4672 | |
4673 | @@ -130,21 +123,14 @@ |
4674 | cancelButton.setPreferredSize(new java.awt.Dimension(100, 25)); |
4675 | cancelButton.addActionListener(evt -> exit()); |
4676 | |
4677 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4678 | - gridBagConstraints.gridx = 0; |
4679 | - gridBagConstraints.gridy = 0; |
4680 | + gridBagConstraints = GridBagHelper.as(0,0,EAST, new Insets(5, 5, 5, 5)); |
4681 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; |
4682 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
4683 | - gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
4684 | + |
4685 | buttonPanel.add(cancelButton, gridBagConstraints); |
4686 | |
4687 | |
4688 | |
4689 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4690 | - gridBagConstraints.gridx = 1; |
4691 | - gridBagConstraints.gridy = 0; |
4692 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4693 | - gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
4694 | + gridBagConstraints = GridBagHelper.as(1,0, WEST, new Insets(5, 5, 5, 5)); |
4695 | buttonPanel.add(okButton, gridBagConstraints); |
4696 | |
4697 | setupInitialState(); |
4698 | @@ -166,7 +152,7 @@ |
4699 | } |
4700 | |
4701 | sharedPlaces.sort((o1, o2) -> o1.name().compareToIgnoreCase(o2.name())); |
4702 | - sharedPlacesComboBox.setModel(new DefaultComboBoxModel(sharedPlaces)); |
4703 | + sharedPlacesComboBox.setModel(new DefaultComboBoxModel<>(sharedPlaces)); |
4704 | if(place.underlyingPlace().isShared()) { |
4705 | |
4706 | sharedPlacesComboBox.setSelectedItem(place.underlyingPlace()); |
4707 | @@ -224,11 +210,7 @@ |
4708 | } |
4709 | }); |
4710 | |
4711 | - GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); |
4712 | - gridBagConstraints.gridx = 2; |
4713 | - gridBagConstraints.gridy = 1; |
4714 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4715 | - gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3); |
4716 | + GridBagConstraints gridBagConstraints = GridBagHelper.as(2,1, WEST, new Insets(0, 3, 3, 3)); |
4717 | basicPropertiesPanel.add(sharedCheckBox, gridBagConstraints); |
4718 | |
4719 | makeSharedButton = new javax.swing.JButton(); |
4720 | @@ -250,19 +232,11 @@ |
4721 | makeNewShared = false; |
4722 | }); |
4723 | |
4724 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4725 | - gridBagConstraints.gridx = 3; |
4726 | - gridBagConstraints.gridy = 1; |
4727 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4728 | - gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
4729 | + gridBagConstraints = GridBagHelper.as(3,1, WEST, new Insets(5, 5, 5, 5)); |
4730 | basicPropertiesPanel.add(makeSharedButton, gridBagConstraints); |
4731 | |
4732 | nameLabel = new javax.swing.JLabel("Name:"); |
4733 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4734 | - gridBagConstraints.gridx = 0; |
4735 | - gridBagConstraints.gridy = 1; |
4736 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
4737 | - gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
4738 | + gridBagConstraints = GridBagHelper.as(0,1, EAST, new Insets(3, 3, 3, 3)); |
4739 | basicPropertiesPanel.add(nameLabel, gridBagConstraints); |
4740 | |
4741 | nameTextField = new javax.swing.JTextField(); |
4742 | @@ -281,32 +255,18 @@ |
4743 | }); |
4744 | |
4745 | markingLabel = new javax.swing.JLabel("Marking:"); |
4746 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4747 | - gridBagConstraints.gridx = 0; |
4748 | - gridBagConstraints.gridy = 2; |
4749 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
4750 | - gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
4751 | + gridBagConstraints = GridBagHelper.as(0,2, EAST, new Insets(3, 3, 3, 3)); |
4752 | basicPropertiesPanel.add(markingLabel, gridBagConstraints); |
4753 | |
4754 | - // markingSpinner = new javax.swing.JSpinner(); |
4755 | - // markingSpinner.setModel(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); |
4756 | - // markingSpinner.setPreferredSize(new Dimension(75,27)); |
4757 | markingSpinner = new CustomJSpinner(0, okButton); |
4758 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4759 | - gridBagConstraints.gridx = 1; |
4760 | - gridBagConstraints.gridy = 2; |
4761 | - gridBagConstraints.anchor = GridBagConstraints.WEST; |
4762 | - gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
4763 | + gridBagConstraints = GridBagHelper.as(1,2, WEST, new Insets(3, 3, 3, 3)); |
4764 | basicPropertiesPanel.add(markingSpinner, gridBagConstraints); |
4765 | |
4766 | attributesCheckBox = new javax.swing.JCheckBox("Show place name"); |
4767 | attributesCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
4768 | - attributesCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
4769 | - gridBagConstraints = new java.awt.GridBagConstraints(); |
4770 | - gridBagConstraints.gridx = 1; |
4771 | - gridBagConstraints.gridy = 3; |
4772 | - gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
4773 | - gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
4774 | + attributesCheckBox.setMargin(new Insets(0, 0, 0, 0)); |
4775 | + |
4776 | + gridBagConstraints = GridBagHelper.as(1,3,WEST, new Insets(3, 3, 3, 3)); |
4777 | basicPropertiesPanel.add(attributesCheckBox, gridBagConstraints); |
4778 | } |
4779 | |
4780 | @@ -336,8 +296,8 @@ |
4781 | timeInvariantPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Age Invariant")); |
4782 | |
4783 | invariantGroup = new JPanel(new GridBagLayout()); |
4784 | - invRelationNormal = new JComboBox(new String[] { "<=", "<" }); |
4785 | - invRelationConstant = new JComboBox(new String[] { "<=", "<" }); |
4786 | + invRelationNormal = new JComboBox<>(new String[] { "<=", "<" }); |
4787 | + invRelationConstant = new JComboBox<>(new String[] { "<=", "<" }); |
4788 | //invariantSpinner = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); |
4789 | invariantSpinner = new CustomJSpinner(0, okButton); |
4790 | invariantSpinner.addChangeListener(e -> { |
4791 | @@ -351,28 +311,13 @@ |
4792 | } |
4793 | }); |
4794 | |
4795 | - GridBagConstraints gbc = new GridBagConstraints(); |
4796 | - gbc.gridx = 1; |
4797 | - gbc.gridy = 0; |
4798 | - gbc.insets = new Insets(3, 3, 3, 3); |
4799 | - gbc.fill = GridBagConstraints.HORIZONTAL; |
4800 | + GridBagConstraints gbc = GridBagHelper.as(1,0, HORIZONTAL, new Insets(3, 3, 3, 3)); |
4801 | invariantGroup.add(invRelationNormal, gbc); |
4802 | |
4803 | - gbc = new GridBagConstraints(); |
4804 | - gbc.gridx = 1; |
4805 | - gbc.gridy = 1; |
4806 | - gbc.insets = new Insets(3, 3, 3, 3); |
4807 | - gbc.fill = GridBagConstraints.HORIZONTAL; |
4808 | - invariantGroup.add(invRelationConstant, gbc); |
4809 | - |
4810 | - // invariantSpinner.setMaximumSize(new Dimension(100, 30)); |
4811 | - // invariantSpinner.setMinimumSize(new Dimension(230, 30)); |
4812 | - //invariantSpinner.setPreferredSize(new Dimension(230, 30)); |
4813 | - |
4814 | - gbc = new GridBagConstraints(); |
4815 | - gbc.gridx = 2; |
4816 | - gbc.gridy = 0; |
4817 | - gbc.insets = new Insets(3, 3, 3, 3); |
4818 | + gbc = GridBagHelper.as(1,1, HORIZONTAL, new Insets(3, 3, 3, 3)); |
4819 | + invariantGroup.add(invRelationConstant, gbc); |
4820 | + |
4821 | + gbc = GridBagHelper.as(2,0, new Insets(3, 3, 3, 3)); |
4822 | invariantGroup.add(invariantSpinner, gbc); |
4823 | |
4824 | invariantInf = new JCheckBox("inf"); |
4825 | @@ -386,29 +331,27 @@ |
4826 | invariantSpinner.setEnabled(true); |
4827 | invRelationNormal.setSelectedItem("<="); |
4828 | if ((Integer) invariantSpinner.getValue() < 1) { |
4829 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<=" })); |
4830 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<=" })); |
4831 | } else { |
4832 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<=", "<" })); |
4833 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<=", "<" })); |
4834 | } |
4835 | } else { |
4836 | invRelationNormal.setEnabled(false); |
4837 | invariantSpinner.setEnabled(false); |
4838 | invRelationNormal.setSelectedItem("<"); |
4839 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<" })); |
4840 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<" })); |
4841 | } |
4842 | |
4843 | }); |
4844 | - gbc = new GridBagConstraints(); |
4845 | - gbc.gridx = 3; |
4846 | - gbc.gridy = 0; |
4847 | + gbc = GridBagHelper.as(3,0); |
4848 | invariantGroup.add(invariantInf, gbc); |
4849 | |
4850 | Set<String> constants = context.network().getConstantNames(); |
4851 | String[] constantArray = constants.toArray(new String[constants.size()]); |
4852 | Arrays.sort(constantArray, String.CASE_INSENSITIVE_ORDER); |
4853 | |
4854 | - invConstantsComboBox = new WidthAdjustingComboBox(maxNumberOfPlacesToShowAtOnce); |
4855 | - invConstantsComboBox.setModel(new DefaultComboBoxModel(constantArray)); |
4856 | + invConstantsComboBox = new WidthAdjustingComboBox<>(maxNumberOfPlacesToShowAtOnce); |
4857 | + invConstantsComboBox.setModel(new DefaultComboBoxModel<>(constantArray)); |
4858 | // invConstantsComboBox = new JComboBox(constants.toArray()); |
4859 | invConstantsComboBox.setMaximumRowCount(20); |
4860 | // invConstantsComboBox.setMinimumSize(new Dimension(100, 30)); |
4861 | @@ -419,10 +362,7 @@ |
4862 | } |
4863 | }); |
4864 | |
4865 | - gbc = new GridBagConstraints(); |
4866 | - gbc.gridx = 2; |
4867 | - gbc.gridy = 1; |
4868 | - gbc.anchor = GridBagConstraints.WEST; |
4869 | + gbc = GridBagHelper.as(2,1, WEST); |
4870 | invariantGroup.add(invConstantsComboBox, gbc); |
4871 | |
4872 | normalInvRadioButton = new JRadioButton("Normal"); |
4873 | @@ -443,16 +383,10 @@ |
4874 | btnGroup.add(normalInvRadioButton); |
4875 | btnGroup.add(constantInvRadioButton); |
4876 | |
4877 | - gbc = new GridBagConstraints(); |
4878 | - gbc.gridx = 0; |
4879 | - gbc.gridy = 0; |
4880 | - gbc.anchor = GridBagConstraints.WEST; |
4881 | + gbc = GridBagHelper.as(0,0, WEST); |
4882 | invariantGroup.add(normalInvRadioButton, gbc); |
4883 | |
4884 | - gbc = new GridBagConstraints(); |
4885 | - gbc.gridx = 0; |
4886 | - gbc.gridy = 1; |
4887 | - gbc.anchor = GridBagConstraints.WEST; |
4888 | + gbc = GridBagHelper.as(0,1, WEST); |
4889 | invariantGroup.add(constantInvRadioButton, gbc); |
4890 | |
4891 | TimeInvariant invariantToSet = place.getInvariant(); |
4892 | @@ -465,7 +399,7 @@ |
4893 | |
4894 | if (invariantToSet.upperBound() instanceof InfBound) { |
4895 | invariantSpinner.setEnabled(false); |
4896 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<" })); |
4897 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<" })); |
4898 | invariantInf.setSelected(true); |
4899 | invRelationNormal.setSelectedItem("<"); |
4900 | } |
4901 | @@ -481,9 +415,9 @@ |
4902 | normalInvRadioButton.setSelected(true); |
4903 | if (invariantToSet.upperBound() instanceof IntBound) { |
4904 | if ((Integer) invariantSpinner.getValue() < 1) { |
4905 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<=" })); |
4906 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<=" })); |
4907 | } else { |
4908 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<=", "<" })); |
4909 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<=", "<" })); |
4910 | } |
4911 | invariantSpinner.setValue(invariantToSet.upperBound().value()); |
4912 | invariantSpinner.setEnabled(true); |
4913 | @@ -492,12 +426,7 @@ |
4914 | } |
4915 | } |
4916 | |
4917 | - GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); |
4918 | - gridBagConstraints.gridx = 1; |
4919 | - gridBagConstraints.gridy = 4; |
4920 | - gridBagConstraints.gridwidth = 2; |
4921 | - gridBagConstraints.anchor = GridBagConstraints.WEST; |
4922 | - gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
4923 | + GridBagConstraints gridBagConstraints = GridBagHelper.as(1,4,2, WEST, new Insets(3, 3, 3, 3)); |
4924 | timeInvariantPanel.add(invariantGroup, gridBagConstraints); |
4925 | } |
4926 | |
4927 | @@ -506,9 +435,9 @@ |
4928 | |
4929 | String selected = invRelationConstant.getSelectedItem().toString(); |
4930 | if (value == 0) { |
4931 | - invRelationConstant.setModel(new DefaultComboBoxModel(new String[] { "<=" })); |
4932 | + invRelationConstant.setModel(new DefaultComboBoxModel<>(new String[] { "<=" })); |
4933 | } else { |
4934 | - invRelationConstant.setModel(new DefaultComboBoxModel(new String[] { "<=", "<" })); |
4935 | + invRelationConstant.setModel(new DefaultComboBoxModel<>(new String[] { "<=", "<" })); |
4936 | } |
4937 | invRelationConstant.setSelectedItem(selected); |
4938 | } |
4939 | @@ -524,7 +453,7 @@ |
4940 | invariantInf.setEnabled(true); |
4941 | invariantSpinner.setValue(0); |
4942 | invariantInf.setSelected(true); |
4943 | - invRelationNormal.setModel(new DefaultComboBoxModel(new String[] { "<" })); |
4944 | + invRelationNormal.setModel(new DefaultComboBoxModel<>(new String[] { "<" })); |
4945 | } |
4946 | |
4947 | protected void disableInvariantComponents() { |
4948 | @@ -535,35 +464,20 @@ |
4949 | invariantInf.setEnabled(false); |
4950 | } |
4951 | |
4952 | - ChangeListener changeListener = new javax.swing.event.ChangeListener() { |
4953 | - public void stateChanged(javax.swing.event.ChangeEvent evt) { |
4954 | - JSpinner spinner = (JSpinner) evt.getSource(); |
4955 | - JSpinner.NumberEditor numberEditor = ((JSpinner.NumberEditor) spinner.getEditor()); |
4956 | - numberEditor.getTextField().setBackground(new Color(255, 255, 255)); |
4957 | - spinner.removeChangeListener(this); |
4958 | - } |
4959 | - }; |
4960 | - |
4961 | private void switchToNameTextField() { |
4962 | basicPropertiesPanel.remove(sharedPlacesComboBox); |
4963 | - GridBagConstraints gbc = new java.awt.GridBagConstraints(); |
4964 | - gbc.gridx = 1; |
4965 | - gbc.gridy = 1; |
4966 | - gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; |
4967 | - gbc.insets = new java.awt.Insets(3, 3, 3, 3); |
4968 | - basicPropertiesPanel.add(nameTextField, gbc); |
4969 | + GridBagConstraints gbc = GridBagHelper.as(1,1, HORIZONTAL, new Insets(3, 3, 3, 3)); |
4970 | + basicPropertiesPanel.add(nameTextField, gbc); |
4971 | + |
4972 | basicPropertiesPanel.validate(); |
4973 | basicPropertiesPanel.repaint(); |
4974 | } |
4975 | |
4976 | private void switchToNameDropDown() { |
4977 | basicPropertiesPanel.remove(nameTextField); |
4978 | - GridBagConstraints gbc = new java.awt.GridBagConstraints(); |
4979 | - gbc.gridx = 1; |
4980 | - gbc.gridy = 1; |
4981 | - gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; |
4982 | - gbc.insets = new java.awt.Insets(3, 3, 3, 3); |
4983 | - basicPropertiesPanel.add(sharedPlacesComboBox, gbc); |
4984 | + GridBagConstraints gbc = GridBagHelper.as(1,1, HORIZONTAL, new Insets(3, 3, 3, 3)); |
4985 | + basicPropertiesPanel.add(sharedPlacesComboBox, gbc); |
4986 | + |
4987 | basicPropertiesPanel.validate(); |
4988 | basicPropertiesPanel.repaint(); |
4989 | |
4990 | @@ -587,7 +501,7 @@ |
4991 | private void setInvariantControlsBasedOn(TimeInvariant invariant) { |
4992 | if(invariant.upperBound() instanceof ConstantBound){ |
4993 | constantInvRadioButton.setSelected(true); |
4994 | - invRelationConstant.setModel(new DefaultComboBoxModel(invariant.upperBound().value() == 0 ? new String[] { "<=" } : new String[] { "<", "<=" })); |
4995 | + invRelationConstant.setModel(new DefaultComboBoxModel<>(invariant.upperBound().value() == 0 ? new String[] { "<=" } : new String[] { "<", "<=" })); |
4996 | invRelationConstant.setSelectedItem(invariant.isUpperNonstrict() ? "<=" : "<"); |
4997 | invRelationConstant.setEnabled(true); |
4998 | invConstantsComboBox.setEnabled(true); |
4999 | @@ -595,16 +509,16 @@ |
5000 | }else{ |
1. Right now quick draw only works if you are drawing arcs. Maybe it would be nice if it also worked when drawing places and transitions, i.e. it would place a place then start the quick draw.
2. It would be nice if it wasn't possible to place transitions underneath a place when quickdrawing and vice versa.
3. Right now, if you select drawing an arc an click anywhere it will create a new place (unless you click a place or transition) even if you are not holding ctrl. I'm not sure if this is intended. By my intuition it should just do nothing.
4. Just pressing 'A' will add a new edit to the undomanager, which is undoable. Place a place, press 'A', press ctrl + z. I would expect the place to disappear.
5. I cannot verify that https:/ /bugs.launchpad .net/tapaal/ +bug/1829887 is fixed. I cannot run it for 100+ seconds before getting an answer. Same for the mac bugs.
6. https:/ /bugs.launchpad .net/tapaal/ +bug/1762817 seems to be fixed