]> gerrit.simantics Code Review - simantics/platform.git/blob
64ea1c87709bd0f96f0fa6d136bd2b42cd026e8a
[simantics/platform.git] /
1 package org.simantics.browsing.ui.swt.stubs;
2
3 import org.simantics.db.RequestProcessor;
4 import org.simantics.db.Resource;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.request.Read;
7 import org.simantics.db.Session;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.service.QueryControl;
10
11 public class BrowsingResource {
12     
13     public final Resource Action;
14     public final Resource BundleIcon;
15     public final Resource BundleIcon_Bundle;
16     public final Resource BundleIcon_Bundle_Inverse;
17     public final Resource BundleIcon_Path;
18     public final Resource BundleIcon_Path_Inverse;
19     public final Resource Button;
20     public final Resource Button_Action;
21     public final Resource Button_Action_Inverse;
22     public final Resource Button_Icon;
23     public final Resource Button_Icon_Inverse;
24     public final Resource Button_Text;
25     public final Resource Button_Text_Inverse;
26     public final Resource Button_Tooltip;
27     public final Resource Button_Tooltip_Inverse;
28     public final Resource Combo;
29     public final Resource Combo_AvailableItems;
30     public final Resource Combo_AvailableItems_Inverse;
31     public final Resource Combo_Modifier;
32     public final Resource Combo_Modifier_Inverse;
33     public final Resource Combo_SelectedItem;
34     public final Resource Combo_SelectedItem_Inverse;
35     public final Resource Composite;
36     public final Resource Composite_Children;
37     public final Resource Composite_Children_Inverse;
38     public final Resource Composite_ColumnCount;
39     public final Resource Composite_ColumnCount_Inverse;
40     public final Resource Control;
41     public final Resource Control_HorizontalGrab;
42     public final Resource Control_HorizontalGrab_Inverse;
43     public final Resource Control_HorizontalSpan;
44     public final Resource Control_HorizontalSpan_Inverse;
45     public final Resource Control_PreferredHeight;
46     public final Resource Control_PreferredHeight_Inverse;
47     public final Resource Control_PreferredWidth;
48     public final Resource Control_PreferredWidth_Inverse;
49     public final Resource Dialog;
50     public final Resource Dialog_Control;
51     public final Resource Dialog_Control_Inverse;
52     public final Resource Dialog_FinishAction;
53     public final Resource Dialog_FinishAction_Inverse;
54     public final Resource Dialog_Title;
55     public final Resource Dialog_Title_Inverse;
56     public final Resource GraphExplorerComposite;
57     public final Resource GraphExplorerComposite_BrowseContext;
58     public final Resource GraphExplorerComposite_BrowseContext_Inverse;
59     public final Resource GraphExplorerComposite_Check;
60     public final Resource GraphExplorerComposite_Check_Inverse;
61     public final Resource GraphExplorerComposite_DisplayFilter;
62     public final Resource GraphExplorerComposite_DisplayFilter_Inverse;
63     public final Resource GraphExplorerComposite_SelectionListener;
64     public final Resource GraphExplorerComposite_SelectionListener_Inverse;
65     public final Resource GraphExplorerComposite_SelectionParameter;
66     public final Resource GraphExplorerComposite_SelectionParameter_Inverse;
67     public final Resource HasInputSource;
68     public final Resource HasInputSource_Inverse;
69     public final Resource Icon;
70     public final Resource InputSource;
71     public final Resource Listener;
72     public final Resource ModifyListener;
73     public final Resource Parameter;
74     public final Resource ReadFactory;
75     public final Resource Wizard;
76     public final Resource WizardPage;
77     public final Resource WizardPage_Control;
78     public final Resource WizardPage_Control_Inverse;
79     public final Resource WizardPage_Title;
80     public final Resource WizardPage_Title_Inverse;
81     public final Resource Wizard_FinishAction;
82     public final Resource Wizard_FinishAction_Inverse;
83     public final Resource Wizard_Pages;
84     public final Resource Wizard_Pages_Inverse;
85     public final Resource Wizard_Title;
86     public final Resource Wizard_Title_Inverse;
87     public final Resource WorkbenchSelectionInputSource;
88     public final Resource WorkbenchSelectionResourceInputSource;
89         
90     public static class URIs {
91         public static final String Action = "http://www.simantics.org/Browsing-1.1/Action";
92         public static final String BundleIcon = "http://www.simantics.org/Browsing-1.1/BundleIcon";
93         public static final String BundleIcon_Bundle = "http://www.simantics.org/Browsing-1.1/BundleIcon/Bundle";
94         public static final String BundleIcon_Bundle_Inverse = "http://www.simantics.org/Browsing-1.1/BundleIcon/Bundle/Inverse";
95         public static final String BundleIcon_Path = "http://www.simantics.org/Browsing-1.1/BundleIcon/Path";
96         public static final String BundleIcon_Path_Inverse = "http://www.simantics.org/Browsing-1.1/BundleIcon/Path/Inverse";
97         public static final String Button = "http://www.simantics.org/Browsing-1.1/Button";
98         public static final String Button_Action = "http://www.simantics.org/Browsing-1.1/Button/Action";
99         public static final String Button_Action_Inverse = "http://www.simantics.org/Browsing-1.1/Button/Action/Inverse";
100         public static final String Button_Icon = "http://www.simantics.org/Browsing-1.1/Button/Icon";
101         public static final String Button_Icon_Inverse = "http://www.simantics.org/Browsing-1.1/Button/Icon/Inverse";
102         public static final String Button_Text = "http://www.simantics.org/Browsing-1.1/Button/Text";
103         public static final String Button_Text_Inverse = "http://www.simantics.org/Browsing-1.1/Button/Text/Inverse";
104         public static final String Button_Tooltip = "http://www.simantics.org/Browsing-1.1/Button/Tooltip";
105         public static final String Button_Tooltip_Inverse = "http://www.simantics.org/Browsing-1.1/Button/Tooltip/Inverse";
106         public static final String Combo = "http://www.simantics.org/Browsing-1.1/Combo";
107         public static final String Combo_AvailableItems = "http://www.simantics.org/Browsing-1.1/Combo/AvailableItems";
108         public static final String Combo_AvailableItems_Inverse = "http://www.simantics.org/Browsing-1.1/Combo/AvailableItems/Inverse";
109         public static final String Combo_Modifier = "http://www.simantics.org/Browsing-1.1/Combo/Modifier";
110         public static final String Combo_Modifier_Inverse = "http://www.simantics.org/Browsing-1.1/Combo/Modifier/Inverse";
111         public static final String Combo_SelectedItem = "http://www.simantics.org/Browsing-1.1/Combo/SelectedItem";
112         public static final String Combo_SelectedItem_Inverse = "http://www.simantics.org/Browsing-1.1/Combo/SelectedItem/Inverse";
113         public static final String Composite = "http://www.simantics.org/Browsing-1.1/Composite";
114         public static final String Composite_Children = "http://www.simantics.org/Browsing-1.1/Composite/Children";
115         public static final String Composite_Children_Inverse = "http://www.simantics.org/Browsing-1.1/Composite/Children/Inverse";
116         public static final String Composite_ColumnCount = "http://www.simantics.org/Browsing-1.1/Composite/ColumnCount";
117         public static final String Composite_ColumnCount_Inverse = "http://www.simantics.org/Browsing-1.1/Composite/ColumnCount/Inverse";
118         public static final String Control = "http://www.simantics.org/Browsing-1.1/Control";
119         public static final String Control_HorizontalGrab = "http://www.simantics.org/Browsing-1.1/Control/HorizontalGrab";
120         public static final String Control_HorizontalGrab_Inverse = "http://www.simantics.org/Browsing-1.1/Control/HorizontalGrab/Inverse";
121         public static final String Control_HorizontalSpan = "http://www.simantics.org/Browsing-1.1/Control/HorizontalSpan";
122         public static final String Control_HorizontalSpan_Inverse = "http://www.simantics.org/Browsing-1.1/Control/HorizontalSpan/Inverse";
123         public static final String Control_PreferredHeight = "http://www.simantics.org/Browsing-1.1/Control/PreferredHeight";
124         public static final String Control_PreferredHeight_Inverse = "http://www.simantics.org/Browsing-1.1/Control/PreferredHeight/Inverse";
125         public static final String Control_PreferredWidth = "http://www.simantics.org/Browsing-1.1/Control/PreferredWidth";
126         public static final String Control_PreferredWidth_Inverse = "http://www.simantics.org/Browsing-1.1/Control/PreferredWidth/Inverse";
127         public static final String Dialog = "http://www.simantics.org/Browsing-1.1/Dialog";
128         public static final String Dialog_Control = "http://www.simantics.org/Browsing-1.1/Dialog/Control";
129         public static final String Dialog_Control_Inverse = "http://www.simantics.org/Browsing-1.1/Dialog/Control/Inverse";
130         public static final String Dialog_FinishAction = "http://www.simantics.org/Browsing-1.1/Dialog/FinishAction";
131         public static final String Dialog_FinishAction_Inverse = "http://www.simantics.org/Browsing-1.1/Dialog/FinishAction/Inverse";
132         public static final String Dialog_Title = "http://www.simantics.org/Browsing-1.1/Dialog/Title";
133         public static final String Dialog_Title_Inverse = "http://www.simantics.org/Browsing-1.1/Dialog/Title/Inverse";
134         public static final String GraphExplorerComposite = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite";
135         public static final String GraphExplorerComposite_BrowseContext = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/BrowseContext";
136         public static final String GraphExplorerComposite_BrowseContext_Inverse = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/BrowseContext/Inverse";
137         public static final String GraphExplorerComposite_Check = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/Check";
138         public static final String GraphExplorerComposite_Check_Inverse = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/Check/Inverse";
139         public static final String GraphExplorerComposite_DisplayFilter = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/DisplayFilter";
140         public static final String GraphExplorerComposite_DisplayFilter_Inverse = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/DisplayFilter/Inverse";
141         public static final String GraphExplorerComposite_SelectionListener = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/SelectionListener";
142         public static final String GraphExplorerComposite_SelectionListener_Inverse = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/SelectionListener/Inverse";
143         public static final String GraphExplorerComposite_SelectionParameter = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/SelectionParameter";
144         public static final String GraphExplorerComposite_SelectionParameter_Inverse = "http://www.simantics.org/Browsing-1.1/GraphExplorerComposite/SelectionParameter/Inverse";
145         public static final String HasInputSource = "http://www.simantics.org/Browsing-1.1/HasInputSource";
146         public static final String HasInputSource_Inverse = "http://www.simantics.org/Browsing-1.1/HasInputSource/Inverse";
147         public static final String Icon = "http://www.simantics.org/Browsing-1.1/Icon";
148         public static final String InputSource = "http://www.simantics.org/Browsing-1.1/InputSource";
149         public static final String Listener = "http://www.simantics.org/Browsing-1.1/Listener";
150         public static final String ModifyListener = "http://www.simantics.org/Browsing-1.1/ModifyListener";
151         public static final String Parameter = "http://www.simantics.org/Browsing-1.1/Parameter";
152         public static final String ReadFactory = "http://www.simantics.org/Browsing-1.1/ReadFactory";
153         public static final String Wizard = "http://www.simantics.org/Browsing-1.1/Wizard";
154         public static final String WizardPage = "http://www.simantics.org/Browsing-1.1/WizardPage";
155         public static final String WizardPage_Control = "http://www.simantics.org/Browsing-1.1/WizardPage/Control";
156         public static final String WizardPage_Control_Inverse = "http://www.simantics.org/Browsing-1.1/WizardPage/Control/Inverse";
157         public static final String WizardPage_Title = "http://www.simantics.org/Browsing-1.1/WizardPage/Title";
158         public static final String WizardPage_Title_Inverse = "http://www.simantics.org/Browsing-1.1/WizardPage/Title/Inverse";
159         public static final String Wizard_FinishAction = "http://www.simantics.org/Browsing-1.1/Wizard/FinishAction";
160         public static final String Wizard_FinishAction_Inverse = "http://www.simantics.org/Browsing-1.1/Wizard/FinishAction/Inverse";
161         public static final String Wizard_Pages = "http://www.simantics.org/Browsing-1.1/Wizard/Pages";
162         public static final String Wizard_Pages_Inverse = "http://www.simantics.org/Browsing-1.1/Wizard/Pages/Inverse";
163         public static final String Wizard_Title = "http://www.simantics.org/Browsing-1.1/Wizard/Title";
164         public static final String Wizard_Title_Inverse = "http://www.simantics.org/Browsing-1.1/Wizard/Title/Inverse";
165         public static final String WorkbenchSelectionInputSource = "http://www.simantics.org/Browsing-1.1/WorkbenchSelectionInputSource";
166         public static final String WorkbenchSelectionResourceInputSource = "http://www.simantics.org/Browsing-1.1/WorkbenchSelectionResourceInputSource";
167     }
168     
169     public static Resource getResourceOrNull(ReadGraph graph, String uri) {
170         try {
171             return graph.getResource(uri);
172         } catch(DatabaseException e) {
173             System.err.println(e.getMessage());
174             return null;
175         }
176     }
177     
178     public BrowsingResource(ReadGraph graph) {
179         Action = getResourceOrNull(graph, URIs.Action);
180         BundleIcon = getResourceOrNull(graph, URIs.BundleIcon);
181         BundleIcon_Bundle = getResourceOrNull(graph, URIs.BundleIcon_Bundle);
182         BundleIcon_Bundle_Inverse = getResourceOrNull(graph, URIs.BundleIcon_Bundle_Inverse);
183         BundleIcon_Path = getResourceOrNull(graph, URIs.BundleIcon_Path);
184         BundleIcon_Path_Inverse = getResourceOrNull(graph, URIs.BundleIcon_Path_Inverse);
185         Button = getResourceOrNull(graph, URIs.Button);
186         Button_Action = getResourceOrNull(graph, URIs.Button_Action);
187         Button_Action_Inverse = getResourceOrNull(graph, URIs.Button_Action_Inverse);
188         Button_Icon = getResourceOrNull(graph, URIs.Button_Icon);
189         Button_Icon_Inverse = getResourceOrNull(graph, URIs.Button_Icon_Inverse);
190         Button_Text = getResourceOrNull(graph, URIs.Button_Text);
191         Button_Text_Inverse = getResourceOrNull(graph, URIs.Button_Text_Inverse);
192         Button_Tooltip = getResourceOrNull(graph, URIs.Button_Tooltip);
193         Button_Tooltip_Inverse = getResourceOrNull(graph, URIs.Button_Tooltip_Inverse);
194         Combo = getResourceOrNull(graph, URIs.Combo);
195         Combo_AvailableItems = getResourceOrNull(graph, URIs.Combo_AvailableItems);
196         Combo_AvailableItems_Inverse = getResourceOrNull(graph, URIs.Combo_AvailableItems_Inverse);
197         Combo_Modifier = getResourceOrNull(graph, URIs.Combo_Modifier);
198         Combo_Modifier_Inverse = getResourceOrNull(graph, URIs.Combo_Modifier_Inverse);
199         Combo_SelectedItem = getResourceOrNull(graph, URIs.Combo_SelectedItem);
200         Combo_SelectedItem_Inverse = getResourceOrNull(graph, URIs.Combo_SelectedItem_Inverse);
201         Composite = getResourceOrNull(graph, URIs.Composite);
202         Composite_Children = getResourceOrNull(graph, URIs.Composite_Children);
203         Composite_Children_Inverse = getResourceOrNull(graph, URIs.Composite_Children_Inverse);
204         Composite_ColumnCount = getResourceOrNull(graph, URIs.Composite_ColumnCount);
205         Composite_ColumnCount_Inverse = getResourceOrNull(graph, URIs.Composite_ColumnCount_Inverse);
206         Control = getResourceOrNull(graph, URIs.Control);
207         Control_HorizontalGrab = getResourceOrNull(graph, URIs.Control_HorizontalGrab);
208         Control_HorizontalGrab_Inverse = getResourceOrNull(graph, URIs.Control_HorizontalGrab_Inverse);
209         Control_HorizontalSpan = getResourceOrNull(graph, URIs.Control_HorizontalSpan);
210         Control_HorizontalSpan_Inverse = getResourceOrNull(graph, URIs.Control_HorizontalSpan_Inverse);
211         Control_PreferredHeight = getResourceOrNull(graph, URIs.Control_PreferredHeight);
212         Control_PreferredHeight_Inverse = getResourceOrNull(graph, URIs.Control_PreferredHeight_Inverse);
213         Control_PreferredWidth = getResourceOrNull(graph, URIs.Control_PreferredWidth);
214         Control_PreferredWidth_Inverse = getResourceOrNull(graph, URIs.Control_PreferredWidth_Inverse);
215         Dialog = getResourceOrNull(graph, URIs.Dialog);
216         Dialog_Control = getResourceOrNull(graph, URIs.Dialog_Control);
217         Dialog_Control_Inverse = getResourceOrNull(graph, URIs.Dialog_Control_Inverse);
218         Dialog_FinishAction = getResourceOrNull(graph, URIs.Dialog_FinishAction);
219         Dialog_FinishAction_Inverse = getResourceOrNull(graph, URIs.Dialog_FinishAction_Inverse);
220         Dialog_Title = getResourceOrNull(graph, URIs.Dialog_Title);
221         Dialog_Title_Inverse = getResourceOrNull(graph, URIs.Dialog_Title_Inverse);
222         GraphExplorerComposite = getResourceOrNull(graph, URIs.GraphExplorerComposite);
223         GraphExplorerComposite_BrowseContext = getResourceOrNull(graph, URIs.GraphExplorerComposite_BrowseContext);
224         GraphExplorerComposite_BrowseContext_Inverse = getResourceOrNull(graph, URIs.GraphExplorerComposite_BrowseContext_Inverse);
225         GraphExplorerComposite_Check = getResourceOrNull(graph, URIs.GraphExplorerComposite_Check);
226         GraphExplorerComposite_Check_Inverse = getResourceOrNull(graph, URIs.GraphExplorerComposite_Check_Inverse);
227         GraphExplorerComposite_DisplayFilter = getResourceOrNull(graph, URIs.GraphExplorerComposite_DisplayFilter);
228         GraphExplorerComposite_DisplayFilter_Inverse = getResourceOrNull(graph, URIs.GraphExplorerComposite_DisplayFilter_Inverse);
229         GraphExplorerComposite_SelectionListener = getResourceOrNull(graph, URIs.GraphExplorerComposite_SelectionListener);
230         GraphExplorerComposite_SelectionListener_Inverse = getResourceOrNull(graph, URIs.GraphExplorerComposite_SelectionListener_Inverse);
231         GraphExplorerComposite_SelectionParameter = getResourceOrNull(graph, URIs.GraphExplorerComposite_SelectionParameter);
232         GraphExplorerComposite_SelectionParameter_Inverse = getResourceOrNull(graph, URIs.GraphExplorerComposite_SelectionParameter_Inverse);
233         HasInputSource = getResourceOrNull(graph, URIs.HasInputSource);
234         HasInputSource_Inverse = getResourceOrNull(graph, URIs.HasInputSource_Inverse);
235         Icon = getResourceOrNull(graph, URIs.Icon);
236         InputSource = getResourceOrNull(graph, URIs.InputSource);
237         Listener = getResourceOrNull(graph, URIs.Listener);
238         ModifyListener = getResourceOrNull(graph, URIs.ModifyListener);
239         Parameter = getResourceOrNull(graph, URIs.Parameter);
240         ReadFactory = getResourceOrNull(graph, URIs.ReadFactory);
241         Wizard = getResourceOrNull(graph, URIs.Wizard);
242         WizardPage = getResourceOrNull(graph, URIs.WizardPage);
243         WizardPage_Control = getResourceOrNull(graph, URIs.WizardPage_Control);
244         WizardPage_Control_Inverse = getResourceOrNull(graph, URIs.WizardPage_Control_Inverse);
245         WizardPage_Title = getResourceOrNull(graph, URIs.WizardPage_Title);
246         WizardPage_Title_Inverse = getResourceOrNull(graph, URIs.WizardPage_Title_Inverse);
247         Wizard_FinishAction = getResourceOrNull(graph, URIs.Wizard_FinishAction);
248         Wizard_FinishAction_Inverse = getResourceOrNull(graph, URIs.Wizard_FinishAction_Inverse);
249         Wizard_Pages = getResourceOrNull(graph, URIs.Wizard_Pages);
250         Wizard_Pages_Inverse = getResourceOrNull(graph, URIs.Wizard_Pages_Inverse);
251         Wizard_Title = getResourceOrNull(graph, URIs.Wizard_Title);
252         Wizard_Title_Inverse = getResourceOrNull(graph, URIs.Wizard_Title_Inverse);
253         WorkbenchSelectionInputSource = getResourceOrNull(graph, URIs.WorkbenchSelectionInputSource);
254         WorkbenchSelectionResourceInputSource = getResourceOrNull(graph, URIs.WorkbenchSelectionResourceInputSource);
255     }
256     
257     public static BrowsingResource getInstance(ReadGraph graph) {
258         Session session = graph.getSession();
259         BrowsingResource ret = session.peekService(BrowsingResource.class);
260         if(ret == null) {
261             QueryControl qc = graph.getService(QueryControl.class);
262             ret = new BrowsingResource(qc.getIndependentGraph(graph));
263             session.registerService(BrowsingResource.class, ret);
264         }
265         return ret;
266     }
267     
268     public static BrowsingResource getInstance(RequestProcessor session) throws DatabaseException {
269         BrowsingResource ret = session.peekService(BrowsingResource.class);
270         if(ret == null) {
271             ret = session.syncRequest(new Read<BrowsingResource>() {
272                 public BrowsingResource perform(ReadGraph graph) throws DatabaseException {
273                     QueryControl qc = graph.getService(QueryControl.class);
274                     return new BrowsingResource(qc.getIndependentGraph(graph));
275                 }
276             });
277             session.registerService(BrowsingResource.class, ret);
278         }
279         return ret;
280     }
281     
282 }
283