1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.fosstrak.llrp.commander.editors.graphical;
23
24 import java.util.Observable;
25 import java.util.Observer;
26
27 import org.eclipse.ui.forms.IManagedForm;
28 import org.eclipse.ui.forms.editor.FormPage;
29 import org.eclipse.ui.forms.widgets.ScrolledForm;
30 import org.fosstrak.llrp.commander.editors.LLRPEditor;
31 import org.fosstrak.llrp.commander.util.LLRPTreeMaintainer;
32 import org.llrp.ltk.types.LLRPMessage;
33
34
35
36
37
38
39
40
41 public class GraphicalEditorPage extends FormPage implements Observer {
42
43 private final static String GRAPHICAL_EDITOR_TITLE = "Graphical Editor";
44 private LLRPEditor editor;
45 private LLRPMasterDetailsBlock masterDetailsBlock;
46 private LLRPTreeMaintainer treeMaintainer;
47 private boolean masterDetailsBlockCreated;
48 private boolean dirty;
49
50
51
52
53
54
55 public GraphicalEditorPage(LLRPEditor editor) {
56 super(editor, "graphicalEditor", GRAPHICAL_EDITOR_TITLE);
57 this.editor = editor;
58 treeMaintainer = new LLRPTreeMaintainer(null);
59 treeMaintainer.addObserver(this);
60 masterDetailsBlock = new LLRPMasterDetailsBlock(this, this.treeMaintainer);
61 }
62
63
64
65
66 protected void createFormContent(final IManagedForm managedForm) {
67 final ScrolledForm form = managedForm.getForm();
68 form.setText(GRAPHICAL_EDITOR_TITLE);
69 masterDetailsBlock.createContent(managedForm);
70 masterDetailsBlockCreated = true;
71 }
72
73
74
75
76
77
78 public LLRPMessage getLLRPMessage(){
79 return treeMaintainer.getRoot();
80 }
81
82
83
84
85
86
87 public void setLLRPMessage(LLRPMessage lLRPMessage){
88 this.treeMaintainer.setRoot(lLRPMessage);
89 dirty = false;
90 if (masterDetailsBlockCreated){
91 masterDetailsBlock.refresh(treeMaintainer.getRoot());
92 }
93 }
94
95
96
97
98 public boolean isGraphicalEditorDirty() {
99 return dirty;
100 }
101
102
103
104
105 public void setDirty(boolean dirty) {
106 this.dirty = dirty;
107 }
108
109 public void update(Observable arg0, Object arg1) {
110 if ((arg0 == treeMaintainer) && (!dirty)){
111 dirty = true;
112 editor.markXMLEditorAsDirty();
113 }
114 }
115 }