Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java15
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java4
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties3
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java290
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java122
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java122
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties1
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java2
10 files changed, 298 insertions, 319 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
index 69814ff7f..8e428957d 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -285,10 +286,20 @@ public interface ILaunchConfiguration extends IAdaptable {
/**
* Returns the location of this launch configuration as a
- * path. This is a handle-only method.
+ * path in the local file system or <code>null</code> if it cannot
+ * be mapped to a location in the local file system. This is a handle-only method.
+ * <p>
+ * Since 3.5, this method can return <code>null</code>. For example, when a
+ * launch configuration is stored in the workspace as an {@link IFile} in
+ * an external file system ({@link EFS}).
+ * </p>
*
* @return the location of this launch configuration as a
- * path
+ * path file system or <code>null</code> if it cannot be mapped
+ * to a location in the local file system. Since 3.5, this method
+ * can return <code>null</code>.
+ * @deprecated Since a launch configuration does not need to be stored in the local
+ * file system, this attribute should no longer be used to identify a launch configuration.
*/
public IPath getLocation();
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
index a8ade0a81..892eaa155 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
@@ -43,13 +43,10 @@ public class DebugCoreMessages extends NLS {
public static String J9VMRunner_0;
public static String LaunchConfiguration_0;
- public static String LaunchConfiguration_1;
public static String LaunchConfiguration_11;
public static String LaunchConfiguration_13;
public static String LaunchConfiguration_14;
- public static String LaunchConfiguration_15;
-
public static String LaunchConfiguration_16;
public static String LaunchConfiguration_17;
@@ -119,7 +116,6 @@ public class DebugCoreMessages extends NLS {
public static String LaunchManager_Invalid_launch_configuration_index__18;
public static String LaunchManager_does_not_exist;
public static String LaunchManager_Source_locator_does_not_exist___0__13;
- public static String LaunchManager_30;
public static String LogicalStructureType_0;
public static String OutputStreamMonitor_label;
public static String ProcessMonitorJob_0;
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
index c169c7f0a..991822a85 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
@@ -37,12 +37,10 @@ LaunchConfiguration_5=Performing incremental workspace build...
LaunchConfiguration_4=Performing final launch validation...
LaunchConfiguration_3=Initializing source locator...
LaunchConfiguration_2=Launching delegate...
-LaunchConfiguration_1=Unable to restore location for launch configuration from memento: {0}
LaunchConfiguration_0=Launch configuration has corrupt resource mapping attributes
LaunchConfiguration_11=No launch delegate found - launch canceled
LaunchConfiguration_13=Duplicate launcher detected - launch canceled
LaunchConfiguration_14=Incompatible launch mode: expecting {0} instead of {1}
-LaunchConfiguration_15=Unable to generate memento for {0}, shared file does not exist.
LaunchConfiguration_16=Exception occurred creating launch configuration memento
LaunchConfiguration_17=Exception occurred parsing memento
LaunchConfiguration_18=Invalid launch configuration memento: missing path attribute
@@ -69,7 +67,6 @@ LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1={0} oc
LaunchManager_Invalid_launch_configuration_index__18=Invalid launch configuration index.
LaunchManager_does_not_exist=Launch configuration {0} at {1} does not exist.
LaunchManager_Source_locator_does_not_exist___0__13=Source locator does not exist: {0}
-LaunchManager_30=Unable to retrieve shared launch configuration file for {0}
LaunchManager_26=Import failed
LaunchManager_27=Failed to import {0}.
LaunchManager_28=Importing {0}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
index a3b4b2eb7..49e8d0f64 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
@@ -26,6 +26,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -126,19 +128,49 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
protected static final IStatus duplicateDelegates = new Status(IStatus.INFO, "org.eclipse.debug.core", 227, "", null); //$NON-NLS-1$//$NON-NLS-2$
/**
- * Location this configuration is stored in. This
- * is the key for a launch configuration handle.
+ * This configuration's name
*/
- private IPath fLocation;
+ private String fName;
+
+ /**
+ * The container this configuration is stored in or <code>null</code> if stored locally
+ * with workspace metadata.
+ */
+ private IContainer fContainer;
+
+ /**
+ * Constructs a launch configuration with the given name. The configuration
+ * is stored in the given container or locally with workspace metadata if
+ * the specified container is <code>null</code>.
+ *
+ * @param name launch configuration name
+ * @param container parent container or <code>null</code>
+ */
+ protected LaunchConfiguration(String name, IContainer container) {
+ setName(name);
+ setContainer(container);
+ }
/**
- * Constructs a launch configuration in the given location.
+ * Constructs a launch configuration on the given workspace file.
+ *
+ * @param file workspace .launch file
+ */
+ protected LaunchConfiguration(IFile file) {
+ this(getSimpleName(file.getName()), file.getParent());
+ }
+
+ /**
+ * Given a name that ends with .launch, return the simple name of the configuration.
*
- * @param location path to where this launch configuration's
- * underlying file is located
+ * @param fileName
+ * @return simple name
*/
- protected LaunchConfiguration(IPath location) {
- setLocation(location);
+ protected static String getSimpleName(String fileName) {
+ if (fileName.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION)) {
+ return fileName.substring(0, fileName.length() - ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.length() - 1);
+ }
+ return fileName;
}
/**
@@ -174,18 +206,16 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
throw new CoreException(s);
}
- IPath location = null;
+
boolean local = (Boolean.valueOf(localString)).booleanValue();
- if (local) {
- location = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append(path);
- } else {
- location = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)).getLocation();
- }
- setLocation(location);
- if (location == null) {
- IStatus s = newStatus(MessageFormat.format(DebugCoreMessages.LaunchConfiguration_1, new String[]{path}), DebugPlugin.ERROR, null);
- throw new CoreException(s);
+ IPath iPath = new Path(path);
+ String name = getSimpleName(iPath.lastSegment());
+ IContainer container = null;
+ if (!local) {
+ container = ResourcesPlugin.getWorkspace().getRoot().getFile(iPath).getParent();
}
+ setName(name);
+ setContainer(container);
return;
} catch (ParserConfigurationException e) {
ex = e;
@@ -207,7 +237,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
LaunchConfiguration otherConfig = (LaunchConfiguration) object;
return getName().equals(otherConfig.getName())
&& getType().equals(otherConfig.getType())
- && getLocation().equals(otherConfig.getLocation())
+ && equalOrNull(getContainer(), otherConfig.getContainer())
&& getInfo().equals(otherConfig.getInfo());
}
return false;
@@ -229,8 +259,10 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
*/
public void delete() throws CoreException {
if (exists()) {
- if (isLocal()) {
- if (!(getLocation().toFile().delete())) {
+ IFile file = getFile();
+ if (file == null) {
+ getFileStore().delete(EFS.NONE, null);
+ if ((getFileStore().fetchInfo().exists())) {
throw new DebugException(
new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, DebugCoreMessages.LaunchConfiguration_Failed_to_delete_launch_configuration__1, null)
@@ -240,21 +272,16 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
// will be no resource delta
getLaunchManager().launchConfigurationDeleted(this);
} else {
- // delete the resource using IFile API such that
+ // Delete the resource using IFile API such that
// resource deltas are fired.
- IFile file = getFile();
- if (file != null) {
- // validate edit
- if (file.isReadOnly()) {
- IStatus status = ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, null);
- if (!status.isOK()) {
- throw new CoreException(status);
- }
+ // First do validate edit to ensure the resource is local
+ if (file.isReadOnly()) {
+ IStatus status = ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, null);
+ if (!status.isOK()) {
+ throw new CoreException(status);
}
- file.delete(true, null);
- } else {
- // Error - the exists test passed, but could not locate file
}
+ file.delete(true, null);
}
}
}
@@ -274,23 +301,44 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
if (isWorkingCopy()) {
return this == object;
}
- ILaunchConfiguration config = (ILaunchConfiguration) object;
+ LaunchConfiguration config = (LaunchConfiguration) object;
if (!config.isWorkingCopy()) {
- return config.getLocation().equals(getLocation());
+ return getName().equals(config.getName()) &&
+ equalOrNull(getContainer(), config.getContainer());
}
}
return false;
}
+
+ /**
+ * Returns whether the given objects are equal or both <code>null</code>.
+ *
+ * @param o1
+ * @param o2
+ * @return whether the given objects are equal or both <code>null</code>
+ */
+ protected boolean equalOrNull(Object o1, Object o2) {
+ if (o1 == null) {
+ return o2 == null;
+ } else if (o2 != null) {
+ return o1.equals(o2);
+ }
+ return false;
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfiguration#exists()
*/
public boolean exists() {
- if (isLocal()) {
- return getLocation().toFile().exists();
- }
IFile file = getFile();
- return file != null && file.exists();
+ if (file != null) {
+ return file.exists();
+ }
+ try {
+ return getFileStore().fetchInfo().exists();
+ } catch (CoreException e) {
+ }
+ return false;
}
/* (non-Javadoc)
@@ -350,36 +398,29 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
return getType().getCategory();
}
- /**
- * Returns the container this launch configuration is
- * stored in, or <code>null</code> if this launch configuration
- * is stored locally.
- *
- * @return the container this launch configuration is
- * stored in, or <code>null</code> if this launch configuration
- * is stored locally
- */
- protected IContainer getContainer() {
- IFile file = getFile();
- if (file != null) {
- return file.getParent();
- }
- return null;
- }
-
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfiguration#getFile()
*/
public IFile getFile() {
- if (isLocal()) {
- return null;
- }
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(getLocation());
- if (files.length > 0) {
- return files[0];
+ IContainer container = getContainer();
+ if (container != null) {
+ return container.getFile(new Path(getFileName()));
}
return null;
}
+
+ /**
+ * Returns the simple file name of this launch configuration.
+ *
+ * @return the simple file name of this launch configuration - for example
+ * "Abc.launch"
+ */
+ protected String getFileName() {
+ StringBuffer buf = new StringBuffer(getName());
+ buf.append('.');
+ buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+ return buf.toString();
+ }
/**
* Returns the info object containing the attributes
@@ -392,18 +433,6 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
protected LaunchConfigurationInfo getInfo() throws CoreException {
return getLaunchManager().getInfo(this);
}
-
- /**
- * Returns the last segment from the location
- * @return the last segment from the location
- */
- private String getLastLocationSegment() {
- String name = getLocation().lastSegment();
- if (name.length() > LAUNCH_CONFIGURATION_FILE_EXTENSION.length()) {
- name = name.substring(0, name.length() - (LAUNCH_CONFIGURATION_FILE_EXTENSION.length() + 1));
- }
- return name;
- }
/**
* Returns the launch manager
@@ -418,7 +447,38 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @see org.eclipse.debug.core.ILaunchConfiguration#getLocation()
*/
public IPath getLocation() {
- return fLocation;
+ try {
+ IFileStore store = getFileStore();
+ if (store != null) {
+ File localFile = store.toLocalFile(EFS.CACHE, null);
+ if (localFile != null) {
+ if (store.fetchInfo().exists()) {
+ return new Path(localFile.getAbsolutePath());
+ } else {
+ // when it does not exist, toLocalFile(...) returns a bogus file
+ return new Path(store.toString());
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ /**
+ * Returns the file store this configuration is persisted in or <code>null</code> if
+ * a file store cannot be derived. The file may or may not exist. If this configuration
+ * is in a project that is closed or does not exist, <code>null</code> is returned.
+ *
+ * @return file store this configuration is persisted in or <code>null</code>
+ * @throws CoreException
+ */
+ public IFileStore getFileStore() throws CoreException {
+ if (isLocal()) {
+ return EFS.getLocalFileSystem().fromLocalFile(
+ LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append(getFileName()).toFile());
+ }
+ return EFS.getStore(getFile().getLocationURI());
}
/* (non-Javadoc)
@@ -477,18 +537,12 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
*/
public String getMemento() throws CoreException {
IPath relativePath = null;
- if (isLocal()) {
- IPath rootPath = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- IPath configPath = getLocation();
- relativePath = configPath.removeFirstSegments(rootPath.segmentCount());
- relativePath = relativePath.setDevice(null);
+ IFile file = getFile();
+ boolean local = true;
+ if (file == null) {
+ relativePath = new Path(getName());
} else {
- IFile file = getFile();
- if (file == null) {
- // cannot generate memento - missing file
- IStatus status = newStatus(MessageFormat.format(DebugCoreMessages.LaunchConfiguration_15, new String[]{getName()}), DebugException.INTERNAL_ERROR, null);
- throw new CoreException(status);
- }
+ local = false;
relativePath = file.getFullPath();
}
Exception e= null;
@@ -496,7 +550,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
Document doc = LaunchManager.getDocument();
Element node = doc.createElement(IConfigurationElementConstants.LAUNCH_CONFIGURATION);
doc.appendChild(node);
- node.setAttribute(IConfigurationElementConstants.LOCAL, (Boolean.valueOf(isLocal())).toString());
+ node.setAttribute(IConfigurationElementConstants.LOCAL, (Boolean.valueOf(local)).toString());
node.setAttribute(IConfigurationElementConstants.PATH, relativePath.toString());
return LaunchManager.serializeDocument(doc);
} catch (IOException ioe) {
@@ -514,8 +568,19 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @see org.eclipse.debug.core.ILaunchConfiguration#getName()
*/
public String getName() {
- return getLastLocationSegment();
+ return fName;
}
+
+ /**
+ * Returns the container this configuration is stored in, or <code>null</code>
+ * if this configuration is local.
+ *
+ * @return the container this configuration is stored in, or <code>null</code>
+ * if this configuration is local
+ */
+ protected IContainer getContainer() {
+ return fContainer;
+ }
public Set getModes() throws CoreException {
Set options = getAttribute(ATTR_LAUNCH_MODES, (Set)null);
@@ -540,7 +605,12 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return getLocation().hashCode();
+ IContainer container = getContainer();
+ if (container == null) {
+ return getName().hashCode();
+ } else {
+ return getName().hashCode() + container.hashCode();
+ }
}
/* (non-Javadoc)
@@ -582,8 +652,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @see org.eclipse.debug.core.ILaunchConfiguration#isLocal()
*/
public boolean isLocal() {
- IPath localPath = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- return localPath.isPrefixOf(getLocation());
+ return getContainer() == null;
}
/* (non-Javadoc)
@@ -800,16 +869,24 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
}
/**
- * Sets the location of this configuration's underlying
- * file.
+ * Sets the new name for this configuration.
*
- * @param location the location of this configuration's underlying
- * file
+ * @param name the new name for this configuration
*/
- private void setLocation(IPath location) {
- fLocation = location;
+ protected void setName(String name) {
+ fName = name;
}
-
+
+ /**
+ * Sets this configurations container or <code>null</code> if stored in the
+ * local metadata.
+ *
+ * @param container or <code>null</code>
+ */
+ protected void setContainer(IContainer container) {
+ fContainer = container;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfiguration#supportsMode(java.lang.String)
*/
@@ -821,19 +898,14 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @see org.eclipse.debug.core.ILaunchConfiguration#isReadOnly()
*/
public boolean isReadOnly() {
- if(!isLocal()) {
- IFile file = getFile();
- if(file != null) {
- return file.isReadOnly();
- }
- }
- else {
- File file = getLocation().toFile();
- if(file != null) {
- return file.exists() && !file.canWrite();
+ try {
+ IFileStore fileStore = getFileStore();
+ if (fileStore != null) {
+ return fileStore.fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY);
}
+ } catch (CoreException e) {
}
- return false;
+ return true;
}
/**
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
index 05d7b6b42..962cf670a 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
@@ -11,9 +11,8 @@
package org.eclipse.debug.internal.core;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -25,13 +24,14 @@ import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -73,12 +73,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* it was created
*/
private boolean fDirty = false;
-
- /**
- * The name for this configuration.
- */
- private String fName;
-
+
/**
* Indicates whether this working copy has been explicitly renamed.
*/
@@ -88,13 +83,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* Suppress change notification until created
*/
private boolean fSuppressChange = true;
-
- /**
- * The container this working copy will be
- * stored in when saved.
- */
- private IContainer fContainer;
-
+
/**
* Constructs a working copy of the specified launch
* configuration.
@@ -105,8 +94,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfiguration original) throws CoreException {
- super(original.getLocation());
- setName(original.getName());
+ super(original.getName(), original.getContainer());
copyFrom(original);
setOriginal(original);
fSuppressChange = false;
@@ -121,8 +109,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfigurationWorkingCopy parent) throws CoreException {
- super(parent.getLocation());
- setName(parent.getName());
+ super(parent.getName(), parent.getContainer());
copyFrom(parent);
setOriginal((LaunchConfiguration) parent.getOriginal());
fParent = parent;
@@ -141,9 +128,8 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfiguration original, String name) throws CoreException {
- super(original.getLocation());
+ super(name, original.getContainer());
copyFrom(original);
- setName(name);
fSuppressChange = false;
}
@@ -157,11 +143,9 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* @param type the type of this working copy
*/
protected LaunchConfigurationWorkingCopy(IContainer container, String name, ILaunchConfigurationType type) {
- super((IPath)null);
- setName(name);
+ super(name, container);
setInfo(new LaunchConfigurationInfo());
getInfo().setType(type);
- setContainer(container);
fSuppressChange = false;
}
@@ -232,7 +216,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
lmonitor.done();
}
}
- return new LaunchConfiguration(getLocation());
+ return new LaunchConfiguration(getName(), getContainer());
}
/**
@@ -245,7 +229,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
// set up from/to information if this is a move
boolean moved = (!isNew() && isMoved());
if (moved) {
- ILaunchConfiguration to = new LaunchConfiguration(getLocation());
+ ILaunchConfiguration to = new LaunchConfiguration(getName(), getContainer());
ILaunchConfiguration from = getOriginal();
getLaunchManager().setMovedFromTo(from, to);
}
@@ -298,17 +282,16 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
try {
boolean added = false;
lmonitor.subTask(DebugCoreMessages.LaunchConfigurationWorkingCopy_1);
- File file = getLocation().toFile();
- File dir = getLocation().removeLastSegments(1).toFile();
- dir.mkdirs();
- if (!file.exists()) {
+ IFileStore file = getFileStore();
+ IFileStore dir = file.getParent();
+ dir.mkdir(EFS.SHALLOW, null);
+ if (!file.fetchInfo().exists()) {
added = true;
- file.createNewFile();
updateMonitor(lmonitor, 1);
}
- FileOutputStream stream = null;
+ BufferedOutputStream stream = null;
try {
- stream = new FileOutputStream(file);
+ stream = new BufferedOutputStream(file.openOutputStream(EFS.NONE, null));
stream.write(xml.getBytes("UTF8")); //$NON-NLS-1$
}
finally {
@@ -317,9 +300,9 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
}
}
if (added) {
- getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getLocation()));
+ getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getName(), getContainer()));
} else {
- getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getLocation()));
+ getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getName(), getContainer()));
}
//notify file saved
updateMonitor(lmonitor, 1);
@@ -484,7 +467,6 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
private void copyFrom(LaunchConfiguration original) throws CoreException {
LaunchConfigurationInfo info = original.getInfo();
setInfo(info.getCopy());
- setContainer(original.getContainer());
fDirty = false;
}
@@ -587,52 +569,18 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
fRenamed = isNew() || !(getOriginal().getName().equals(name));
}
}
-
+
/**
* Sets the new name for this configuration.
*
* @param name the new name for this configuration
*/
- private void setName(String name) {
- fName = name;
+ protected void setName(String name) {
+ super.setName(name);
setDirty();
- }
-
- /**
- * @see ILaunchConfiguration#getName()
- */
- public String getName() {
- return fName;
- }
-
- /**
- * @see ILaunchConfiguration#isLocal()
- */
- public boolean isLocal() {
- return getContainer() == null;
}
/**
- * Returns the location this launch configuration will reside at
- * when saved.
- *
- * @see ILaunchConfiguration#getLocation()
- */
- public IPath getLocation() {
- if (isMoved()) {
- IPath path = null;
- if (isLocal()) {
- path = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- } else {
- path = getContainer().getLocation();
- }
- path = path.append(getName() + "." + LAUNCH_CONFIGURATION_FILE_EXTENSION); //$NON-NLS-1$
- return path;
- }
- return getOriginal().getLocation();
- }
-
- /**
* Returns whether this working copy is new, or is a
* working copy of another launch configuration.
*
@@ -686,36 +634,14 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* @see ILaunchConfigurationWorkingCopy#setContainer(IContainer)
*/
public void setContainer(IContainer container) {
- if (container == fContainer) {
+ if (equalOrNull(getContainer(), container)) {
return;
}
- if (container != null) {
- if (container.equals(fContainer)) {
- return;
- }
- } else {
- if (fContainer.equals(container)) {
- return;
- }
- }
- fContainer = container;
+ super.setContainer(container);
setDirty();
}
/**
- * Returns the container this working copy will be
- * stored in when saved, or <code>null</code> if
- * this working copy is local.
- *
- * @return the container this working copy will be
- * stored in when saved, or <code>null</code> if
- * this working copy is local
- */
- protected IContainer getContainer() {
- return fContainer;
- }
-
- /**
* @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setAttributes(java.util.Map)
*/
public void setAttributes(Map attributes) {
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index 0bf194120..612eb2bf0 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -49,6 +49,7 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -69,6 +70,7 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
@@ -321,38 +323,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* Visitor for handling resource deltas.
*/
class LaunchManagerVisitor implements IResourceDeltaVisitor {
-
- /**
- * Map of files to associated (shared) launch configurations in a project
- * that is going to be deleted.
- */
- private Map fFileToConfig = new HashMap();
-
-
- /**
- * Builds a cache of configurations that will be deleted in the given project
- *
- * @param project project that is going to be deleted
- */
- public void preDelete(IProject project) {
- List list = findLaunchConfigurations(project);
- Iterator configs = list.iterator();
- while (configs.hasNext()) {
- ILaunchConfiguration configuration = (ILaunchConfiguration) configs.next();
- IFile file = configuration.getFile();
- if (file != null) {
- fFileToConfig.put(file, configuration);
- }
- }
- }
-
- /**
- * Resets this resource delta visitor for a new pass.
- */
- public void reset() {
- fFileToConfig.clear();
- }
-
+
/**
* @see IResourceDeltaVisitor#visit(IResourceDelta)
*/
@@ -375,26 +346,17 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (resource instanceof IFile) {
IFile file = (IFile)resource;
if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(file.getFileExtension())) {
- IPath configPath = file.getLocation();
- ILaunchConfiguration handle = null;
- // If the file has already been deleted, reconstruct the handle from our cache
- if (configPath == null) {
- handle = (ILaunchConfiguration) fFileToConfig.get(file);
- } else {
- handle = new LaunchConfiguration(configPath);
- }
- if (handle != null) {
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- LaunchManager.this.launchConfigurationAdded(handle);
- break;
- case IResourceDelta.REMOVED :
- LaunchManager.this.launchConfigurationDeleted(handle);
- break;
- case IResourceDelta.CHANGED :
- LaunchManager.this.launchConfigurationChanged(handle);
- break;
- }
+ ILaunchConfiguration handle = new LaunchConfiguration(file);
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ LaunchManager.this.launchConfigurationAdded(handle);
+ break;
+ case IResourceDelta.REMOVED :
+ LaunchManager.this.launchConfigurationDeleted(handle);
+ break;
+ case IResourceDelta.CHANGED :
+ LaunchManager.this.launchConfigurationChanged(handle);
+ break;
}
}
return false;
@@ -977,10 +939,10 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
}
};
- String[] files = directory.list(filter);
+ File[] files = directory.listFiles(filter);
LaunchConfiguration config = null;
for (int i = 0; i < files.length; i++) {
- config = new LaunchConfiguration(containerPath.append(files[i]));
+ config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(files[i].getName()), null);
configs.add(config);
}
}
@@ -1319,23 +1281,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* the info object
* @exception DebugException if the config does not exist
*/
- protected LaunchConfigurationInfo getInfo(ILaunchConfiguration config) throws CoreException {
+ protected LaunchConfigurationInfo getInfo(LaunchConfiguration config) throws CoreException {
LaunchConfigurationInfo info = (LaunchConfigurationInfo)fLaunchConfigurations.get(config);
if (info == null) {
if (config.exists()) {
BufferedInputStream stream = null;
try {
- if (config.isLocal()) {
- IPath path = config.getLocation();
- File file = path.toFile();
- stream = new BufferedInputStream(new FileInputStream(file));
- } else {
- IFile file = ((LaunchConfiguration) config).getFile();
- if (file == null) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_30, new String[] {config.getName()}), null);
- }
- stream = new BufferedInputStream(file.getContents(true));
- }
+ stream = new BufferedInputStream(config.getFileStore().openInputStream(EFS.NONE, null));
info = createInfoFromXML(stream);
synchronized (this) {
fLaunchConfigurations.put(config, info);
@@ -1360,7 +1312,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
} else {
throw createDebugException(
- MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new String[]{config.getName(), config.getLocation().toOSString()}), null);
+ MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new String[]{config.getName(), config.getFileStore().toURI().toString()}), null);
}
}
return info;
@@ -1371,12 +1323,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
public ILaunchConfiguration getLaunchConfiguration(IFile file) {
hookResourceChangeListener();
- IPath location = file.getLocation();
- if (location != null) {
- return new LaunchConfiguration(location);
- }
- // bug 199294: avoid NPE, but return a bogus launch configuration that does not exist
- return new LaunchConfiguration(file.getFullPath());
+ return new LaunchConfiguration(file);
}
/**
@@ -2217,15 +2164,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
- if (delta == null) {
- // pre-delete
- LaunchManagerVisitor visitor = getDeltaVisitor();
- IResource resource = event.getResource();
- if (resource instanceof IProject) {
- IProject project = (IProject) resource;
- visitor.preDelete(project);
- }
- } else {
+ if (delta != null) {
LaunchManagerVisitor visitor = getDeltaVisitor();
MappedResourceVisitor v = null;
if (isDeleteConfigurations()) {
@@ -2239,7 +2178,6 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
} catch (CoreException e) {
DebugPlugin.log(e.getStatus());
}
- visitor.reset();
}
}
@@ -2398,9 +2336,14 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* Throws a debug exception with the given throwable that occurred
* while processing the given configuration.
*/
- private void throwException(ILaunchConfiguration config, Throwable e) throws DebugException {
- IPath path = config.getLocation();
- throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1, new String[]{e.toString(), path.toOSString()}), e);
+ private void throwException(LaunchConfiguration config, Throwable e) throws DebugException {
+ String uri = null;
+ try {
+ uri = config.getFileStore().toString();
+ } catch (CoreException ce) {
+ uri = config.getName();
+ }
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1, new String[]{e.toString(), uri}), e);
}
/**
@@ -2486,11 +2429,14 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
* (i.e. a shared configuration), the shared configuration is deleted (becomes local).
* </p>
* @param files files to import
- * @param monitor progress monitor
+ * @param monitor progress monitor or <code>null</code>
* @throws CoreException if an exception occurs while importing configurations
* @since 3.4.0
*/
public void importConfigurations(File[] files, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
Map sharedConfigs = new HashMap();
List stati = null;
Iterator iterator = getAllLaunchConfigurations().iterator();
@@ -2519,7 +2465,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
boolean added = !target.exists();
try {
copyFile(source, target);
- ILaunchConfiguration configuration = new LaunchConfiguration(location);
+ ILaunchConfiguration configuration = new LaunchConfiguration(LaunchConfiguration.getSimpleName(source.getName()), null);
ILaunchConfiguration shared = (ILaunchConfiguration) sharedConfigs.get(target.getName());
if (shared != null) {
setMovedFromTo(shared, configuration);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
index 1a4eff0fe..a9b56c6d7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
@@ -10,14 +10,21 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.importexport.launchconfigurations;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -304,7 +311,9 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
}
monitor.beginTask(WizardMessages.ExportLaunchConfigurationsWizardPage_10, configs.length);
try {
- File file = null, newfile = null;
+ List errors = null;
+ IFileStore file = null;
+ File newfile = null;
boolean owall = false, nowall = false;
MessageDialog dialog = null;
for(int i = 0; i < configs.length; i++) {
@@ -312,8 +321,8 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
return Status.CANCEL_STATUS;
}
if(configs[i] instanceof ILaunchConfiguration) {
- file = new File(((LaunchConfiguration) configs[i]).getLocation().toOSString());
try {
+ file = ((LaunchConfiguration) configs[i]).getFileStore();
newfile = new File(destpath.append(file.getName()).toOSString());
if(newfile.exists() & !overwrite) {
if(nowall) {
@@ -353,16 +362,36 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
else {
copyFile(file, newfile);
}
- }
- catch (Exception e) {
- DebugUIPlugin.logErrorMessage(e.getMessage());
+ }
+ catch (IOException e ) {
+ if (errors == null) {
+ errors = new ArrayList(configs.length);
+ }
+ errors.add(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(),
+ e.getMessage(), e));
+ }
+ catch (CoreException e) {
+ if (errors == null) {
+ errors = new ArrayList(configs.length);
+ }
+ errors.add(e.getStatus());
}
}
if(!monitor.isCanceled()) {
monitor.worked(1);
}
}
- return Status.OK_STATUS;
+ if (errors == null || errors.isEmpty()) {
+ return Status.OK_STATUS;
+ } else {
+ if (errors.size() == 1) {
+ return (IStatus)errors.get(0);
+ } else {
+ return new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), 0,
+ (IStatus[])errors.toArray(new IStatus[errors.size()]),
+ WizardMessages.ExportLaunchConfigurationsWizardPage_18, null);
+ }
+ }
}
finally {
monitor.done();
@@ -379,15 +408,15 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
* @param out the file to be copied out to
* @throws Exception
*/
- protected void copyFile(File in, File out) throws Exception {
- FileInputStream fis = new FileInputStream(in);
- FileOutputStream fos = new FileOutputStream(out);
+ protected void copyFile(IFileStore in, File out) throws CoreException, IOException {
+ BufferedInputStream is = new BufferedInputStream(in.openInputStream(EFS.NONE, null));
+ BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(out));
byte[] buf = new byte[1024];
int i = 0;
- while((i = fis.read(buf)) != -1) {
- fos.write(buf, 0, i);
+ while((i = is.read(buf)) != -1) {
+ os.write(buf, 0, i);
}
- fis.close();
- fos.close();
+ is.close();
+ os.close();
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java
index 605797019..c1a1113e7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java
@@ -25,6 +25,7 @@ public class WizardMessages extends NLS {
public static String ExportLaunchConfigurationsWizardPage_15;
public static String ExportLaunchConfigurationsWizardPage_16;
public static String ExportLaunchConfigurationsWizardPage_17;
+ public static String ExportLaunchConfigurationsWizardPage_18;
public static String ExportLaunchConfigurationsWizardPage_2;
public static String ExportLaunchConfigurationsWizardPage_3;
public static String ExportLaunchConfigurationsWizardPage_4;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties
index 2055ca1f1..79b942311 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties
@@ -19,6 +19,7 @@ ExportLaunchConfigurationsWizardPage_14=Yes to All
ExportLaunchConfigurationsWizardPage_15=No
ExportLaunchConfigurationsWizardPage_16=No to All
ExportLaunchConfigurationsWizardPage_17=Cancel
+ExportLaunchConfigurationsWizardPage_18=Launch configuration export failed
ExportLaunchConfigurationsWizardPage_2=Specified export location is not a directory
ExportLaunchConfigurationsWizardPage_3=&Launch Configurations:
ExportLaunchConfigurationsWizardPage_4=Location:
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
index 9f4ec4d3d..3667db81c 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
@@ -220,7 +220,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta
if (shell == null) {
return;
}
- IStatus status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_Exists, new String[]{config.getLocation().toOSString()}), null);
+ IStatus status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_Exists, new String[]{config.getName()}), null);
ErrorDialog.openError(getShell(), ExternalToolsUIMessages.BuilderPropertyPage_errorTitle,
NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2, new String[]{config.getName()}),
status);

Back to the top