Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbench 1499 #1500

Merged
merged 2 commits into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Shared
Bundle-SymbolicName: org.csstudio.utility.product;singleton:=true
Bundle-Version: 1.2.2.qualifier
Bundle-Version: 1.3.0.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>org.csstudio.utility.product</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public class StartupParameters implements StartupParametersExtPoint
/** Parameter tag defines the shared link. The value is stored in the returned map. */
public static final String SHARE_LINK_PARAM = "css.shareLink"; //$NON-NLS-1$

/** Command-line switch to install workbench.xmi */
private static final String WORKBENCH_XMI = "-workbench_xmi"; //$NON-NLS-1$

/** Parameter tag for WORKBENCH_XMI. Map value contains path to workbench.xmi. */
public static final String WORKBENCH_XMI_PARAM = "css.workbench.xmi"; //$NON-NLS-1$

/** {@inheritDoc} */
@SuppressWarnings("nls")
@Override
Expand Down Expand Up @@ -122,6 +128,29 @@ else if (arg.equalsIgnoreCase(WORKSPACE_PROMPT))
}
}
}
else if (arg.equalsIgnoreCase(WORKBENCH_XMI))
{
String template = null;
if ((i + 1) < args.length)
{
final String next = args[i+1];
if (!next.startsWith("-")) //$NON-NLS-1$
{
template = next;
++i;
}
}
if (template != null)
parameters.put(WORKBENCH_XMI_PARAM, template);
else
{
System.out.println("Error: Missing /path/to/workspace.xmi"); //$NON-NLS-1$
showHelp();
// Exit ASAP, see comment below.
parameters.put(EXIT_CODE, IApplication.EXIT_OK);
System.exit(0);
}
}
else if (arg.equalsIgnoreCase(SHARE_LINK))
{
if ((i + 1) < args.length)
Expand Down Expand Up @@ -240,6 +269,8 @@ private void showHelp()
WORKSPACE_PROMPT);
System.out.format(" %-40s : Present workspace dialog with given default\n",
WORKSPACE_PROMPT + " /some/workspace");
System.out.format(" %-40s : Initialize workbench.xmi with a given template\n",
WORKBENCH_XMI + " /path/to/workbench.xmi");
System.out.format(" %-40s : Log all messages to the console\n",
"-consoleLog");
System.out.format(" %-40s : Select workspace on command-line, no prompt\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.csstudio.platform.workspace.WorkspaceIndependentStore;
import org.csstudio.platform.workspace.WorkspaceInfo;
Expand Down Expand Up @@ -68,6 +72,29 @@ public Object promptForWorkspace(Display display,
//Platform.endSplash();
return IApplication.EXIT_OK;
}

o = parameters.get(StartupParameters.WORKBENCH_XMI_PARAM);
if (o != null)
{ // Install predefined workbench.xmi
final File template = new File((String)o);
try
{ // Another way to get the workbench.xmi location,
// but depends on hardcoded knowledge of ".metadata/.plugins":
// ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi");
final URL uri = Platform.getInstanceLocation().getDataArea("org.eclipse.e4.workbench/workbench.xmi");
final File file = new File(uri.getFile());
if (! file.isAbsolute())
throw new Exception("Cannot obtain absolute workbench.xmi location, got " + file);
Files.createDirectories(file.toPath().getParent());
Files.copy(template.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
catch (Exception ex)
{
Logger.getLogger(getClass().getName())
.log(Level.SEVERE, "Cannot install workbench.xmi template " + template, ex);
}
}

return null;
}

Expand Down