[inhouse]Add ExtensionPoint in Connections,
authorhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 22 Jul 2011 13:59:13 +0000 (22:59 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 22 Jul 2011 13:59:13 +0000 (22:59 +0900)
Connect Connections to PackageDialog

com.samsung.ide.connection/plugin.xml
com.samsung.ide.connection/schema/actionForConnections.exsd [new file with mode: 0644]
com.samsung.ide.connection/src/com/samsung/ide/connection/IExtensionPointAction.java [new file with mode: 0644]
com.samsung.ide.connection/src/com/samsung/ide/connection/ui/DeviceView.java

index 6c634df..a9986f3 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
+   <extension-point id="actionForConnections" name="actionForConnections" schema="schema/actionForConnections.exsd"/>
 <!-- connection start -->
   <extension
          point="org.eclipse.ui.menus">
diff --git a/com.samsung.ide.connection/schema/actionForConnections.exsd b/com.samsung.ide.connection/schema/actionForConnections.exsd
new file mode 100644 (file)
index 0000000..64c2902
--- /dev/null
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.samsung.ide.connection" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="com.samsung.ide.connection" id="actionForConnections" name="actionForConnections"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="actionForConnections"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="actionForConnections">
+      <complexType>
+         <attribute name="action" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":com.samsung.ide.connection.IEXTTEST"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/com.samsung.ide.connection/src/com/samsung/ide/connection/IExtensionPointAction.java b/com.samsung.ide.connection/src/com/samsung/ide/connection/IExtensionPointAction.java
new file mode 100644 (file)
index 0000000..87cb18a
--- /dev/null
@@ -0,0 +1,10 @@
+package com.samsung.ide.connection;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Shell;
+
+public interface IExtensionPointAction {
+       ImageDescriptor getImageDescriptor();
+       String getActionText();
+       void createDialog(Shell shell);
+}
index d8a1000..35b7fa3 100644 (file)
@@ -1,10 +1,17 @@
 package com.samsung.ide.connection.ui;\r
 \r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
 import java.util.concurrent.CopyOnWriteArrayList;\r
 \r
 import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.core.commands.IHandler;\r
+import org.eclipse.core.runtime.CoreException;\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.ListenerList;\r
+import org.eclipse.core.runtime.Platform;\r
 import org.eclipse.jface.action.Action;\r
 import org.eclipse.jface.action.IToolBarManager;\r
 import org.eclipse.jface.viewers.ArrayContentProvider;\r
@@ -17,12 +24,14 @@ import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.swt.widgets.Table;\r
 import org.eclipse.swt.widgets.TableColumn;\r
 import org.eclipse.ui.IActionBars;\r
 import org.eclipse.ui.part.ViewPart;\r
 \r
 import com.samsung.ide.connection.FreshConnectionActivator;\r
+import com.samsung.ide.connection.IExtensionPointAction;\r
 import com.samsung.ide.connection.device.Device;\r
 import com.samsung.ide.connection.device.DeviceLauncherManager;\r
 import com.samsung.ide.connection.device.DeviceManager;\r
@@ -38,6 +47,7 @@ public class DeviceView extends ViewPart {
        private TableViewer Connections;\r
        private Action startAction;\r
        private Action stopAction;\r
+       private Action pkgAction = null;\r
        private ImageLoader loader;\r
        \r
        ListenerList listeners = new ListenerList();\r
@@ -116,7 +126,6 @@ public class DeviceView extends ViewPart {
                                try {\r
                                        startHandler.execute(null);\r
                                } catch (ExecutionException e) {\r
-                                       // TODO Auto-generated catch block\r
                                        e.printStackTrace();\r
                                }\r
                        }\r
@@ -129,13 +138,28 @@ public class DeviceView extends ViewPart {
                                try {\r
                                        stopHandler.execute(null);\r
                                } catch (ExecutionException e) {\r
-                                       // TODO Auto-generated catch block\r
                                        e.printStackTrace();\r
                                }\r
                        }\r
                };\r
                stopAction.setImageDescriptor(loader.loadDescriptor("Emulator_stop.gif"));\r
                stopAction.setEnabled(false);\r
+               \r
+               final IExtensionPointAction extAction = externalAction();\r
+               if ( extAction != null )\r
+               {\r
+                       pkgAction = new Action(extAction.getActionText()){\r
+                               public void run(){\r
+                                       Shell shell = new Shell();\r
+                                       shell.setLocation(200, 200);\r
+                                       shell.setSize(600, 400);\r
+                                       extAction.createDialog(shell);\r
+                               }\r
+\r
+                       };\r
+                       pkgAction.setImageDescriptor(extAction.getImageDescriptor());\r
+                       pkgAction.setEnabled(true);\r
+               }\r
                placeActions();\r
        }\r
        \r
@@ -273,6 +297,11 @@ public class DeviceView extends ViewPart {
                startAction.setEnabled(true);\r
                toolBarManager.add(stopAction);\r
                stopAction.setEnabled(false);\r
+               if(pkgAction != null)\r
+               {\r
+                       toolBarManager.add(pkgAction);          \r
+                       pkgAction.setEnabled(true);\r
+                       }\r
            }\r
 \r
        \r
@@ -280,4 +309,36 @@ public class DeviceView extends ViewPart {
        public void setFocus() {\r
                Connections.getControl().setFocus();\r
        }\r
+       \r
+    public IExtensionPointAction externalAction()\r
+    {\r
+       IExtensionPointAction action = null;\r
+       if( action == null ) {\r
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()\r
+                       .getExtensionPoint(FreshConnectionActivator.PLUGIN_ID, "actionForConnections");\r
+               \r
+               action = null;\r
+                       if (extensionPoint != null) {\r
+                               IExtension[] extensions = extensionPoint.getExtensions();\r
+                               if( extensions.length == 0)\r
+                                       return null;\r
+                               for (IExtension ex : extensions) {\r
+                                       IConfigurationElement[] configElements = ex.getConfigurationElements();\r
+                                       for(int i=0;i<configElements.length;i++){\r
+                                               if(configElements[i].getName().equals("actionForConnections")){\r
+                                                       try {\r
+                                                               action = (IExtensionPointAction)(configElements[i].createExecutableExtension("action"));\r
+                                                       } catch (CoreException e) {\r
+                                                               e.printStackTrace();\r
+                                                       }\r
+                                                                                               \r
+                                                       if(action!=null)\r
+                                                               break;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       return action;\r
+    }\r
 }\r