\r
import java.net.URL;\r
\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.debug.core.DebugEvent;\r
+import org.eclipse.debug.core.DebugPlugin;\r
+import org.eclipse.debug.core.IDebugEventSetListener;\r
+import org.eclipse.debug.core.ILaunch;\r
+import org.eclipse.debug.core.model.IProcess;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.jface.resource.ImageRegistry;\r
import org.eclipse.swt.graphics.Image;\r
public void start(BundleContext context) throws Exception {\r
super.start(context);\r
plugin = this;\r
+ DebugPlugin.getDefault()\r
+ .addDebugEventListener(new DebugEventListener());\r
}\r
\r
@Override\r
}\r
return image;\r
}\r
+\r
+ protected static class DebugEventListener implements IDebugEventSetListener {\r
+ public void handleDebugEvents(DebugEvent[] events) {\r
+ for (int i = 0; i < events.length; i++) {\r
+ DebugEvent event = events[i];\r
+ Object source = event.getSource();\r
+ if (source instanceof IProcess\r
+ && event.getKind() == DebugEvent.TERMINATE) {\r
+ IProcess process = (IProcess) source;\r
+ ILaunch launch = process.getLaunch();\r
+ if (launch != null) {\r
+ refreshOsgiBootLaunch(launch);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ protected void refreshOsgiBootLaunch(ILaunch launch) {\r
+ try {\r
+ IResource[] resources = launch.getLaunchConfiguration()\r
+ .getMappedResources();\r
+ if (resources.length > 0) {\r
+ IResource propertiesFile = resources[0];\r
+ propertiesFile.getParent().refreshLocal(\r
+ IResource.DEPTH_INFINITE, null);\r
+// System.out.println("Refreshed "\r
+// + propertiesFile.getParent());\r
+ }\r
+ } catch (CoreException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
}\r
.getAttribute(
IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
""));
- String defaultProgArgs = configuration.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- "");
- // configuration.setAttribute(
- // OsgiLauncherConstants.ATTR_DEFAULT_PROGRAM_ARGS,
- // defaultProgArgs);
+// String defaultProgArgs = configuration.getAttribute(
+// IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+// "");
+// configuration.setAttribute(
+// OsgiLauncherConstants.ATTR_DEFAULT_PROGRAM_ARGS,
+// defaultProgArgs);
configuration.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
super.launch(configuration, mode, launch, monitor);
-
- // TODO: add launch listener to be notified when is terminated and
- // refresh resources
-
- IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
+ // Refresh resources before launching
+ final IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
propertiesFile.getParent().refreshLocal(IResource.DEPTH_INFINITE,
monitor);
- // propertiesFile.getProject().refreshLocal(IResource.DEPTH_INFINITE,
- // monitor);
}
@Override
package org.argeo.slc.ide.ui.launch.osgi;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
-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.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
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>();
+ private StringBuffer name = null;
+ private IFile propertiesFile = null;
@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);
super.launch(selection, mode);
- // name = null;
- // bundlesToStart.clear();
- // systemPropertiesToAppend.clear();
- //
- // propertiesFile = null;
}
@Override
protected String getName(ILaunchConfigurationType type) {
if (name != null && !name.toString().trim().equals(""))
- return name.toString();
+ return DebugPlugin.getDefault().getLaunchManager()
+ .generateUniqueLaunchConfigurationNameFrom(name.toString());
else
- return "SLC";
+ return DebugPlugin.getDefault().getLaunchManager()
+ .generateUniqueLaunchConfigurationNameFrom("SLC");
}
@Override
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 OsgiBootMainTab(), new EnvironmentTab(), new BundlesTab() {
+ new OsgiBootMainTab(),
+ new BundlesTab() {
private boolean activating = false;
@Override
public void performApply(
ILaunchConfigurationWorkingCopy config) {
- System.out.println("performApply");
super.performApply(config);
if (activating) {
try {
ILaunchConfigurationWorkingCopy workingCopy) {
activating = true;
}
- }, new OSGiSettingsTab(), new TracingTab(), new CommonTab() };
+ }, new OSGiSettingsTab(), new EnvironmentTab(),
+ new JavaArgumentsTab() {
+ private boolean initializing = false;
+
+ @Override
+ public void performApply(
+ ILaunchConfigurationWorkingCopy configuration) {
+ if (initializing)
+ return;
+ initializing = true;
+ initializeFrom(configuration);
+ initializing = false;
+ }
+ }, new TracingTab(), new CommonTab() };
setTabs(tabs);
}
import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
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 implements OsgiLauncherConstants {
ILaunchConfigurationWorkingCopy configuration) {
try {
IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
+ propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
Properties properties = OsgiLaunchHelper
.readProperties(propertiesFile);
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");
}
}
- public static void updateLaunchConfiguration(
+ static void updateLaunchConfiguration(
ILaunchConfigurationWorkingCopy configuration,
List<String> bundlesToStart,
Map<String, String> systemPropertiesToAppend, String dataDir)
// Update other default information
configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START,
false);
+
+ // VM arguments (system properties)
String defaultVmArgs = configuration.getAttribute(
OsgiLauncherConstants.ATTR_DEFAULT_VM_ARGS, "");
StringBuffer vmArgs = new StringBuffer(defaultVmArgs);
- vmArgs.append(" "
- + configuration.getAttribute(ATTR_ADDITIONAL_VM_ARGS, ""));
+ // Data dir system property
+ if (dataDir != null)
+ addSysProperty(vmArgs, OsgiLauncherConstants.ARGEO_OSGI_DATA_DIR,
+ dataDir);
// Add locations of JVMs
if (configuration.getAttribute(ATTR_ADD_JVM_PATHS, false))
addVms(vmArgs);
for (String key : systemPropertiesToAppend.keySet())
addSysProperty(vmArgs, key, systemPropertiesToAppend.get(key));
- if (dataDir != null)
- addSysProperty(vmArgs, OsgiLauncherConstants.ARGEO_OSGI_DATA_DIR,
- dataDir);
+ vmArgs.append(" ").append(
+ configuration.getAttribute(ATTR_ADDITIONAL_VM_ARGS, ""));
configuration.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs
.toString());
// Program arguments
- StringBuffer progArgs = new StringBuffer(configuration.getAttribute(
- OsgiLauncherConstants.ATTR_ADDITIONAL_PROGRAM_ARGS, ""));
+ StringBuffer progArgs = new StringBuffer("");
if (dataDir != null) {
- progArgs.append(" -data ");
+ progArgs.append("-data ");
progArgs.append(surroundSpaces(dataDir));
}
+ String additionalProgramArgs = configuration.getAttribute(
+ OsgiLauncherConstants.ATTR_ADDITIONAL_PROGRAM_ARGS, "");
+ progArgs.append(' ').append(additionalProgramArgs);
configuration.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
progArgs.toString());
-
- // String dir = findWorkingDirectory();
-
}
protected static void addVms(StringBuffer vmArgs) {
surroundSpaces(value);
String str = "-D" + key + "=" + value;
// surroundSpaces(str);
- vmArgs.append(" " + str);
+ vmArgs.append(' ').append(str);
}
protected static String surroundSpaces(String str) {
return mgr.performStringSubstitution(text);
}
- static void initializeConfiguration(
- ILaunchConfigurationWorkingCopy configuration) {
- new OSGiLaunchConfigurationInitializer().initialize(configuration);
- }
+ // static void initializeConfiguration(
+ // ILaunchConfigurationWorkingCopy configuration) {
+ // new OSGiLaunchConfigurationInitializer().initialize(configuration);
+ // }
}