~tapaal-contributor/tapaal/disappearing-tokens-1940098

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/gui/Context.java

  • Committer: Kenneth Yrke Jørgensen
  • Date: 2011-04-12 09:50:16 UTC
  • mfrom: (329.1.188 tapaal-1.5)
  • Revision ID: mail@yrke.dk-20110412095016-e4hqdgab5596ja09
Merged with branch addning support for new 1.5 features

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package dk.aau.cs.gui;
 
2
 
 
3
import pipe.dataLayer.TAPNQuery;
 
4
import pipe.dataLayer.Template;
 
5
import pipe.gui.undo.UndoManager;
 
6
import dk.aau.cs.model.tapn.TimedArcPetriNet;
 
7
import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
 
8
import dk.aau.cs.util.Require;
 
9
 
 
10
public class Context { // TODO: consider having only currentTab as a field and have methods ask it for the things?
 
11
        private final TimedArcPetriNetNetwork network;
 
12
        private final Template selectedTemplate;
 
13
        
 
14
        private final UndoManager undoManager;
 
15
        private final TabContent currentTab;
 
16
        
 
17
        public Context(TabContent tab) {
 
18
                Require.that(tab != null, "tab cannot be null");
 
19
                this.currentTab = tab;
 
20
                this.network = tab.network();
 
21
                this.selectedTemplate = tab.activeTemplate();
 
22
                this.undoManager = tab.drawingSurface().getUndoManager();
 
23
        }
 
24
        
 
25
        public TimedArcPetriNetNetwork network(){
 
26
                return network;
 
27
        }
 
28
        
 
29
        public TimedArcPetriNet activeModel(){
 
30
                return selectedTemplate.model();
 
31
        }
 
32
        
 
33
        public UndoManager undoManager(){
 
34
                return undoManager;
 
35
        }
 
36
 
 
37
        public Iterable<TAPNQuery> queries() {
 
38
                return currentTab.queries();
 
39
        }
 
40
 
 
41
        public TabContent tabContent() {
 
42
                return currentTab;
 
43
        }
 
44
 
 
45
        public NameGenerator nameGenerator() {
 
46
                return currentTab.drawingSurface().getNameGenerator();
 
47
        }
 
48
}