001: package com.xoetrope.editor.eclipse;
002:
003: import java.net.URL;
004:
005: import javax.swing.SwingUtilities;
006: import javax.swing.UIManager;
007:
008: import net.xoetrope.editor.dnd.PageDesignerTransferHandler;
009: import net.xoetrope.editor.eclipse.project.pages.EditorUtility;
010: import net.xoetrope.editor.project.XEditorProjectManager;
011: import net.xoetrope.editor.project.pages.PageDesigner;
012: import net.xoetrope.editor.project.pages.XPageResource;
013: import net.xoetrope.editor.project.pages.components.XEditorRegisteredComponentFactory;
014:
015: import org.eclipse.jface.resource.ImageDescriptor;
016: import org.eclipse.ui.plugin.AbstractUIPlugin;
017: import org.osgi.framework.BundleContext;
018:
019: import com.xoetrope.builder.database.DatabaseFormBuilderDndHelper;
020: import com.xoetrope.builder.pojo.PojoFormBuilderDndHelper;
021: import com.xoetrope.carousel.langed.LanguageProjectListener;
022: import com.xoetrope.carousel.services.ProjectRouteManager;
023: import com.xoetrope.carousel.survey.SurveyProjectListener;
024: import com.xoetrope.carousel.visualizer.VisualiserProjectListener;
025: import com.xoetrope.data.DataSourceLoader;
026: import com.xoetrope.editor.lm.XuiProLicenseManager;
027:
028: /**
029: * The activator class controls the plug-in life cycle
030: */
031: public class XuiProActivator extends AbstractUIPlugin {
032: // The shared instance
033: private static XuiProActivator plugin;
034:
035: /**
036: * The constructor
037: */
038: public XuiProActivator() {
039: if (plugin == null) {
040: plugin = this ;
041:
042: EditorUtility eu = new EditorUtility();
043: PageDesigner.setEditorUtility(eu, false);
044: XPageResource.setEditorUtility(eu, false);
045: XEditorProjectManager.setEditorUtility(eu, true);
046: XEditorProjectManager
047: .setLicenseManager(new XuiProLicenseManager());
048:
049: try {
050: String lafName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
051: UIManager.setLookAndFeel(lafName);
052: } catch (Exception e) {
053: System.err.println("Can't set look & feel:" + e);
054: }
055: }
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
062: */
063: public void start(BundleContext context) throws Exception {
064: super .start(context);
065: restored();
066: }
067:
068: /*
069: * (non-Javadoc)
070: *
071: * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
072: */
073: public void stop(BundleContext context) throws Exception {
074: plugin = null;
075: super .stop(context);
076: }
077:
078: /**
079: * Returns the shared instance
080: *
081: * @return the shared instance
082: */
083: public static XuiProActivator getDefault() {
084: return plugin;
085: }
086:
087: /**
088: * Returns an image descriptor for the image file at the given plug-in
089: * relative path
090: *
091: * @param path
092: * the path
093: * @return the image descriptor
094: */
095: public static ImageDescriptor getImageDescriptor(String path) {
096: return AbstractUIPlugin.imageDescriptorFromPlugin("XuiPro",
097: path);
098: }
099:
100: public void restored() {
101: SwingUtilities.invokeLater(new Runnable() {
102: public void run() {
103: if (XEditorProjectManager.isUserRegistered("XUI Pro")) {
104: XEditorProjectManager.resetProject("XuiPro");
105: XEditorProjectManager.setClassLoader("XuiPro",
106: getClass().getClassLoader());
107: if (XEditorProjectManager
108: .isUserRegistered("XUI Pro Widgets")) {
109: URL url = getClass()
110: .getClassLoader()
111: .getResource(
112: "com/xoetrope/carousel/resources/xuiProComponents.xml");
113: XEditorRegisteredComponentFactory
114: .addConfigFile("XuiPro", url, true);
115: }
116: if (XEditorProjectManager
117: .isUserRegistered("XUI Pro SVG Widgets")) {
118: URL url2 = getClass()
119: .getClassLoader()
120: .getResource(
121: "com/xoetrope/carousel/resources/svgComponents.xml");
122: XEditorRegisteredComponentFactory
123: .addConfigFile("Svg", url2, true);
124: }
125: XEditorProjectManager
126: .setDefaultClassLoader(getClass()
127: .getClassLoader());
128: XEditorProjectManager.addProjectListener(
129: "XuiProProjectCheck",
130: new XuiProProjectCheck(), true);
131:
132: XEditorProjectManager.addProjectListener(
133: "RouteManager", ProjectRouteManager
134: .getInstance(), true);
135: XEditorProjectManager.addProjectListener(
136: "LanguageManager",
137: new LanguageProjectListener(), true);
138: XEditorProjectManager.addProjectListener(
139: "SurveyManager",
140: new SurveyProjectListener(), true);
141: XEditorProjectManager.addProjectListener(
142: "ModelVisualiser",
143: new VisualiserProjectListener(), true);
144: XEditorProjectManager.addProjectListener(
145: "DataSourceLoader", new DataSourceLoader(),
146: true);
147:
148: PageDesignerTransferHandler
149: .addDndHelper(new PojoFormBuilderDndHelper());
150: PageDesignerTransferHandler
151: .addDndHelper(new DatabaseFormBuilderDndHelper());
152: }
153: }
154: });
155: }
156: }
|