mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Flexible File System. Get project creation working by replacing the use of IPath for project location with URIs. Also move FFS to its own plugin to avoid early initialization of the CDT.
This commit is contained in:
parent
0d50d5b222
commit
e8019df504
10 changed files with 62 additions and 452 deletions
|
@ -46,7 +46,6 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.internal.core.dom.parser.c;x-friends:="org.eclipse.cdt.refactoring",
|
||||
org.eclipse.cdt.internal.core.dom.parser.cpp;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.refactoring",
|
||||
org.eclipse.cdt.internal.core.envvar,
|
||||
org.eclipse.cdt.internal.core.ffs;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.index;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.index.provider,
|
||||
org.eclipse.cdt.internal.core.language,
|
||||
|
|
|
@ -704,14 +704,5 @@
|
|||
<simple name="appName"/>
|
||||
</processType>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.filesystem.filesystems">
|
||||
<filesystem
|
||||
scheme="ecproj">
|
||||
<run
|
||||
class="org.eclipse.cdt.internal.core.ffs.FFSFileSystem">
|
||||
</run>
|
||||
</filesystem>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.ffs;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Contents of the ecproj file.
|
||||
*/
|
||||
public class FFSEcprojFile {
|
||||
|
||||
private final URI uri;
|
||||
private final IFileStore root;
|
||||
private final FFSFileSystem fileSystem;
|
||||
|
||||
public FFSEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
|
||||
this.uri = uri;
|
||||
this.fileSystem = fileSystem;
|
||||
this.root = EFS.getStore(uri);
|
||||
}
|
||||
|
||||
public FFSFileSystem getFileSystem() {
|
||||
return fileSystem;
|
||||
}
|
||||
|
||||
public IFileStore getRoot() {
|
||||
return new FFSFileStore(this, null, root);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.ffs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.filesystem.IFileSystem;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class FFSFileStore implements org.eclipse.core.filesystem.IFileStore {
|
||||
|
||||
private final IFileStore target;
|
||||
private final IFileStore parent;
|
||||
private final FFSEcprojFile ecprojFile;
|
||||
|
||||
public FFSFileStore(FFSEcprojFile ecprojFile, IFileStore parent, IFileStore target) {
|
||||
this.ecprojFile = ecprojFile;
|
||||
this.parent = parent;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.childInfos(options, monitor);
|
||||
}
|
||||
|
||||
public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
|
||||
// TODO child handling
|
||||
return target.childNames(options, monitor);
|
||||
}
|
||||
|
||||
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
|
||||
IFileStore[] targetChildren = target.childStores(options, monitor);
|
||||
IFileStore[] children = new IFileStore[targetChildren.length];
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
children[i] = new FFSFileStore(ecprojFile, this, targetChildren[i]);
|
||||
return children;
|
||||
}
|
||||
|
||||
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
|
||||
target.copy(destination, options, monitor);
|
||||
}
|
||||
|
||||
public void delete(int options, IProgressMonitor monitor) throws CoreException {
|
||||
target.delete(options, monitor);
|
||||
}
|
||||
|
||||
public IFileInfo fetchInfo() {
|
||||
return target.fetchInfo();
|
||||
}
|
||||
|
||||
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.fetchInfo(options, monitor);
|
||||
}
|
||||
|
||||
public IFileStore getChild(IPath path) {
|
||||
IFileStore store = getChild(path.segment(0));
|
||||
if (store == null)
|
||||
return null;
|
||||
return store.getChild(path.removeFirstSegments(1));
|
||||
}
|
||||
|
||||
public IFileStore getChild(String name) {
|
||||
// TODO child handling
|
||||
return target.getChild(name);
|
||||
}
|
||||
|
||||
public IFileSystem getFileSystem() {
|
||||
return ecprojFile.getFileSystem();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return target.getName();
|
||||
}
|
||||
|
||||
public IFileStore getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isParentOf(IFileStore other) {
|
||||
if (other == null || !(other instanceof FFSFileStore))
|
||||
return false;
|
||||
|
||||
if (other.equals(this))
|
||||
return true;
|
||||
|
||||
return isParentOf(other.getParent());
|
||||
}
|
||||
|
||||
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.mkdir(options, monitor);
|
||||
}
|
||||
|
||||
public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
|
||||
// TODO what happens if destination is a different target file system?
|
||||
target.move(destination, options, monitor);
|
||||
}
|
||||
|
||||
public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.openInputStream(options, monitor);
|
||||
}
|
||||
|
||||
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.openOutputStream(options, monitor);
|
||||
}
|
||||
|
||||
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
|
||||
target.putInfo(info, options, monitor);
|
||||
}
|
||||
|
||||
public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException {
|
||||
return target.toLocalFile(options, monitor);
|
||||
}
|
||||
|
||||
public URI toURI() {
|
||||
// TODO
|
||||
// need base URI from file system
|
||||
// then add in the child path as the query
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IFileStore.class || adapter == FFSFileStore.class)
|
||||
return this;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof FFSFileStore)
|
||||
return target.equals(((FFSFileStore)obj).target);
|
||||
else
|
||||
return target.equals(obj);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.ffs;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.filesystem.IFileTree;
|
||||
import org.eclipse.core.filesystem.provider.FileSystem;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* This is the flexible file system. It allows you to add and exclude
|
||||
* entries from from a given directory.
|
||||
*
|
||||
* The URI's for this system are as follows:
|
||||
*
|
||||
* ecproj:///<ecproj file location>?<logical path>#<ecproj file schema>
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ecproj:///c:/Eclipse/workspace/s?.project
|
||||
*
|
||||
*/
|
||||
public class FFSFileSystem extends FileSystem {
|
||||
|
||||
private Map<URI, FFSEcprojFile> ecprojFiles = new HashMap<URI, FFSEcprojFile>();
|
||||
|
||||
private synchronized FFSEcprojFile getEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
|
||||
uri.normalize();
|
||||
FFSEcprojFile ecprojFile = ecprojFiles.get(uri);
|
||||
if (ecprojFile == null) {
|
||||
ecprojFile = new FFSEcprojFile(fileSystem, uri);
|
||||
ecprojFiles.put(uri, ecprojFile);
|
||||
}
|
||||
return ecprojFile;
|
||||
}
|
||||
|
||||
public IFileStore getStore(URI uri) {
|
||||
try {
|
||||
String ecprojScheme = uri.getFragment();
|
||||
if (ecprojScheme == null)
|
||||
ecprojScheme = EFS.SCHEME_FILE;
|
||||
|
||||
URI ecprojURI = new URI(ecprojScheme, uri.getAuthority(), uri.getPath(), null, null);
|
||||
FFSEcprojFile ecprojFile = getEcprojFile(this, ecprojURI);
|
||||
|
||||
IFileStore root = ecprojFile.getRoot();
|
||||
String pathStr = uri.getQuery();
|
||||
if (pathStr == null)
|
||||
return root;
|
||||
IPath path = new Path(pathStr);
|
||||
if (path.segmentCount() == 0)
|
||||
return root;
|
||||
return root.getChild(path);
|
||||
} catch (URISyntaxException e) {
|
||||
CCorePlugin.log(e);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
||||
return EFS.getNullFileSystem().getStore(uri);
|
||||
}
|
||||
|
||||
public int attributes() {
|
||||
// TODO what attributes should we support?
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean canDelete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canWrite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public IFileTree fetchFileTree(IFileStore root, IProgressMonitor monitor) {
|
||||
try {
|
||||
// TODO obviously
|
||||
return EFS.getNullFileSystem().fetchFileTree(root, monitor);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IFileStore fromLocalFile(File file) {
|
||||
return EFS.getLocalFileSystem().fromLocalFile(file);
|
||||
}
|
||||
|
||||
public IFileStore getStore(IPath path) {
|
||||
return EFS.getLocalFileSystem().getStore(path);
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive() {
|
||||
return EFS.getLocalFileSystem().isCaseSensitive();
|
||||
}
|
||||
|
||||
}
|
|
@ -2400,13 +2400,5 @@
|
|||
id="org.eclipse.cdt.ui.provider1">
|
||||
</provider>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.ide.filesystemSupport">
|
||||
<filesystemContributor
|
||||
class="org.eclipse.cdt.internal.ui.ffs.FFSFileSystemContributor"
|
||||
label="Flexible File System"
|
||||
scheme="ecproj">
|
||||
</filesystemContributor>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.ffs;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
|
||||
|
||||
import org.eclipse.cdt.internal.core.ffs.FFSFileSystem;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class FFSFileSystemContributor extends FileSystemContributor {
|
||||
|
||||
public URI getURI(String string) {
|
||||
try {
|
||||
return new URI(string);
|
||||
} catch (URISyntaxException e) {
|
||||
return super.getURI(string);
|
||||
}
|
||||
}
|
||||
|
||||
public URI browseFileSystem(String initialPath, Shell shell) {
|
||||
DirectoryDialog dialog = new DirectoryDialog(shell);
|
||||
dialog.setMessage("Select Project Location");
|
||||
|
||||
if (!initialPath.equals("")) { //$NON-NLS-1$
|
||||
IFileInfo info = EFS.getLocalFileSystem().getStore(new Path(initialPath)).fetchInfo();
|
||||
if (info != null && info.exists()) {
|
||||
dialog.setFilterPath(initialPath);
|
||||
}
|
||||
}
|
||||
|
||||
String selectedDirectory = dialog.open();
|
||||
if (selectedDirectory == null) {
|
||||
return null;
|
||||
}
|
||||
URI rootURI = new File(selectedDirectory).toURI();
|
||||
try {
|
||||
return new URI("ecproj", rootURI.getAuthority(), rootURI.getPath(), null, rootURI.getScheme());
|
||||
} catch (URISyntaxException e) {
|
||||
return rootURI;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -12,11 +12,14 @@
|
|||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -27,7 +30,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
|
@ -61,7 +63,7 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
|
||||
private boolean existingPath = false;
|
||||
private String lastProjectName = null;
|
||||
private IPath lastProjectLocation = null;
|
||||
private URI lastProjectLocation = null;
|
||||
private CWizardHandler savedHandler = null;
|
||||
|
||||
protected List localPages = new ArrayList(); // replacing Wizard.pages since we have to delete them
|
||||
|
@ -96,7 +98,7 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
if (!fMainPage.getProjectName().equals(lastProjectName))
|
||||
return true;
|
||||
|
||||
IPath projectLocation = fMainPage.getProjectLocation();
|
||||
URI projectLocation = fMainPage.getProjectLocation();
|
||||
if (projectLocation == null) {
|
||||
if (lastProjectLocation != null)
|
||||
return true;
|
||||
|
@ -115,23 +117,29 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
clearProject();
|
||||
if (newProject == null) {
|
||||
existingPath = false;
|
||||
IPath p = fMainPage.getProjectLocation();
|
||||
if (p == null) {
|
||||
p = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||
p = p.append(fMainPage.getProjectName());
|
||||
}
|
||||
File f = p.toFile();
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
if (p.append(".project").toFile().exists()) { //$NON-NLS-1$
|
||||
if (!
|
||||
MessageDialog.openConfirm(getShell(),
|
||||
UIMessages.getString("CDTCommonProjectWizard.0"), //$NON-NLS-1$
|
||||
UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$
|
||||
)
|
||||
return null;
|
||||
}
|
||||
existingPath = true;
|
||||
}
|
||||
try {
|
||||
IFileStore fs;
|
||||
URI p = fMainPage.getProjectLocation();
|
||||
if (p == null) {
|
||||
fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
|
||||
fs = fs.getChild(fMainPage.getProjectName());
|
||||
} else
|
||||
fs = EFS.getStore(p);
|
||||
IFileInfo f = fs.fetchInfo();
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
|
||||
if (!
|
||||
MessageDialog.openConfirm(getShell(),
|
||||
UIMessages.getString("CDTCommonProjectWizard.0"), //$NON-NLS-1$
|
||||
UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$
|
||||
)
|
||||
return null;
|
||||
}
|
||||
existingPath = true;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e.getStatus());
|
||||
}
|
||||
savedHandler = fMainPage.h_selected;
|
||||
savedHandler.saveState();
|
||||
lastProjectName = fMainPage.getProjectName();
|
||||
|
@ -229,7 +237,7 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public IProject createIProject(final String name, final IPath location) throws CoreException{
|
||||
public IProject createIProject(final String name, final URI location) throws CoreException{
|
||||
if (newProject != null) return newProject;
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
|
@ -242,7 +250,7 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
// workspace.setDescription(workspaceDesc);
|
||||
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
|
||||
if(location != null)
|
||||
description.setLocation(location);
|
||||
description.setLocationURI(location);
|
||||
newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());
|
||||
} else {
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
|
@ -285,7 +293,7 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
return lastProjectName;
|
||||
}
|
||||
|
||||
public IPath getLastProjectLocation() {
|
||||
public URI getLastProjectLocation() {
|
||||
return lastProjectLocation;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.dialogs.DialogPage;
|
||||
|
@ -42,6 +44,7 @@ import org.eclipse.swt.widgets.Tree;
|
|||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||
import org.eclipse.cdt.ui.newui.PageLayout;
|
||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||
|
@ -147,12 +150,8 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
|
|||
return (h_selected == null) ? null : h_selected.getSpecificPage();
|
||||
}
|
||||
|
||||
public IPath getProjectLocation() {
|
||||
return useDefaults() ? null : getLocationPath();
|
||||
}
|
||||
|
||||
public String getProjectLocationPath() {
|
||||
return getLocationPath().toOSString();
|
||||
public URI getProjectLocation() {
|
||||
return useDefaults() ? null : getLocationURI();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,20 +187,26 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
|
|||
}
|
||||
|
||||
if (bad) { // skip this check if project already created
|
||||
IPath p = getProjectLocation();
|
||||
if (p == null) {
|
||||
p = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||
p = p.append(getProjectName());
|
||||
}
|
||||
File f = p.toFile();
|
||||
if (f.exists()) {
|
||||
if (f.isDirectory()) {
|
||||
setMessage(UIMessages.getString("CMainWizardPage.7"), DialogPage.WARNING); //$NON-NLS-1$
|
||||
return true;
|
||||
} else {
|
||||
setErrorMessage(UIMessages.getString("CMainWizardPage.6")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
IFileStore fs;
|
||||
URI p = getProjectLocation();
|
||||
if (p == null) {
|
||||
fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
|
||||
fs = fs.getChild(getProjectName());
|
||||
} else
|
||||
fs = EFS.getStore(p);
|
||||
IFileInfo f = fs.fetchInfo();
|
||||
if (f.exists()) {
|
||||
if (f.isDirectory()) {
|
||||
setMessage(UIMessages.getString("CMainWizardPage.7"), DialogPage.WARNING); //$NON-NLS-1$
|
||||
return true;
|
||||
} else {
|
||||
setErrorMessage(UIMessages.getString("CMainWizardPage.6")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jface.wizard.IWizard;
|
||||
|
||||
public interface IWizardWithMemory extends IWizard {
|
||||
|
@ -18,6 +19,6 @@ public interface IWizardWithMemory extends IWizard {
|
|||
// or null if no projects were created
|
||||
public String getLastProjectName();
|
||||
|
||||
public IPath getLastProjectLocation();
|
||||
public URI getLastProjectLocation();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue