Enable launch of "Run in OSGi" command on local workspaces
authorBruno Sinou <bsinou@argeo.org>
Wed, 5 Mar 2014 14:25:10 +0000 (14:25 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 5 Mar 2014 14:25:10 +0000 (14:25 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6874 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
plugins/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/plugin.xml
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java

index dba791e79cba6ed42f3736e13d3cbafb6eafc5ab..f6bb0b6d75b47a5d66b200910d34da57ce8189f3 100644 (file)
                <property name="keyring" ref="keyring" />
        </bean>
 
+       <!-- ADVANCED -->
+       <bean id="runInOsgi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
+               scope="prototype">
+               <property name="repository" ref="javaRepository" />
+       </bean>
+
+
        <!-- LEGACY -->
        <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
                class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor"
                        value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor" />
        </bean>
 
-       <bean id="runInOSGi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
-               scope="prototype">
-               <property name="repository" ref="javaRepository" />
-               <property name="workspace" value="org.argeo.tp-1.4.x" />
-       </bean>
-
        <bean id="refreshDistributionsView"
                class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
                scope="prototype">
diff --git a/plugins/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif b/plugins/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif
new file mode 100644 (file)
index 0000000..2df4b45
Binary files /dev/null and b/plugins/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif differ
index f905e139b29d5c93049bfe2566cea6575f018593..9fa7e8b8ed1d020e87b676b505cf8dffc04ce8e6 100644 (file)
             name="Advanced">
        </command>
                <command
-            id="org.argeo.slc.client.ui.dist.runInOSGi"
+            id="org.argeo.slc.client.ui.dist.runInOsgi"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Run in OSGi">
             <commandParameter
-                       id="workspace"
+                       id="workspaceName"
                        name="Workspace Name">
                        </commandParameter>
        </command>
                                label="Refresh"
                                tooltip="Force the full refresh of the distribution tree (close all open connections)">
                        </command>
-            <command
+            <!-- <command
                commandId="org.argeo.slc.client.ui.dist.runInOSGi"
                 icon="icons/showSize.gif"
                 label="Run in OSGi"
                 tooltip="Run in a spearate OSGi runtime">
             </command>
+            -->
                </menuContribution>
                <!-- Anonymous distribution view toolbar -->             
         <menuContribution
index e85f06eb73b4d81b90b5bf87bff9bdd298571550..238e819d009c3fbceb2f33393d9b7c58abbaa614 100644 (file)
@@ -53,17 +53,27 @@ import org.argeo.slc.jcr.SlcTypes;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.osgi.framework.Bundle;
 
 /** <b>UNDER DEVELOPMENT</b>. Download and prepare an OSGi runtime */
 public class RunInOsgi extends AbstractHandler implements SlcNames {
        private final static Log log = LogFactory.getLog(RunInOsgi.class);
 
+       public final static String ID = DistPlugin.ID + ".runInOsgi";
+       public final static String DEFAULT_LABEL = "Run in OSGi";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/runInOsgi.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+
+       /* DEPENDENCY INJECTION */
        private Repository repository;
-       private String workspace;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
 
+               String workspace = event.getParameter(PARAM_WORKSPACE_NAME);
+
                InputStream jarStream = null;
                OutputStream out = null;
                Writer writer = null;
@@ -216,9 +226,4 @@ public class RunInOsgi extends AbstractHandler implements SlcNames {
        public void setRepository(Repository repository) {
                this.repository = repository;
        }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
 }
index 09119524f5dea4aa817c6c6ef0f73d2929b56428..c365a833cedc3247d0f2584e78ec75060466934b 100644 (file)
@@ -37,6 +37,7 @@ import org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace;
 import org.argeo.slc.client.ui.dist.commands.PublishWorkspace;
 import org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView;
 import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
+import org.argeo.slc.client.ui.dist.commands.RunInOsgi;
 import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeComparer;
@@ -157,7 +158,7 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                // String targetRepoUri = null;
                                // Build conditions depending on element type
                                boolean isDistribElem = false, isRepoElem = false, isDistribGroupElem = false;
-                               boolean isHomeRepo = false, isReadOnly = true;
+                               boolean isLocal = false, isReadOnly = true;
 
                                RepoElem re = null;
 
@@ -167,10 +168,11 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                        isDistribElem = true;
                                        isReadOnly = de.isReadOnly();
                                        workspaceName = de.getWorkspaceName();
+                                       isLocal = de.inHome();
                                } else if (firstElement instanceof RepoElem) {
                                        re = (RepoElem) firstElement;
                                        isRepoElem = true;
-                                       isHomeRepo = re.inHome();
+                                       isLocal = re.inHome();
                                        isReadOnly = re.isReadOnly();
                                } else if (firstElement instanceof WkspGroupElem) {
                                        WkspGroupElem wge = (WkspGroupElem) firstElement;
@@ -220,14 +222,14 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                UnregisterRemoteRepo.ID,
                                                UnregisterRemoteRepo.DEFAULT_LABEL,
                                                UnregisterRemoteRepo.DEFAULT_ICON, isRepoElem
-                                                               && !isHomeRepo && singleElement, params);
+                                                               && !isLocal && singleElement, params);
 
                                // Fetch repository
                                params = new HashMap<String, String>();
                                params.put(Fetch.PARAM_TARGET_REPO_PATH, targetRepoPath);
                                CommandUtils.refreshParametrizedCommand(menuManager, window,
                                                Fetch.ID, Fetch.DEFAULT_LABEL, Fetch.DEFAULT_ICON,
-                                               isRepoElem && isHomeRepo && singleElement
+                                               isRepoElem && isLocal && singleElement
                                                                && !isReadOnly, params);
 
                                // Normalize workspace
@@ -292,6 +294,14 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                NormalizeDistribution.DEFAULT_ICON, isDistribElem
                                                                && singleElement && !isReadOnly, params);
 
+                               // Run in OSGi
+                               params = new HashMap<String, String>();
+                               params.put(RunInOsgi.PARAM_WORKSPACE_NAME, workspaceName);
+                               CommandUtils.refreshParametrizedCommand(submenu, window,
+                                               RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
+                                               RunInOsgi.DEFAULT_ICON, isDistribElem && singleElement
+                                                               && isLocal, params);
+
                                if (submenu.getSize() > 0)
                                        menuManager.add(submenu);