]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.ui/src/org/simantics/document/ui/Activator.java
5a25c5b6b7f8708d0c7865ff20ad0ee8150ca68a
[simantics/platform.git] / bundles / org.simantics.document.ui / src / org / simantics / document / ui / Activator.java
1 /*******************************************************************************
2  * Copyright (c) 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.document.ui;
13
14 import java.nio.file.Path;
15 import java.nio.file.Paths;
16
17 import org.eclipse.core.runtime.IPath;
18 import org.eclipse.core.runtime.Platform;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.eclipse.ui.plugin.AbstractUIPlugin;
21 import org.osgi.framework.Bundle;
22 import org.osgi.framework.BundleContext;
23 import org.simantics.document.ui.graphfile.ExternalEditorAdapter;
24
25 /**
26  * The activator class controls the plug-in life cycle
27  */
28 public class Activator extends AbstractUIPlugin {
29
30         // The plug-in ID
31         public static final String PLUGIN_ID = "org.simantics.document.ui"; //$NON-NLS-1$
32
33         // The shared instance
34         private static Activator plugin;
35         
36     public ImageDescriptor DOCUMENT_DECORATION_ICON;
37     
38         public ImageDescriptor cross;
39         public ImageDescriptor clock_red;
40
41     private static Path location;
42         
43         /**
44          * The constructor
45          */
46         public Activator() {
47         }
48
49         /*
50          * (non-Javadoc)
51          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
52          */
53         public void start(BundleContext context) throws Exception {
54                 
55                 super.start(context);
56                 
57                 plugin = this;
58
59                 Bundle bundle = context.getBundle();
60                 
61                 DOCUMENT_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/document_decoration.png"));
62                 cross = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/cross.png"));
63                 clock_red = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/clock_red.png"));
64                 
65                 IPath ipath = Platform.getStateLocation(bundle);
66                 location = Paths.get(ipath.toOSString());
67         }
68
69         /*
70          * (non-Javadoc)
71          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
72          */
73         public void stop(BundleContext context) throws Exception {
74             ExternalEditorAdapter.stopFileWatcher();
75                 plugin = null;
76                 super.stop(context);
77         }
78
79         /**
80          * Returns the shared instance
81          *
82          * @return the shared instance
83          */
84         public static Activator getDefault() {
85                 return plugin;
86         }
87
88         public static Path getInstanceLocation() {
89             return location;
90         }
91 }