org.eclipse.jdt.ui;bundle-version="3.4.2"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Argeo
+Bundle-ActivationPolicy: lazy
package org.argeo.slc.ide.ui;\r
\r
+import java.net.URL;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.resource.ImageRegistry;\r
+import org.eclipse.swt.graphics.Image;\r
import org.eclipse.ui.plugin.AbstractUIPlugin;\r
import org.osgi.framework.BundleContext;\r
\r
return plugin;\r
}\r
\r
+ public Image getImage(String relativeURL) {\r
+ ImageRegistry imageRegistry = getImageRegistry();\r
+ Image image = imageRegistry.get(relativeURL);\r
+ if (image == null) {\r
+ URL imageURL = getBundle().getEntry(relativeURL);\r
+ ImageDescriptor descriptor = ImageDescriptor\r
+ .createFromURL(imageURL);\r
+ image = descriptor.createImage();\r
+ imageRegistry.put(relativeURL, image);\r
+ }\r
+ return image;\r
+ }\r
}\r
String defaultProgArgs = configuration.getAttribute(
IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
"");
- configuration.setAttribute(
- OsgiLauncherConstants.ATTR_DEFAULT_PROGRAM_ARGS,
- defaultProgArgs);
+ // configuration.setAttribute(
+ // OsgiLauncherConstants.ATTR_DEFAULT_PROGRAM_ARGS,
+ // defaultProgArgs);
+ configuration.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ findWorkingDirectory());
OsgiLaunchHelper.updateLaunchConfiguration(configuration,
- bundlesToStart, systemPropertiesToAppend,
- findWorkingDirectory(), null);
+ bundlesToStart, systemPropertiesToAppend, null);
} catch (CoreException e) {
Shell shell = Display.getCurrent().getActiveShell();
ErrorDialog.openError(shell, "Error",
package org.argeo.slc.ide.ui.launch.osgi;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration;
-import org.eclipse.pde.ui.launcher.OSGiLaunchShortcut;
-import org.eclipse.swt.widgets.Display;
public class OsgiBootEquinoxLaunchConfiguration extends
EquinoxLaunchConfiguration {
protected void preLaunchCheck(ILaunchConfiguration configuration,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
// System.out.println("Launching... " + launch);
- IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
-
- Properties properties = null;
- try {
- properties = OsgiLaunchHelper.readProperties(propertiesFile);
- } catch (CoreException e) {
- ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- "Error", "Cannot execute launch shortcut", e.getStatus());
- return;
- }
-
- List<String> bundlesToStart = new ArrayList<String>();
- Map<String, String> systemPropertiesToAppend = new HashMap<String, String>();
- OsgiLaunchHelper.interpretProperties(properties, bundlesToStart,
- systemPropertiesToAppend);
-
- File workingDir = getWorkingDirectory(configuration);
-
ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
-
- // Reinitialize using standard OSGi launch shortcut
- // Kind of a hack but it lacks extension capabilities and it is still
- // cleaner than forking the code (which would imply a lot of fork indeed
- // because of all the internal classes)
- new OSGiLaunchShortcut() {
- @Override
- public void initializeConfiguration(
- ILaunchConfigurationWorkingCopy configuration) {
- // TODO Auto-generated method stub
- super.initializeConfiguration(configuration);
- }
- }.initializeConfiguration(wc);
-
- OsgiLaunchHelper.updateLaunchConfiguration(wc, bundlesToStart,
- systemPropertiesToAppend, null, new File(workingDir, "data")
- .getAbsolutePath());
+ OsgiLaunchHelper.updateLaunchConfiguration(wc);
wc.doSave();
-
super.preLaunchCheck(configuration, launch, monitor);
// Note that if a Java project contains a build.properties it has to
package org.argeo.slc.ide.ui.launch.osgi;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
-import java.util.Properties;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
+import org.eclipse.pde.ui.launcher.OSGiLaunchShortcut;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
-public class OsgiBootLaunchShortcut extends AbstractOsgiLaunchShortcut {
+public class OsgiBootLaunchShortcut extends OSGiLaunchShortcut implements
+ OsgiLauncherConstants {
+ protected StringBuffer name = null;
protected IFile propertiesFile = null;
+ protected List<String> bundlesToStart = new ArrayList<String>();
+ protected Map<String, String> systemPropertiesToAppend = new HashMap<String, String>();
@Override
protected String getLaunchConfigurationTypeName() {
name = new StringBuffer(extractName(propertiesFile));
- Properties properties = null;
- try {
- properties = OsgiLaunchHelper.readProperties(propertiesFile);
- } catch (CoreException e) {
- ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- "Error", "Cannot execute launch shortcut", e.getStatus());
- return;
- }
-
- OsgiLaunchHelper.interpretProperties(properties, bundlesToStart,
- systemPropertiesToAppend);
+ // Properties properties = null;
+ // try {
+ // properties = OsgiLaunchHelper.readProperties(propertiesFile);
+ // } catch (CoreException e) {
+ // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ // "Error", "Cannot execute launch shortcut", e.getStatus());
+ // return;
+ // }
+ //
+ // OsgiLaunchHelper.interpretProperties(properties, bundlesToStart,
+ // systemPropertiesToAppend);
super.launch(selection, mode);
-
- propertiesFile = null;
+ // name = null;
+ // bundlesToStart.clear();
+ // systemPropertiesToAppend.clear();
+ //
+ // propertiesFile = null;
}
@Override
IResource[] resources = { propertiesFile };
configuration.setMappedResources(resources);
super.initializeConfiguration(configuration);
+
+ try {
+ configuration.setAttribute(ATTR_ADD_JVM_PATHS, false);
+ configuration.setAttribute(ATTR_ADDITIONAL_VM_ARGS, "-Xmx128m");
+ configuration
+ .setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS, "-console");
+
+ // Defaults
+ String originalVmArgs = configuration.getAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
+ configuration.setAttribute(ATTR_DEFAULT_VM_ARGS, originalVmArgs);
+ configuration.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA,
+ true);
+
+ configuration.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ findWorkingDirectory());
+
+ OsgiLaunchHelper.updateLaunchConfiguration(configuration);
+ } catch (CoreException e) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ ErrorDialog.openError(shell, "Error",
+ "Cannot execute initalize configuration", e.getStatus());
+ }
}
- @Override
protected String findWorkingDirectory() {
try {
- // String relPath = "exec/" + extractName(propertiesFile);
-
IProject project = propertiesFile.getProject();
IPath parent = propertiesFile.getProjectRelativePath()
.removeLastSegments(1);
extractName(propertiesFile)));
if (!launchFolder.exists())
launchFolder.create(true, true, null);
-
- // IPath execDirPath = propertiesFile.getFullPath()
- // .removeLastSegments(1).append(relPath);
- // File baseDir = propertiesFile.getRawLocation().toFile()
- // .getParentFile();
- // File execDir = new File(baseDir.getCanonicalPath()
- // + File.separatorChar
- // + relPath.replace('/', File.separatorChar));
- // File execDir = execDirPath.toFile();
- // execDir.mkdirs();
- // return "${workspace_loc:" + execDirPath.toString().substring(1)
- // + "}";
return "${workspace_loc:"
+ launchFolder.getFullPath().toString().substring(1) + "}";
} catch (Exception e) {
return pathNoExt.segment(pathNoExt.segmentCount() - 1);
}
+
+ protected String getName(ILaunchConfigurationType type) {
+ if (name != null && !name.toString().trim().equals(""))
+ return name.toString();
+ else
+ return "SLC";
+ }
+
+ @Override
+ protected boolean isGoodMatch(ILaunchConfiguration configuration) {
+ if (name != null) {
+ return name.toString().equals(configuration.getName());
+ }
+ return super.isGoodMatch(configuration);
+ }
+
}
package org.argeo.slc.ide.ui.launch.osgi;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
import org.eclipse.pde.ui.launcher.BundlesTab;
import org.eclipse.pde.ui.launcher.OSGiLauncherTabGroup;
import org.eclipse.pde.ui.launcher.OSGiSettingsTab;
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new JavaArgumentsTab(), new EnvironmentTab(), new BundlesTab(),
- new OSGiSettingsTab(), new TracingTab(), new CommonTab() };
+ new OsgiBootMainTab(), new EnvironmentTab(), new BundlesTab() {
+ private boolean activating = false;
+
+ @Override
+ public void performApply(
+ ILaunchConfigurationWorkingCopy config) {
+ System.out.println("performApply");
+ super.performApply(config);
+ if (activating) {
+ try {
+ config.doSave();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ activating = false;
+ }
+ }
+
+ @Override
+ public void activated(
+ ILaunchConfigurationWorkingCopy workingCopy) {
+ activating = true;
+ }
+ }, new OSGiSettingsTab(), new TracingTab(), new CommonTab() };
setTabs(tabs);
}
--- /dev/null
+package org.argeo.slc.ide.ui.launch.osgi;
+
+import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class OsgiBootMainTab extends AbstractLaunchConfigurationTab implements
+ OsgiLauncherConstants {
+ private Listener listener = new Listener();
+ private Button addJvmPaths;
+ private Text additionalVmArgs;
+
+ private Text additionalProgramArgs;
+
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+ createAdditionalProgramArgs(container);
+ createAdditionalVmArgumentBlock(container);
+ Dialog.applyDialogFont(container);
+ setControl(container);
+ }
+
+ protected void createAdditionalProgramArgs(Composite parent) {
+ Group container = new Group(parent, SWT.NONE);
+ container.setText("Additional Program Arguments");
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ additionalProgramArgs = new Text(container, SWT.MULTI | SWT.WRAP
+ | SWT.BORDER | SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 60;
+ gd.widthHint = 100;
+ gd.horizontalSpan = 2;
+ additionalProgramArgs.setLayoutData(gd);
+ additionalProgramArgs.addModifyListener(listener);
+ }
+
+ protected void createAdditionalVmArgumentBlock(Composite parent) {
+ Group container = new Group(parent, SWT.NONE);
+ container.setText("Additional VM Arguments");
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ additionalVmArgs = new Text(container, SWT.MULTI | SWT.WRAP
+ | SWT.BORDER | SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 60;
+ gd.widthHint = 100;
+ gd.horizontalSpan = 2;
+ additionalVmArgs.setLayoutData(gd);
+ additionalVmArgs.addModifyListener(listener);
+
+ addJvmPaths = new Button(container, SWT.CHECK);
+ addJvmPaths.addSelectionListener(listener);
+ new Label(container, SWT.NONE)
+ .setText("Add workspace JVM paths as non-standard system properties");
+
+ }
+
+ public String getName() {
+ return "OSGi Boot";
+ }
+
+ @Override
+ public Image getImage() {
+ return SlcIdeUiPlugin.getDefault().getImage("icons/slc-launch.gif");
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ // System.out.println("initializeFrom");
+ try {
+ additionalProgramArgs.setText(configuration.getAttribute(
+ ATTR_ADDITIONAL_PROGRAM_ARGS, ""));
+ addJvmPaths.setSelection(configuration.getAttribute(
+ ATTR_ADD_JVM_PATHS, false));
+ additionalVmArgs.setText(configuration.getAttribute(
+ ATTR_ADDITIONAL_VM_ARGS, ""));
+ // readProperties(configuration);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // System.out.println("performApply");
+ configuration.setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS,
+ additionalProgramArgs.getText());
+ configuration.setAttribute(ATTR_ADDITIONAL_VM_ARGS, additionalVmArgs
+ .getText());
+ configuration.setAttribute(ATTR_ADD_JVM_PATHS, addJvmPaths
+ .getSelection());
+ // writeProperties(configuration);
+
+ OsgiLaunchHelper.updateLaunchConfiguration(configuration);
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ // System.out.println("setDefaults");
+ configuration.setAttribute(ATTR_ADD_JVM_PATHS, false);
+ configuration.setAttribute(ATTR_ADDITIONAL_VM_ARGS, "-Xmx128m");
+ configuration.setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS, "-console");
+ }
+
+ @Override
+ public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
+ initializeFrom(workingCopy);
+ try {
+ workingCopy.doSave();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
+ // do nothing
+ }
+
+ class Listener extends SelectionAdapter implements ModifyListener {
+ public void widgetSelected(SelectionEvent e) {
+ // Object source = e.getSource();
+ // setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+
+ public void modifyText(ModifyEvent e) {
+ // System.out.println("modifyText : " + e);
+ // setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ // private void readProperties(ILaunchConfiguration configuration) {
+ // BufferedReader reader = null;
+ // try {
+ // IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
+ // propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
+ // reader = new BufferedReader(new InputStreamReader(propertiesFile
+ // .getContents()));
+ // String line = null;
+ // StringBuffer buf = new StringBuffer("");
+ // while ((line = reader.readLine()) != null) {
+ // buf.append(line);
+ // buf.append("\n");
+ // }
+ // propertiesText.setText(buf.toString());
+ // } catch (CoreException e) {
+ // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ // "Error", "Cannot read properties", e.getStatus());
+ // return;
+ // } catch (Exception e) {
+ // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ // "Error", "Cannot read properties",
+ // new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
+ // e.getMessage(), e));
+ // return;
+ // } finally {
+ // if (reader != null)
+ // try {
+ // reader.close();
+ // } catch (IOException e) {
+ // // silent
+ // }
+ // }
+ //
+ // }
+ //
+ // private void writeProperties(ILaunchConfiguration configuration) {
+ // InputStream in = null;
+ // IFile propertiesFile = null;
+ // try {
+ // propertiesFile = (IFile) configuration.getMappedResources()[0];
+ // in = new ByteArrayInputStream(propertiesText.getText().getBytes());
+ // propertiesFile.setContents(in, true, true, null);
+ // propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
+ // } catch (CoreException e) {
+ // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ // "Error", "Cannot write properties", e.getStatus());
+ // return;
+ // } catch (Exception e) {
+ // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ // "Error", "Cannot write properties",
+ // new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
+ // e.getMessage(), e));
+ // return;
+ // } finally {
+ // if (in != null)
+ // try {
+ // in.close();
+ // } catch (IOException e) {
+ // // silent
+ // }
+ // }
+ //
+ // }
+
+}
package org.argeo.slc.ide.ui.launch.osgi;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstall2;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
+import org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer;
+import org.eclipse.swt.widgets.Display;
-public class OsgiLaunchHelper {
+public class OsgiLaunchHelper implements OsgiLauncherConstants {
private static Boolean debug = false;
+ /** Expect properties file to be set as mapped resources */
+ public static void updateLaunchConfiguration(
+ ILaunchConfigurationWorkingCopy configuration) {
+ try {
+ IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
+
+ Properties properties = OsgiLaunchHelper
+ .readProperties(propertiesFile);
+
+ List<String> bundlesToStart = new ArrayList<String>();
+ Map<String, String> systemPropertiesToAppend = new HashMap<String, String>();
+ OsgiLaunchHelper.interpretProperties(properties, bundlesToStart,
+ systemPropertiesToAppend);
+
+ // Reinitialize using standard OSGi launch shortcut
+ // Kind of a hack but it lacks extension capabilities and it is
+ // still
+ // cleaner than forking the code (which would imply a lot of fork
+ // indeed
+ // because of all the internal classes)
+ // new OSGiLaunchShortcut() {
+ // @Override
+ // public void initializeConfiguration(
+ // ILaunchConfigurationWorkingCopy configuration) {
+ // // TODO Auto-generated method stub
+ // super.initializeConfiguration(configuration);
+ // }
+ // }.initializeConfiguration(configuration);
+
+ // initializeConfiguration(configuration);
+
+ File workingDir = getWorkingDirectory(configuration);
+ File dataDir = new File(workingDir, "data");
+
+ OsgiLaunchHelper.updateLaunchConfiguration(configuration,
+ bundlesToStart, systemPropertiesToAppend, dataDir
+ .getAbsolutePath());
+ } catch (Exception e) {
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),
+ "Error", "Cannot read properties",
+ new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
+ e.getMessage(), e));
+ return;
+ }
+ }
+
public static void updateLaunchConfiguration(
ILaunchConfigurationWorkingCopy configuration,
List<String> bundlesToStart,
- Map<String, String> systemPropertiesToAppend, String workingDir,
- String dataDir) throws CoreException {
+ Map<String, String> systemPropertiesToAppend, String dataDir)
+ throws CoreException {
// Convert bundle lists
String targetBundles = configuration.getAttribute(
IPDELauncherConstants.TARGET_BUNDLES, "");
// Update other default information
configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START,
false);
- configuration.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA,
- true);
String defaultVmArgs = configuration.getAttribute(
OsgiLauncherConstants.ATTR_DEFAULT_VM_ARGS, "");
StringBuffer vmArgs = new StringBuffer(defaultVmArgs);
- vmArgs.append(" -Xmx256m");
+ vmArgs.append(" "
+ + configuration.getAttribute(ATTR_ADDITIONAL_VM_ARGS, ""));
// Add locations of JVMs
- addVmSysProperty(vmArgs, "default", JavaRuntime.getDefaultVMInstall());
- IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
- for (IVMInstallType vmType : vmTypes) {
- for (IVMInstall vmInstall : vmType.getVMInstalls()) {
- // printVm("", vmInstall);
- // properties based on name
- addVmSysProperty(vmArgs, vmInstall.getName(), vmInstall);
- if (vmInstall instanceof IVMInstall2) {
- // properties based on version
- IVMInstall2 vmInstall2 = (IVMInstall2) vmInstall;
- String version = vmInstall2.getJavaVersion();
- addVmSysProperty(vmArgs, version, vmInstall);
-
- List<String> tokens = new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(version, ".");
- while (st.hasMoreTokens())
- tokens.add(st.nextToken());
- if (tokens.size() >= 2)
- addVmSysProperty(vmArgs, tokens.get(0) + "."
- + tokens.get(1), vmInstall);
- }
- }
- }
+ if (configuration.getAttribute(ATTR_ADD_JVM_PATHS, false))
+ addVms(vmArgs);
// Add other system properties
for (String key : systemPropertiesToAppend.keySet())
.toString());
// Program arguments
- String defaultProgArgs = configuration.getAttribute(
- OsgiLauncherConstants.ATTR_DEFAULT_PROGRAM_ARGS, "");
- StringBuffer progArgs = new StringBuffer(defaultProgArgs);
+ StringBuffer progArgs = new StringBuffer(configuration.getAttribute(
+ OsgiLauncherConstants.ATTR_ADDITIONAL_PROGRAM_ARGS, ""));
if (dataDir != null) {
progArgs.append(" -data ");
progArgs.append(surroundSpaces(dataDir));
progArgs.toString());
// String dir = findWorkingDirectory();
- if (workingDir != null)
- configuration.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- workingDir);
+
+ }
+
+ protected static void addVms(StringBuffer vmArgs) {
+ addVmSysProperty(vmArgs, "default", JavaRuntime.getDefaultVMInstall());
+ IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
+ for (IVMInstallType vmType : vmTypes) {
+ for (IVMInstall vmInstall : vmType.getVMInstalls()) {
+ // printVm("", vmInstall);
+ // properties based on name
+ addVmSysProperty(vmArgs, vmInstall.getName(), vmInstall);
+ if (vmInstall instanceof IVMInstall2) {
+ // properties based on version
+ IVMInstall2 vmInstall2 = (IVMInstall2) vmInstall;
+ String version = vmInstall2.getJavaVersion();
+ addVmSysProperty(vmArgs, version, vmInstall);
+
+ List<String> tokens = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(version, ".");
+ while (st.hasMoreTokens())
+ tokens.add(st.nextToken());
+ if (tokens.size() >= 2)
+ addVmSysProperty(vmArgs, tokens.get(0) + "."
+ + tokens.get(1), vmInstall);
+ }
+ }
+ }
}
protected static void addSysProperty(StringBuffer vmArgs, String key,
String value) {
+ surroundSpaces(value);
String str = "-D" + key + "=" + value;
- surroundSpaces(str);
+ // surroundSpaces(str);
vmArgs.append(" " + str);
}
protected static String surroundSpaces(String str) {
- if (str.contains(" "))
- return "\"" + str + "\"";
+ if (str.indexOf(' ') >= 0)
+ return '\"' + str + '\"';
else
return str;
}
while (st.hasMoreTokens())
bundlesToStart.add(st.nextToken());
}
-
+
propKeys: for (Object keyObj : properties.keySet()) {
String key = keyObj.toString();
if (OsgiLauncherConstants.ARGEO_OSGI_START.equals(key))
}
}
+
+ // Hacked from
+ // org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper.getWorkingDirectory(ILaunchConfiguration)
+ public static File getWorkingDirectory(ILaunchConfiguration configuration)
+ throws CoreException {
+ String working;
+ try {
+ working = configuration.getAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ new File(".").getCanonicalPath()); //$NON-NLS-1$
+ } catch (IOException e) {
+ working = "${workspace_loc}/../"; //$NON-NLS-1$
+ }
+ File dir = new File(getSubstitutedString(working));
+ if (!dir.exists())
+ dir.mkdirs();
+ return dir;
+ }
+
+ // Hacked from
+ // org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper.getSubstitutedString(String)
+ private static String getSubstitutedString(String text)
+ throws CoreException {
+ if (text == null)
+ return ""; //$NON-NLS-1$
+ IStringVariableManager mgr = VariablesPlugin.getDefault()
+ .getStringVariableManager();
+ return mgr.performStringSubstitution(text);
+ }
+
+ static void initializeConfiguration(
+ ILaunchConfigurationWorkingCopy configuration) {
+ new OSGiLaunchConfigurationInitializer().initialize(configuration);
+ }
+
}
public final static String ARGEO_OSGI_DATA_DIR = "argeo.osgi.data.dir";
public final static String OSGI_BUNDLES = "osgi.bundles";
public final static String VMS_PROPERTY_PREFIX = "slc.launch.vm";
+ // public final static String ATTR_DEFAULT_PROGRAM_ARGS = SlcIdeUiPlugin.ID
+ // + ".defaultProgramArgs";
+
+ // Configuration
public final static String ATTR_DEFAULT_VM_ARGS = SlcIdeUiPlugin.ID
+ ".defaultVmArgs";
- public final static String ATTR_DEFAULT_PROGRAM_ARGS = SlcIdeUiPlugin.ID
- + ".defaultProgramArgs";
-
+ public final static String ATTR_ADDITIONAL_PROGRAM_ARGS = SlcIdeUiPlugin.ID
+ + ".additionalProgramArgs";
+ public final static String ATTR_ADDITIONAL_VM_ARGS = SlcIdeUiPlugin.ID
+ + ".additionalVmArgs";
+ public final static String ATTR_ADD_JVM_PATHS = SlcIdeUiPlugin.ID
+ + ".addJvmPaths";
+ public final static String ATTR_DATADIR = SlcIdeUiPlugin.ID + ".dataDir";
}