Fix single sourcing issue on file download
authorBruno Sinou <bsinou@argeo.org>
Wed, 14 May 2014 14:13:46 +0000 (14:13 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 14 May 2014 14:13:46 +0000 (14:13 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6981 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.rap/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFile.java
plugins/org.argeo.slc.client.rap/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java [new file with mode: 0644]
plugins/org.argeo.slc.client.rcp/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFile.java
plugins/org.argeo.slc.client.rcp/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java

index 48a0d82979020b8c0338cd7c478cbca1b4d2b6fc..6c971c11941048363b042a131214d610410883b8 100644 (file)
@@ -43,10 +43,10 @@ import org.eclipse.ui.PlatformUI;
  * 2)
  */
 public class OpenJcrFile extends AbstractHandler {
-       // private final static Log log = LogFactory.getLog(OpenJcrFile.class);
-
-       public final static String ID = SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
 
+       // Use (new OpenJcrFileCmdId()).getCmdId() instead.
+       // public final String ID = SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
+       
        public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
        public final static String PARAM_REPO_URI = "param.repoUri";
        public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
diff --git a/plugins/org.argeo.slc.client.rap/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java b/plugins/org.argeo.slc.client.rap/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java
new file mode 100644 (file)
index 0000000..a4e0d83
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.client.ui.specific;
+
+import org.argeo.slc.client.rap.SlcRapPlugin;
+
+/**
+ * Workaround a single sourcing problem:
+ * 
+ * final static variable are imported at compilation time (we build against RCP)
+ * and we still must have a different ID (the prefix must be the PLUGIN ID) for
+ * RAP and RCP in order to be able to inject beans in the corresponding commands 
+ */
+public class OpenJcrFileCmdId {
+
+       public String getCmdId() {
+               return SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
+       }
+}
index e2fc880dd7933554ace97b21abaedc6def317820..5c73a60bde3179081a397801a7368dda62f25651 100644 (file)
@@ -31,7 +31,6 @@ import javax.jcr.nodetype.NodeType;
 import org.apache.commons.io.IOUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
-import org.argeo.slc.client.rcp.SlcRcpPlugin;
 import org.argeo.slc.repo.RepoService;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -45,8 +44,8 @@ public class OpenJcrFile extends AbstractHandler {
        // private final static Log log = LogFactory.getLog(OpenJcrFile.class);
 
        // Here is the trick that enable single sourcing: the ID is determined at
-       // runtime. ALWAYS use this public variable to call the command.
-       public final static String ID = SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
+       // runtime so use (new OpenJcrFileCmdId()).getCmdId() instead of the usual
+       // public final String ID = SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
 
        public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
        public final static String PARAM_REPO_URI = "param.repoUri";
diff --git a/plugins/org.argeo.slc.client.rcp/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java b/plugins/org.argeo.slc.client.rcp/src/main/java/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java
new file mode 100644 (file)
index 0000000..fb0ad74
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.client.ui.specific;
+
+import org.argeo.slc.client.rcp.SlcRcpPlugin;
+
+/**
+ * Workaround a single sourcing problem:
+ * 
+ * final static variable are imported at compilation time (we build against RCP)
+ * and we still must have a different ID (the prefix must be the PLUGIN ID) for
+ * RAP and RCP in order to be able to inject beans in the corresponding commands
+ */
+public class OpenJcrFileCmdId {
+
+       public String getCmdId() {
+               return SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
+       }
+}
index bcf6070cbfecbf12c79902ea066bdf5b5770452d..b48b66b12f121f1f66b53285361a001453744432 100644 (file)
@@ -22,12 +22,15 @@ import java.util.Map;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoException;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.utils.AbstractHyperlinkListener;
 import org.argeo.slc.client.ui.specific.OpenJcrFile;
+import org.argeo.slc.client.ui.specific.OpenJcrFileCmdId;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
@@ -55,6 +58,7 @@ import org.eclipse.ui.forms.widgets.Section;
  * Show the details for a given bundle.
  */
 public class BundleDetailPage extends FormPage implements SlcNames {
+       private final static Log log = LogFactory.getLog(BundleDetailPage.class);
 
        final static String PAGE_ID = "BundleDetailPage";
 
@@ -253,7 +257,9 @@ public class BundleDetailPage extends FormPage implements SlcNames {
                Label label = tk.createLabel(parent, "Pom", SWT.RIGHT);
                label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
 
-               String name = bundle.getName().substring(0, bundle.getName().length() - "jar".length()) + "pom";
+               String name = bundle.getName().substring(0,
+                               bundle.getName().length() - "jar".length())
+                               + "pom";
 
                if (bundle.getParent().hasNode(name)) {
                        Node pom = bundle.getParent().getNode(name);
@@ -397,7 +403,11 @@ public class BundleDetailPage extends FormPage implements SlcNames {
                                params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
                                                editorInput.getWorkspaceName());
                                params.put(OpenJcrFile.PARAM_FILE_PATH, path);
-                               CommandUtils.callCommand(OpenJcrFile.ID, params);
+
+                               String cmdId = (new OpenJcrFileCmdId()).getCmdId();
+                               if (log.isTraceEnabled())
+                                       log.debug("Retrieved openFile Cmd ID: " + cmdId);
+                               CommandUtils.callCommand(cmdId, params);
                        } catch (Exception ex) {
                                throw new SlcException("error opening browser", ex); //$NON-NLS-1$
                        }