~peta-power-group/+junk/vIDE-trunk

« back to all changes in this revision

Viewing changes to net.launchpad.vide.diagram/src/net/launchpad/vide/flowchart/diagram/part/FlowchartDiagramEditorPlugin.java

  • Committer: Dražen Lučanin
  • Date: 2010-12-16 01:15:35 UTC
  • Revision ID: kermit666@gmail.com-20101216011535-5uk4xtiwbu9ia3hl
Added the algorithm domain model & deleted the old generated projects

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package net.launchpad.vide.flowchart.diagram.part;
2
 
 
3
 
import java.util.ArrayList;
4
 
import java.util.List;
5
 
 
6
 
import net.launchpad.vide.flowchart.diagram.edit.policies.FlowchartBaseItemSemanticEditPolicy;
7
 
import net.launchpad.vide.flowchart.diagram.providers.ElementInitializers;
8
 
import net.launchpad.vide.flowchart.provider.FlowchartItemProviderAdapterFactory;
9
 
 
10
 
import org.eclipse.core.runtime.IPath;
11
 
import org.eclipse.core.runtime.IStatus;
12
 
import org.eclipse.core.runtime.Path;
13
 
import org.eclipse.core.runtime.Platform;
14
 
import org.eclipse.core.runtime.Status;
15
 
import org.eclipse.emf.common.notify.AdapterFactory;
16
 
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
17
 
import org.eclipse.emf.edit.provider.IItemLabelProvider;
18
 
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
19
 
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
20
 
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
21
 
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
22
 
import org.eclipse.jface.resource.ImageDescriptor;
23
 
import org.eclipse.swt.graphics.Image;
24
 
import org.eclipse.ui.plugin.AbstractUIPlugin;
25
 
import org.osgi.framework.BundleContext;
26
 
 
27
 
/**
28
 
 * @generated
29
 
 */
30
 
public class FlowchartDiagramEditorPlugin extends AbstractUIPlugin {
31
 
 
32
 
        /**
33
 
         * @generated
34
 
         */
35
 
        public static final String ID = "net.launchpad.vide.diagram"; //$NON-NLS-1$
36
 
 
37
 
        /**
38
 
         * @generated
39
 
         */
40
 
        public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(
41
 
                        ID);
42
 
 
43
 
        /**
44
 
         * @generated
45
 
         */
46
 
        private static FlowchartDiagramEditorPlugin instance;
47
 
 
48
 
        /**
49
 
         * @generated
50
 
         */
51
 
        private ComposedAdapterFactory adapterFactory;
52
 
 
53
 
        /**
54
 
         * @generated
55
 
         */
56
 
        private FlowchartDocumentProvider documentProvider;
57
 
 
58
 
        /**
59
 
         * @generated
60
 
         */
61
 
        private FlowchartBaseItemSemanticEditPolicy.LinkConstraints linkConstraints;
62
 
 
63
 
        /**
64
 
         * @generated
65
 
         */
66
 
        private ElementInitializers initializers;
67
 
 
68
 
        /**
69
 
         * @generated
70
 
         */
71
 
        public FlowchartDiagramEditorPlugin() {
72
 
        }
73
 
 
74
 
        /**
75
 
         * @generated
76
 
         */
77
 
        public void start(BundleContext context) throws Exception {
78
 
                super.start(context);
79
 
                instance = this;
80
 
                PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT,
81
 
                                getPreferenceStore());
82
 
                adapterFactory = createAdapterFactory();
83
 
        }
84
 
 
85
 
        /**
86
 
         * @generated
87
 
         */
88
 
        public void stop(BundleContext context) throws Exception {
89
 
                adapterFactory.dispose();
90
 
                adapterFactory = null;
91
 
                linkConstraints = null;
92
 
                initializers = null;
93
 
                instance = null;
94
 
                super.stop(context);
95
 
        }
96
 
 
97
 
        /**
98
 
         * @generated
99
 
         */
100
 
        public static FlowchartDiagramEditorPlugin getInstance() {
101
 
                return instance;
102
 
        }
103
 
 
104
 
        /**
105
 
         * @generated
106
 
         */
107
 
        protected ComposedAdapterFactory createAdapterFactory() {
108
 
                ArrayList<AdapterFactory> factories = new ArrayList<AdapterFactory>();
109
 
                fillItemProviderFactories(factories);
110
 
                return new ComposedAdapterFactory(factories);
111
 
        }
112
 
 
113
 
        /**
114
 
         * @generated
115
 
         */
116
 
        protected void fillItemProviderFactories(List<AdapterFactory> factories) {
117
 
                factories.add(new FlowchartItemProviderAdapterFactory());
118
 
                factories.add(new ResourceItemProviderAdapterFactory());
119
 
                factories.add(new ReflectiveItemProviderAdapterFactory());
120
 
        }
121
 
 
122
 
        /**
123
 
         * @generated
124
 
         */
125
 
        public AdapterFactory getItemProvidersAdapterFactory() {
126
 
                return adapterFactory;
127
 
        }
128
 
 
129
 
        /**
130
 
         * @generated
131
 
         */
132
 
        public ImageDescriptor getItemImageDescriptor(Object item) {
133
 
                IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory
134
 
                                .adapt(item, IItemLabelProvider.class);
135
 
                if (labelProvider != null) {
136
 
                        return ExtendedImageRegistry.getInstance().getImageDescriptor(
137
 
                                        labelProvider.getImage(item));
138
 
                }
139
 
                return null;
140
 
        }
141
 
 
142
 
        /**
143
 
         * Returns an image descriptor for the image file at the given
144
 
         * plug-in relative path.
145
 
         *
146
 
         * @generated
147
 
         * @param path the path
148
 
         * @return the image descriptor
149
 
         */
150
 
        public static ImageDescriptor getBundledImageDescriptor(String path) {
151
 
                return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
152
 
        }
153
 
 
154
 
        /**
155
 
         * Respects images residing in any plug-in. If path is relative,
156
 
         * then this bundle is looked up for the image, otherwise, for absolute 
157
 
         * path, first segment is taken as id of plug-in with image
158
 
         *
159
 
         * @generated
160
 
         * @param path the path to image, either absolute (with plug-in id as first segment), or relative for bundled images
161
 
         * @return the image descriptor
162
 
         */
163
 
        public static ImageDescriptor findImageDescriptor(String path) {
164
 
                final IPath p = new Path(path);
165
 
                if (p.isAbsolute() && p.segmentCount() > 1) {
166
 
                        return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p
167
 
                                        .removeFirstSegments(1).makeAbsolute().toString());
168
 
                } else {
169
 
                        return getBundledImageDescriptor(p.makeAbsolute().toString());
170
 
                }
171
 
        }
172
 
 
173
 
        /**
174
 
         * Returns an image for the image file at the given plug-in relative path.
175
 
         * Client do not need to dispose this image. Images will be disposed automatically.
176
 
         *
177
 
         * @generated
178
 
         * @param path the path
179
 
         * @return image instance
180
 
         */
181
 
        public Image getBundledImage(String path) {
182
 
                Image image = getImageRegistry().get(path);
183
 
                if (image == null) {
184
 
                        getImageRegistry().put(path, getBundledImageDescriptor(path));
185
 
                        image = getImageRegistry().get(path);
186
 
                }
187
 
                return image;
188
 
        }
189
 
 
190
 
        /**
191
 
         * Returns string from plug-in's resource bundle
192
 
         *
193
 
         * @generated
194
 
         */
195
 
        public static String getString(String key) {
196
 
                return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$
197
 
        }
198
 
 
199
 
        /**
200
 
         * @generated
201
 
         */
202
 
        public FlowchartDocumentProvider getDocumentProvider() {
203
 
                if (documentProvider == null) {
204
 
                        documentProvider = new FlowchartDocumentProvider();
205
 
                }
206
 
                return documentProvider;
207
 
        }
208
 
 
209
 
        /**
210
 
         * @generated
211
 
         */
212
 
        public FlowchartBaseItemSemanticEditPolicy.LinkConstraints getLinkConstraints() {
213
 
                return linkConstraints;
214
 
        }
215
 
 
216
 
        /**
217
 
         * @generated
218
 
         */
219
 
        public void setLinkConstraints(
220
 
                        FlowchartBaseItemSemanticEditPolicy.LinkConstraints lc) {
221
 
                this.linkConstraints = lc;
222
 
        }
223
 
 
224
 
        /**
225
 
         * @generated
226
 
         */
227
 
        public ElementInitializers getElementInitializers() {
228
 
                return initializers;
229
 
        }
230
 
 
231
 
        /**
232
 
         * @generated
233
 
         */
234
 
        public void setElementInitializers(ElementInitializers i) {
235
 
                this.initializers = i;
236
 
        }
237
 
 
238
 
        /**
239
 
         * @generated
240
 
         */
241
 
        public void logError(String error) {
242
 
                logError(error, null);
243
 
        }
244
 
 
245
 
        /**
246
 
         * @generated
247
 
         */
248
 
        public void logError(String error, Throwable throwable) {
249
 
                if (error == null && throwable != null) {
250
 
                        error = throwable.getMessage();
251
 
                }
252
 
                getLog().log(
253
 
                                new Status(IStatus.ERROR, FlowchartDiagramEditorPlugin.ID,
254
 
                                                IStatus.OK, error, throwable));
255
 
                debug(error, throwable);
256
 
        }
257
 
 
258
 
        /**
259
 
         * @generated
260
 
         */
261
 
        public void logInfo(String message) {
262
 
                logInfo(message, null);
263
 
        }
264
 
 
265
 
        /**
266
 
         * @generated
267
 
         */
268
 
        public void logInfo(String message, Throwable throwable) {
269
 
                if (message == null && throwable != null) {
270
 
                        message = throwable.getMessage();
271
 
                }
272
 
                getLog().log(
273
 
                                new Status(IStatus.INFO, FlowchartDiagramEditorPlugin.ID,
274
 
                                                IStatus.OK, message, throwable));
275
 
                debug(message, throwable);
276
 
        }
277
 
 
278
 
        /**
279
 
         * @generated
280
 
         */
281
 
        private void debug(String message, Throwable throwable) {
282
 
                if (!isDebugging()) {
283
 
                        return;
284
 
                }
285
 
                if (message != null) {
286
 
                        System.err.println(message);
287
 
                }
288
 
                if (throwable != null) {
289
 
                        throwable.printStackTrace();
290
 
                }
291
 
        }
292
 
}