]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/workbench/PerspectiveBarsManager.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / PerspectiveBarsManager.java
index 968f4901df95b78d93b804f599758aeb61740d47..d7a4c547521f63d0e1285e206161a8ad1ed54fbe 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.ui.workbench;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.eclipse.core.runtime.IConfigurationElement;\r
-import org.eclipse.core.runtime.IExtension;\r
-import org.eclipse.core.runtime.IExtensionPoint;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;\r
-import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;\r
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;\r
-import org.eclipse.core.runtime.dynamichelpers.IFilter;\r
-import org.simantics.ui.internal.Activator;\r
-import org.simantics.utils.datastructures.MapList;\r
-\r
-public class PerspectiveBarsManager implements IExtensionChangeHandler {\r
-\r
-    private final static String                           NAMESPACE  = Activator.PLUGIN_ID;\r
-\r
-    private final static String                           EP_NAME    = "perspectiveBars";\r
-\r
-    private ExtensionTracker                              tracker;\r
-\r
-    private MapList<String, IPerspectiveBarsExtension> extensions = new MapList<String, IPerspectiveBarsExtension>();\r
-\r
-    private static PerspectiveBarsManager       INSTANCE;\r
-\r
-    public static synchronized PerspectiveBarsManager getInstance() {\r
-        if (INSTANCE == null)\r
-            INSTANCE = new PerspectiveBarsManager();\r
-        return INSTANCE;\r
-    }\r
-\r
-    public static synchronized void dispose() {\r
-        if (INSTANCE != null) {\r
-            INSTANCE.close();\r
-            INSTANCE = null;\r
-        }\r
-    }\r
-\r
-    private PerspectiveBarsManager() {\r
-        tracker = new ExtensionTracker();\r
-\r
-        // Cache defined actions\r
-        IExtensionPoint expt = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACE, EP_NAME);\r
-        loadExtensions(expt.getConfigurationElements());\r
-\r
-        // Start tracking for new and removed extensions\r
-        IFilter filter = ExtensionTracker.createExtensionPointFilter(expt);\r
-        tracker.registerHandler(this, filter);\r
-    }\r
-\r
-    private void close() {\r
-        tracker.close();\r
-        tracker = null;\r
-        extensions = new MapList<String, IPerspectiveBarsExtension>();\r
-    }\r
-\r
-    public synchronized List<IPerspectiveBarsExtension> getExtensions(String perspectiveId) {\r
-        List<IPerspectiveBarsExtension> exts = extensions.getValues(perspectiveId);\r
-        if (exts == null)\r
-            return Arrays.asList();\r
-        return Collections.unmodifiableList(exts);\r
-    }\r
-\r
-    private synchronized void loadExtensions(IConfigurationElement[] elements) {\r
-        for (IConfigurationElement el : elements) {\r
-            String perspectiveId = el.getAttribute("perspectiveId");\r
-            Boolean menuBar = toBoolean(el.getAttribute("menuBar"));\r
-            Boolean coolBar = toBoolean(el.getAttribute("coolBar"));\r
-            Boolean statusLine = toBoolean(el.getAttribute("statusLine"));\r
-            Boolean perspectiveBar = toBoolean(el.getAttribute("perspectiveBar"));\r
-            Boolean fastViewBar = toBoolean(el.getAttribute("fastViewBar"));\r
-            Boolean progressIndicator = toBoolean(el.getAttribute("progressIndicator"));\r
-\r
-            IPerspectiveBarsExtension ext = new IPerspectiveBarsExtension.Stub(perspectiveId,menuBar,coolBar,statusLine,perspectiveBar,fastViewBar,progressIndicator);\r
-\r
-            // Start tracking the new extension object, its removal will be notified of\r
-            // with removeExtension(extension, Object[]).\r
-            tracker.registerObject(el.getDeclaringExtension(), ext, IExtensionTracker.REF_STRONG);\r
-\r
-            extensions.add(perspectiveId, ext);\r
-        }\r
-    }\r
-    \r
-    private Boolean toBoolean(String s) {\r
-       if (s == null)\r
-               return null;\r
-       return Boolean.parseBoolean(s);\r
-    }\r
-\r
-    @Override\r
-    public void addExtension(IExtensionTracker tracker, IExtension extension) {\r
-        loadExtensions(extension.getConfigurationElements());\r
-    }\r
-\r
-    @Override\r
-    public synchronized void removeExtension(IExtension extension, Object[] objects) {\r
-        \r
-        for (Object o : objects) {\r
-            IPerspectiveBarsExtension ext = (IPerspectiveBarsExtension) o;\r
-            tracker.unregisterObject(extension, ext);\r
-            extensions.remove(ext.getPerspectiveId(), ext);\r
-        }\r
-\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.ui.workbench;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
+import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
+import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
+import org.eclipse.core.runtime.dynamichelpers.IFilter;
+import org.simantics.ui.internal.Activator;
+import org.simantics.utils.datastructures.MapList;
+
+public class PerspectiveBarsManager implements IExtensionChangeHandler {
+
+    private final static String                           NAMESPACE  = Activator.PLUGIN_ID;
+
+    private final static String                           EP_NAME    = "perspectiveBars";
+
+    private ExtensionTracker                              tracker;
+
+    private MapList<String, IPerspectiveBarsExtension> extensions = new MapList<String, IPerspectiveBarsExtension>();
+
+    private static PerspectiveBarsManager       INSTANCE;
+
+    public static synchronized PerspectiveBarsManager getInstance() {
+        if (INSTANCE == null)
+            INSTANCE = new PerspectiveBarsManager();
+        return INSTANCE;
+    }
+
+    public static synchronized void dispose() {
+        if (INSTANCE != null) {
+            INSTANCE.close();
+            INSTANCE = null;
+        }
+    }
+
+    private PerspectiveBarsManager() {
+        tracker = new ExtensionTracker();
+
+        // Cache defined actions
+        IExtensionPoint expt = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACE, EP_NAME);
+        loadExtensions(expt.getConfigurationElements());
+
+        // Start tracking for new and removed extensions
+        IFilter filter = ExtensionTracker.createExtensionPointFilter(expt);
+        tracker.registerHandler(this, filter);
+    }
+
+    private void close() {
+        tracker.close();
+        tracker = null;
+        extensions = new MapList<String, IPerspectiveBarsExtension>();
+    }
+
+    public synchronized List<IPerspectiveBarsExtension> getExtensions(String perspectiveId) {
+        List<IPerspectiveBarsExtension> exts = extensions.getValues(perspectiveId);
+        if (exts == null)
+            return Arrays.asList();
+        return Collections.unmodifiableList(exts);
+    }
+
+    private synchronized void loadExtensions(IConfigurationElement[] elements) {
+        for (IConfigurationElement el : elements) {
+            String perspectiveId = el.getAttribute("perspectiveId");
+            Boolean menuBar = toBoolean(el.getAttribute("menuBar"));
+            Boolean coolBar = toBoolean(el.getAttribute("coolBar"));
+            Boolean statusLine = toBoolean(el.getAttribute("statusLine"));
+            Boolean perspectiveBar = toBoolean(el.getAttribute("perspectiveBar"));
+            Boolean fastViewBar = toBoolean(el.getAttribute("fastViewBar"));
+            Boolean progressIndicator = toBoolean(el.getAttribute("progressIndicator"));
+
+            IPerspectiveBarsExtension ext = new IPerspectiveBarsExtension.Stub(perspectiveId,menuBar,coolBar,statusLine,perspectiveBar,fastViewBar,progressIndicator);
+
+            // Start tracking the new extension object, its removal will be notified of
+            // with removeExtension(extension, Object[]).
+            tracker.registerObject(el.getDeclaringExtension(), ext, IExtensionTracker.REF_STRONG);
+
+            extensions.add(perspectiveId, ext);
+        }
+    }
+    
+    private Boolean toBoolean(String s) {
+       if (s == null)
+               return null;
+       return Boolean.parseBoolean(s);
+    }
+
+    @Override
+    public void addExtension(IExtensionTracker tracker, IExtension extension) {
+        loadExtensions(extension.getConfigurationElements());
+    }
+
+    @Override
+    public synchronized void removeExtension(IExtension extension, Object[] objects) {
+        
+        for (Object o : objects) {
+            IPerspectiveBarsExtension ext = (IPerspectiveBarsExtension) o;
+            tracker.unregisterObject(extension, ext);
+            extensions.remove(ext.getPerspectiveId(), ext);
+        }
+
+    }
+
+}