/** * Removes the active tab from display if it exists. Note active tab must be removed from * netControllers before the petri net is removed from the manager because the manager will fire a * message which causes the active tab to be swapped to the new open tab */ public void removeActiveTab() { if (activeTab != null) { PetriNetController controller = netControllers.get(activeTab); netControllers.remove(activeTab); PetriNet petriNet = controller.getPetriNet(); manager.remove(petriNet); } }
// TODO: THIS IS RATHER UGLY, too many params but better than what was here before public void registerTab( PetriNet net, PetriNetTab tab, Observer historyObserver, UndoableEditListener undoListener, PropertyChangeListener zoomListener) { AnimationHistoryImpl animationHistory = new AnimationHistoryImpl(); animationHistory.addObserver(historyObserver); GUIAnimator animator = new GUIAnimator(new PetriNetAnimator(net), animationHistory, this); CopyPasteManager copyPasteManager = new CopyPasteManager(undoListener, tab, net, this); ZoomController zoomController = new ZoomController(100); tab.addZoomListener(zoomController); PetriNetController petriNetController = new PetriNetController(net, undoListener, animator, copyPasteManager, zoomController, tab); netControllers.put(tab, petriNetController); tab.updatePreferredSize(); PropertyChangeListener changeListener = new PetriNetChangeListener(applicationModel, tab, petriNetController); net.addPropertyChangeListener(changeListener); setActiveTab(tab); initialiseNet(net, changeListener); }
/** @return the names of the petri nets that have changed */ public Set<String> getNetsChanged() { Set<String> changed = new HashSet<>(); for (PetriNetController controller : netControllers.values()) { if (controller.hasChanged()) { changed.add(controller.getPetriNet().getNameValue()); } } return changed; }
/** @return the active Petri net controller */ public PetriNetController getActivePetriNetController() { return netControllers.get(activeTab); }