From: Bruno Sinou Date: Wed, 5 Mar 2014 14:25:10 +0000 (+0000) Subject: Enable launch of "Run in OSGi" command on local workspaces X-Git-Tag: argeo-slc-2.1.7~224 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=87c98c5b3e3f6c3ca4043d3d63086b0c1222eadb;p=gpl%2Fargeo-slc.git Enable launch of "Run in OSGi" command on local workspaces git-svn-id: https://svn.argeo.org/slc/trunk@6874 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml index dba791e79..f6bb0b6d7 100644 --- a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml +++ b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml @@ -91,6 +91,13 @@ + + + + + + - - - - - 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 index 000000000..2df4b45e7 Binary files /dev/null and b/plugins/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif differ diff --git a/plugins/org.argeo.slc.client.ui.dist/plugin.xml b/plugins/org.argeo.slc.client.ui.dist/plugin.xml index f905e139b..9fa7e8b8e 100644 --- a/plugins/org.argeo.slc.client.ui.dist/plugin.xml +++ b/plugins/org.argeo.slc.client.ui.dist/plugin.xml @@ -271,11 +271,11 @@ name="Advanced"> @@ -344,12 +344,13 @@ label="Refresh" tooltip="Force the full refresh of the distribution tree (close all open connections)"> - + --> UNDER DEVELOPMENT. 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; - } - } diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java index 09119524f..c365a833c 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java @@ -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(); 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(); + 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);