~yrke/tapaal/tapaal-fix1764383-java9macoslookandfeel

« back to all changes in this revision

Viewing changes to src/pipe/gui/handler/PlaceTransitionObjectHandler.java

  • Committer: Jiri Srba
  • Date: 2017-10-04 08:53:41 UTC
  • mfrom: (945.1.1 tapaal)
  • Revision ID: srba.jiri@gmail.com-20171004085341-h2s64ayugpwxuaj1
merged in branch lp:~tapaal-contributor/tapaal/cancel-arc-draw-fix-1718892 fixing
escaping from drawing an arc with multiple anchor points

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        private static final String ERROR_MSG_TWO_ARCS = "We do not allow two arcs from a place to a transition or a transition to a place.";
47
47
        private DataLayer guiModel;
48
48
        private TimedArcPetriNet model;
49
 
        ArcKeyboardEventHandler keyHandler = null;
50
49
 
51
50
        public PlaceTransitionObjectHandler(Container contentpane,
52
51
                        PlaceTransitionObject obj, DataLayer guiModel,
70
69
                CreateGui.getView().createArc = newArc;
71
70
                // addPetriNetObject a handler for shift & esc actions drawing arc
72
71
                // this is removed when the arc is finished drawing:
73
 
                keyHandler = new ArcKeyboardEventHandler(newArc);
74
 
                newArc.addKeyListener(keyHandler);
75
72
                newArc.requestFocusInWindow();
76
73
                newArc.setSelectable(false);
 
74
                newArc.enableDrawingKeyBindings();
77
75
        }
78
 
        // Call this function to cleanup temporary key handlers for an new arc object
 
76
 
 
77
        // Disable key bindings that are only available when drawing arcs.
79
78
        private void freeArc(Arc newArc){
80
 
                newArc.removeKeyListener(keyHandler);
81
 
                keyHandler = null;
 
79
                newArc.disableDrawingKeyBindings();
82
80
                CreateGui.getView().createArc = null;
83
81
        }
84
82
 
194
192
                                        undoManager.addNewEdit(new AddTimedInhibitorArcCommand(
195
193
                                                        createTAPNInhibitorArc, model, guiModel, view));
196
194
 
197
 
                                        // arc is drawn, remove handler:
198
195
                                        freeArc(createTAPNInhibitorArc);
199
 
                                        
200
 
                                        
201
196
                                }
202
197
 
203
198
                        break;
296
291
                                                guiModel.addArc((TimedOutputArcComponent) transportArcToCreate);
297
292
                                                view.addNewPetriNetObject(transportArcToCreate);
298
293
 
299
 
                                                // arc is drawn, remove handlers:
300
294
                                                freeArc(transportArcToCreate);
301
295
                                                
302
296
                                                // Create the next arc
361
355
                                                                                guiModel, 
362
356
                                                                                view));
363
357
 
364
 
                                                // arc is drawn, remove handlers:
365
358
                                                freeArc(transportArcToCreate);
366
359
 
367
360
                                                arc2.setGroupNr(arc1.getGroupNr());
368
 
 
369
 
                                                
370
361
                                        }
371
362
 
372
363
                                }
470
461
                                                                model, guiModel, view));
471
462
 
472
463
                                        }
473
 
                                        // arc is drawn, remove handler:
474
 
                                        // arc is drawn, remove handlers:
 
464
 
475
465
                                        freeArc(timedArcToCreate);
476
466
                                }
477
467
                        break;
488
478
 
489
479
        private void cleanupArc(Arc arc, DrawingSurfaceImpl view) {
490
480
                arc.delete();
491
 
                // arc is drawn, remove handlers:
492
481
                freeArc(arc);
493
482
                
494
483
                view.remove(arc);