1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

- removal of deprecated 1.2 methods/classes

This commit is contained in:
David Inglis 2004-01-13 21:25:35 +00:00
parent 613c100d78
commit 74f6ab27e8
21 changed files with 64 additions and 2689 deletions

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="build"/>
<classpathentry kind="src" path="index"/>
<classpathentry kind="src" path="model"/>
<classpathentry kind="src" path="src"/>

View file

@ -2,11 +2,25 @@ bin.includes = plugin.xml,\
plugin.properties,\
about.html,\
cdtparser.jar,\
cdtcore.jar
cdtcore.jar,\
.options
jars.compile.order = cdtparser.jar,\
cdtcore.jar
src.includes = about.html,\
schema/
schema/,\
ChangeLog,\
build.properties,\
utils/,\
src/,\
search/,\
plugin.xml,\
plugin.properties,\
parser/,\
model/,\
index/,\
doc/,\
dependency/,\
.options
javadoc.packages = org.eclipse.cdt.core.*,\
org.eclipse.cdt.core.index.*,\
org.eclipse.cdt.core.model.*,\
@ -14,8 +28,7 @@ javadoc.packages = org.eclipse.cdt.core.*,\
org.eclipse.cdt.utils.*,\
org.eclipse.cdt.utils.elf.*,\
org.eclipse.cdt.utils.spawner.*
source.cdtcore.jar = build/,\
index/,\
source.cdtcore.jar = index/,\
model/,\
src/,\
utils/,\

View file

@ -1,261 +0,0 @@
package org.eclipse.cdt.core.build.standard;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.BuildInfoFactory;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.resources.IStandardBuildInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
public class StandardBuildManager extends AbstractCExtension implements IScannerInfoProvider {
// Name we will use to store build property with the project
private static final QualifiedName buildInfoProperty
= new QualifiedName(CCorePlugin.PLUGIN_ID, "standardBuildInfo");
private static final String ID = CCorePlugin.PLUGIN_ID + ".standardBuildInfo";
// This is the id of the IScannerInfoProvider extension point entry
public static final String INTERFACE_IDENTITY = CCorePlugin.PLUGIN_ID + "." + "StandardBuildManager";
// Listeners interested in build model changes
private static Map buildModelListeners;
/**
* @param project
* @return
*/
private static IStandardBuildInfo findBuildInfo(IResource resource, boolean create) throws CoreException {
IStandardBuildInfo buildInfo = null;
// See if there's already one associated with the resource for this session
try {
buildInfo = (IStandardBuildInfo)resource.getSessionProperty(buildInfoProperty);
} catch (CoreException e) {
}
// Try to load one for the project
if (buildInfo == null && resource instanceof IProject) {
buildInfo = loadBuildInfo((IProject)resource);
}
// There is nothing persisted for the session, or saved in a file so
// create a build info object
if (buildInfo == null && create) {
buildInfo = BuildInfoFactory.create((IProject)resource);
try {
((IProject)resource).setSessionProperty(buildInfoProperty, buildInfo);
} catch (CoreException e) {
buildInfo = null;
}
}
return buildInfo;
}
public static IStandardBuildInfo getBuildInfo(IProject project) throws CoreException {
return findBuildInfo(project, false);
}
public static IStandardBuildInfo getBuildInfo(IProject project, boolean create) throws CoreException {
return findBuildInfo(project, create);
}
/*
* @return
*/
private static synchronized Map getBuildModelListeners() {
if (buildModelListeners == null) {
buildModelListeners = new HashMap();
}
return buildModelListeners;
}
public static void setPreprocessorSymbols(IProject project, String[] symbols)
throws CoreException
{
// Get the information for the project
IStandardBuildInfo info = getBuildInfo(project);
// Set the new information
if (info != null) {
String[] oldSymbols = info.getPreprocessorSymbols();
if (!Arrays.equals(oldSymbols, symbols)) {
info.setPreprocessorSymbols(symbols);
// Alert the listeners
setScannerInfoDirty(project, info);
}
}
}
public static void setIncludePaths(IProject project, String[] paths)
throws CoreException
{
// Get the build info for the project
IStandardBuildInfo info = getBuildInfo(project);
if (info != null) {
String[] oldPaths = info.getIncludePaths();
if (!Arrays.equals(oldPaths, paths)) {
info.setIncludePaths(paths);
setScannerInfoDirty(project, info);
}
}
}
/**
* @param project
* @param info
*/
private static void setScannerInfoDirty(IProject project, IStandardBuildInfo info) {
// Call in the cavalry
List listeners = (List) getBuildModelListeners().get(project);
if (listeners == null) {
return;
}
ListIterator iter = listeners.listIterator();
while (iter.hasNext()) {
((IScannerInfoChangeListener)iter.next()).changeNotification(project, (IScannerInfo) info);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
*/
public IScannerInfo getScannerInformation(IResource resource) {
IStandardBuildInfo info;
try {
info = getBuildInfo((IProject)resource);
} catch (CoreException e) {
return null;
}
return (IScannerInfo)info;
}
/*
* Loads the build file and parses the nodes for build information. The
* information is then associated with the resource for the duration of
* the session.
*/
private static IStandardBuildInfo loadBuildInfo(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
IStandardBuildInfo buildInfo = BuildInfoFactory.create(project, descriptor.getProjectData(ID));
project.setSessionProperty(buildInfoProperty, buildInfo);
return buildInfo;
}
/**
* The build model manager for standard builds only caches the build
* information for a resource on a per-session basis. This method
* allows clients of the build model manager to programmatically
* remove the association between the resource and the information
* while the reource is still open or in the workspace. The Eclipse core
* will take care of removing it if a resource is closed or deleted.
*
* @param resource
*/
public static void removeBuildInfo(IResource resource) {
try {
resource.setSessionProperty(buildInfoProperty, null);
} catch (CoreException e) {
}
}
/**
* Persists build-specific information in the build file. Build
* information for standard make projects consists of preprocessor
* symbols and includes paths. Other project-related information is
* stored in the persistent properties of the project.
*
* @param project
*/
public static void saveBuildInfo(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Element rootElement = descriptor.getProjectData(ID);
// Clear out all current children
// Note: Probably would be a better idea to merge in the data
Node child = rootElement.getFirstChild();
while (child != null) {
rootElement.removeChild(child);
child = rootElement.getFirstChild();
}
// Save the build info
IStandardBuildInfo buildInfo = getBuildInfo(project);
if (buildInfo != null)
buildInfo.serialize(rootElement.getOwnerDocument(), rootElement);
descriptor.saveProjectData();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
*/
public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) {
IResource project = null;
if (resource instanceof IProject) {
project = resource;
} else if (resource instanceof IFile) {
project = ((IFile)resource).getProject();
} else {
return;
}
// Get listeners for this resource
Map map = getBuildModelListeners();
List list = (List) map.get(project);
if (list == null) {
// Create a new list
list = new ArrayList();
}
if (!list.contains(listener)) {
// Add the new listener for the resource
list.add(listener);
map.put(project, list);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
*/
public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
IResource project = null;
if (resource instanceof IProject) {
project = resource;
} else if (resource instanceof IFile) {
project = ((IFile)resource).getProject();
} else {
return;
}
// Remove the listener
Map map = getBuildModelListeners();
List list = (List) map.get(project);
if (list != null && !list.isEmpty()) {
// The list is not empty so try to remove listener
list.remove(listener);
map.put(project, list);
}
}
}

View file

@ -8,12 +8,7 @@ CProblemMarker.name=C Problem
CBuildCommand.name=C Builder Command
CBuildConsole.name=C Builder Console
CProject.name=C Project
CBuilder.name=C Build Model
ProcessList.name=Process List
ErrorParser.name=Error Parser
makeproject.name=Make Project
genericmake.name=Generic Make
makebuildmodel.name=Make Builder
CTaskName=C/C++ Task

View file

@ -25,14 +25,6 @@
<extension-point id="CProject" name="%CProject.name"/>
<!-- =================================================================================== -->
<!-- Extension Point:(Deprecated, to be removed) -->
<!-- =================================================================================== -->
<extension-point id="CBuildModel" name="%CBuilder.name"/>
<!-- =================================================================================== -->
<!-- Extension Point:(Deprecated, to be removed) Default command for the MakeBuilder -->
<!-- =================================================================================== -->
<extension-point id="CBuildCommand" name="%CBuildCommand.name"/>
<!-- =================================================================================== -->
<!-- Extension Point:(work in progress) IConsole, customize a C Build console output -->
<!-- =================================================================================== -->
<extension-point id="CBuildConsole" name="%CBuildConsole.name"/>
@ -137,19 +129,6 @@
</errorparser>
</extension>
<!-- =================================================================================== -->
<!-- Eclipse Builder provided by the CDT, to be removed to the MakePlugin -->
<!-- =================================================================================== -->
<extension
id="cbuilder"
name="C Builder"
point="org.eclipse.core.resources.builders">
<builder>
<run
class="org.eclipse.cdt.internal.core.CBuilder">
</run>
</builder>
</extension>
<!-- =================================================================================== -->
<!-- CDT customized problem markers: C Problem markers -->
<!-- =================================================================================== -->
<extension
@ -190,37 +169,6 @@
</runtime>
</extension>
<!-- =================================================================================== -->
<!-- Deprecated Make default command, will be removed. -->
<!-- =================================================================================== -->
<extension
point="org.eclipse.cdt.core.CBuildCommand">
<buildcommand
command="make">
</buildcommand>
</extension>
<!-- =================================================================================== -->
<!-- Deprecated Make owner, will be removed. -->
<!-- =================================================================================== -->
<extension
id="make"
name="%makeproject.name"
point="org.eclipse.cdt.core.CProject">
<cproject
class="org.eclipse.cdt.internal.core.make.MakeProject">
</cproject>
</extension>
<!-- =================================================================================== -->
<!-- Deprecated Make builder, will be removed. -->
<!-- =================================================================================== -->
<extension
id="makeBuilder"
name="%makebuildmodel.name"
point="org.eclipse.cdt.core.CBuildModel">
<run
class="org.eclipse.cdt.internal.core.make.MakeBuilder">
</run>
</extension>
<!-- =================================================================================== -->
<!-- Some well known C file extensions override for the team plugins -->
<!-- =================================================================================== -->
<extension
@ -309,18 +257,6 @@
</ignore>
</extension>
<!-- =================================================================================== -->
<!-- Extension Point(Note:Temporary): IScannerInfoProvider for the standard Builder -->
<!-- =================================================================================== -->
<extension
id="StandardBuildManager"
point="org.eclipse.cdt.core.ScannerInfoProvider">
<cextension>
<run
class="org.eclipse.cdt.core.build.standard.StandardBuildManager">
</run>
</cextension>
</extension>
<!-- =================================================================================== -->
<!-- =================================================================================== -->
<extension
id="task"

View file

@ -1,293 +0,0 @@
package org.eclipse.cdt.core;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.resources.IStandardBuildInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
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.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class BuildInfoFactory {
public static final String LOCATION = "buildLocation";
public static final String FULL_ARGUMENTS = "buildFullArguments";
public static final String INCREMENTAL_ARGUMENTS = "buildIncrementalArguments";
public static final String STOP_ON_ERROR = "stopOnError";
// public static final String CLEAR_CONSOLE = "clearConsole";
public static final String DEFAULT_BUILD_CMD = "useDefaultBuildCmd";
public static final String PROJECT_NAME = "projectName";
public static final String INCLUDE_PATH = "includePath";
public static final String PATH = "path";
public static final String DEFINED_SYMBOL = "definedSymbol";
public static final String SYMBOL = "symbol";
public static abstract class Store implements IStandardBuildInfo, IScannerInfo {
// List of include paths
protected List pathList;
protected List symbolList;
public String getBuildLocation() {
if ( isDefaultBuildCmd() ) {
Plugin plugin = CCorePlugin.getDefault();
if (plugin != null) {
IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint("CBuildCommand");
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for(int i = 0; i < extensions.length; i++){
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
for(int j = 0; j < configElements.length; j++){
String command = configElements[j].getAttribute("command"); //$NON-NLS-1$
if (command != null)
return command;
}
}
}
}
return "make";
}
return getString(LOCATION);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
*/
public Map getDefinedSymbols() {
// Return the defined symbols for the default configuration
HashMap symbols = new HashMap();
String[] symbolList = getPreprocessorSymbols();
for (int i = 0; i < symbolList.length; ++i) {
String symbol = symbolList[i];
if (symbol.length() == 0) {
continue;
}
String key = new String();
String value = new String();
int index = symbol.indexOf("=");
if (index != -1) {
key = symbol.substring(0, index).trim();
value = symbol.substring(index + 1).trim();
} else {
key = symbol.trim();
}
symbols.put(key, value);
}
return symbols;
}
public String getFullBuildArguments() {
return getString(FULL_ARGUMENTS);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
*/
public String[] getIncludePaths() {
return (String[]) getPathList().toArray(new String[getPathList().size()]);
}
public String getIncrementalBuildArguments() {
return getString(INCREMENTAL_ARGUMENTS);
}
public boolean isStopOnError() {
return getBoolean(STOP_ON_ERROR);
}
public void setBuildLocation(String location) {
putValue(LOCATION, location);
}
public void setPreprocessorSymbols(String[] symbols) {
// Clear out any existing symbols and add the new stuff
getSymbolList().clear();
getSymbolList().addAll(Arrays.asList(symbols));
}
public void setFullBuildArguments(String arguments) {
putValue(FULL_ARGUMENTS, arguments);
}
public void setIncludePaths(String[] paths) {
// Clear the existing list and add the paths
getPathList().clear();
getPathList().addAll(Arrays.asList(paths));
}
public void setIncrementalBuildArguments(String arguments) {
putValue(INCREMENTAL_ARGUMENTS, arguments);
}
public void setStopOnError(boolean on) {
putValue(STOP_ON_ERROR, new Boolean(on).toString());
}
public boolean isDefaultBuildCmd() {
if ( getString(DEFAULT_BUILD_CMD) == null ) { // if no property then default to true
return true;
}
return getBoolean(DEFAULT_BUILD_CMD);
}
public void setUseDefaultBuildCmd(boolean on) {
putValue(DEFAULT_BUILD_CMD, new Boolean(on).toString());
}
// public boolean isClearBuildConsole() {
// return getBoolean(CLEAR_CONSOLE);
// }
public boolean getBoolean(String property) {
return Boolean.valueOf(getString(property)).booleanValue();
}
public void putValue(String name, String value) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IBuildInfo#serialize(org.w3c.dom.Document, org.w3c.dom.Element)
*/
public void serialize(Document doc, Element rootElement) {
// Serialize the include paths
ListIterator iter = getPathList().listIterator();
while (iter.hasNext()){
Element pathElement = doc.createElement(INCLUDE_PATH);
pathElement.setAttribute(PATH, (String)iter.next());
rootElement.appendChild(pathElement);
}
// Now do the same for the symbols
iter = getSymbolList().listIterator();
while (iter.hasNext()) {
Element symbolElement = doc.createElement(DEFINED_SYMBOL);
symbolElement.setAttribute(SYMBOL, (String)iter.next());
rootElement.appendChild(symbolElement);
}
}
protected List getPathList() {
if (pathList == null) {
pathList = new ArrayList();
}
return pathList;
}
public String getString(String property) {
return null;
}
public String[] getPreprocessorSymbols() {
return (String[]) getSymbolList().toArray(new String[getSymbolList().size()]);
}
protected List getSymbolList() {
if (symbolList == null) {
symbolList = new ArrayList();
}
return symbolList;
}
}
public static class Preference extends Store {
Preferences prefs;
public Preference() {
prefs = CCorePlugin.getDefault().getPluginPreferences();
}
public void putValue(String name, String value) {
prefs.setValue(name, value);
}
public String getString(String property) {
return prefs.getString(property);
}
public void setDefault(String name, String def) {
prefs.setDefault(name, def);
}
}
public static class Property extends Store {
private IResource resource;
public Property(IResource resource) {
this.resource = resource;
}
public void putValue(String name, String value) {
QualifiedName qName = new QualifiedName(CCorePlugin.PLUGIN_ID, name);
try {
resource.setPersistentProperty(qName, value);
} catch (CoreException e) {
}
}
public String getString(String property) {
QualifiedName qName = new QualifiedName(CCorePlugin.PLUGIN_ID, property);
try {
return resource.getPersistentProperty(qName);
} catch (CoreException e) {
}
return null;
}
public void setDefault(String name, String def) {
}
// public boolean isClearBuildConsole() {
// return (new Preference()).isClearBuildConsole();
// }
}
public static IStandardBuildInfo create() {
return new BuildInfoFactory.Preference();
}
public static IStandardBuildInfo create(IProject project) {
return new BuildInfoFactory.Property(project);
}
/**
* @param project
* @param element
* @return
*/
public static IStandardBuildInfo create(IProject project, Element element) {
// Create a new info property object
Property buildProperties = new Property(project);
Node child = element.getFirstChild();
while (child != null) {
if (child.getNodeName().equals(INCLUDE_PATH)) {
// Add the path to the property list
buildProperties.getPathList().add(((Element)child).getAttribute(PATH));
} else if (child.getNodeName().equals(DEFINED_SYMBOL)) {
// Add the symbol to the symbol list
buildProperties.getSymbolList().add(((Element)child).getAttribute(SYMBOL));
}
child = child.getNextSibling();
}
return (IStandardBuildInfo)buildProperties;
}
}

View file

@ -11,8 +11,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
public class CCProjectNature extends CProjectNature {
public static final String CC_NATURE_ID= CCorePlugin.PLUGIN_ID + ".ccnature";

View file

@ -1,37 +1,24 @@
package org.eclipse.cdt.core;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
* (c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.build.standard.StandardBuildManager;
import org.eclipse.cdt.core.resources.IStandardBuildInfo;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
public class CProjectNature implements IProjectNature {
public static final String BUILDER_NAME= "cbuilder";
public static final String BUILDER_ID= CCorePlugin.PLUGIN_ID + "." + BUILDER_NAME;
public static final String C_NATURE_ID= CCorePlugin.PLUGIN_ID + ".cnature";
public static final String C_NATURE_ID = CCorePlugin.PLUGIN_ID + ".cnature";
private IProject fProject;
private IStandardBuildInfo fBuildInfo;
public CProjectNature() {
}
@ -51,22 +38,25 @@ public class CProjectNature implements IProjectNature {
/**
* Utility method for adding a nature to a project.
*
* @param proj the project to add the nature
* @param natureId the id of the nature to assign to the project
* @param monitor a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
* @param proj
* the project to add the nature
* @param natureId
* the id of the nature to assign to the project
* @param monitor
* a progress monitor to indicate the duration of the operation,
* or <code>null</code> if progress reporting is not required.
*
*/
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
for (int i= 0; i < prevNatures.length; i++) {
String[] prevNatures = description.getNatureIds();
for (int i = 0; i < prevNatures.length; i++) {
if (natureId.equals(prevNatures[i]))
return;
}
String[] newNatures= new String[prevNatures.length + 1];
String[] newNatures = new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= natureId;
newNatures[prevNatures.length] = natureId;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
}
@ -74,219 +64,23 @@ public class CProjectNature implements IProjectNature {
/**
* Utility method for removing a project nature from a project.
*
* @param proj the project to remove the nature from
* @param natureId the nature id to remove
* @param monitor a progress monitor to indicate the duration of the operation, or
* <code>null</code> if progress reporting is not required.
* @param proj
* the project to remove the nature from
* @param natureId
* the nature id to remove
* @param monitor
* a progress monitor to indicate the duration of the operation,
* or <code>null</code> if progress reporting is not required.
*/
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
String[] prevNatures = description.getNatureIds();
List newNatures = new ArrayList(Arrays.asList(prevNatures));
newNatures.remove(natureId);
description.setNatureIds((String[])newNatures.toArray(new String[newNatures.size()]));
description.setNatureIds((String[]) newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, monitor);
}
/**
* Sets the path of the build command executable.
* @depercated
*/
public void setBuildCommand(IPath locationPath, IProgressMonitor monitor) throws CoreException {
}
/**
* Gets the path of the build command executable.
* @deprecated
*/
public IPath getBuildCommand() throws CoreException {
if( fBuildInfo == null) {
fBuildInfo = StandardBuildManager.getBuildInfo(fProject, true);
}
String buildLocation= fBuildInfo.getBuildLocation();
return new Path(buildLocation);
}
/**
* Sets the arguments for the full build.
* @deprecated
*/
public void setFullBuildArguments(String arguments, IProgressMonitor monitor) throws CoreException {
}
/**
* Gets the arguments for the full build
* @deprecated
*/
public String getFullBuildArguments() throws CoreException {
if( fBuildInfo == null) {
fBuildInfo = StandardBuildManager.getBuildInfo(fProject, true);
}
String buildArguments= fBuildInfo.getFullBuildArguments();
if (buildArguments == null) {
buildArguments= "";
}
return buildArguments;
}
/**
* Sets the arguments for the incremental build.
* @deprecated
*/
public void setIncrBuildArguments(String arguments, IProgressMonitor monitor) throws CoreException {
}
/**
* Gets the arguments for the incremental build
* @deprecated
*/
public String getIncrBuildArguments() throws CoreException {
if( fBuildInfo == null) {
fBuildInfo = StandardBuildManager.getBuildInfo(fProject, true);
}
String buildArguments= fBuildInfo.getIncrementalBuildArguments();
if (buildArguments == null) {
buildArguments= "";
}
return buildArguments;
}
/**
* Sets Stop on Error
* @deprecated
*/
public void setStopOnError(boolean on) throws CoreException {
}
/**
* @deprecated
*/
public void setBuildCommandOverride(boolean on) throws CoreException {
}
/**
* Gets Stop on Error
* @deprecated
*/
public boolean isStopOnError() throws CoreException {
if( fBuildInfo == null) {
fBuildInfo = StandardBuildManager.getBuildInfo(fProject, true);
}
return fBuildInfo.isStopOnError();
}
/**
* @deprecated
*/
public boolean isDefaultBuildCmd() throws CoreException {
if( fBuildInfo == null) {
fBuildInfo = StandardBuildManager.getBuildInfo(fProject, true);
}
return fBuildInfo.isDefaultBuildCmd();
}
/**
* @deprecated
*/
public static boolean hasCBuildSpec(IProject project) {
boolean found= false;
try {
IProjectDescription description = project.getDescription();
ICommand[] commands= description.getBuildSpec();
for (int i= 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(BUILDER_ID)) {
found= true;
break;
}
}
} catch (CoreException e) {
}
return found;
}
/**
* @deprecated
*/
public void addCBuildSpec(IProgressMonitor mon) throws CoreException {
}
/**
* @deprecated
*/
public static void addCBuildSpec(IProject project, IProgressMonitor mon) throws CoreException {
}
/**
* @deprecated
*/
public void addToBuildSpec(String builderID, IProgressMonitor mon) throws CoreException {
addToBuildSpec(getProject(), builderID, mon);
}
/**
* Adds a builder to the build spec for the given project.
* @deprecated
*/
public static void addToBuildSpec(IProject project, String builderID, IProgressMonitor mon) throws CoreException {
IProjectDescription description= project.getDescription();
ICommand[] commands= description.getBuildSpec();
boolean found= false;
for (int i= 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(builderID)) {
found= true;
break;
}
}
if (!found) {
ICommand command= description.newCommand();
command.setBuilderName(builderID);
ICommand[] newCommands= new ICommand[commands.length + 1];
// Add it before other builders. See 1FWJK7I: ITPJCORE:WIN2000
System.arraycopy(commands, 0, newCommands, 1, commands.length);
newCommands[0]= command;
description.setBuildSpec(newCommands);
project.setDescription(description, mon);
}
}
/**
* @deprecated
*/
public void removeCBuildSpec(IProgressMonitor mon) throws CoreException {
}
/**
* Removes the given builder from the build spec for the given project.
* @deprecated
*/
public void removeFromBuildSpec(String builderID, IProgressMonitor mon) throws CoreException {
IProjectDescription description= getProject().getDescription();
ICommand[] commands= description.getBuildSpec();
for (int i= 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(builderID)) {
ICommand[] newCommands= new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
description.setBuildSpec(newCommands);
break;
}
}
getProject().setDescription(description, mon);
}
/**
* Get the correct builderID
* @deprecated
*/
public static String getBuilderID() {
Plugin plugin = (Plugin)CCorePlugin.getDefault();
IPluginDescriptor descriptor = plugin.getDescriptor();
if (descriptor.getExtension(BUILDER_NAME) != null) {
return descriptor.getUniqueIdentifier() + "." + BUILDER_NAME;
}
return BUILDER_ID;
}
/**
* @see IProjectNature#configure
*/
@ -310,7 +104,6 @@ public class CProjectNature implements IProjectNature {
* @see IProjectNature#setProject
*/
public void setProject(IProject project) {
fProject= project;
fProject = project;
}
}

View file

@ -1,38 +0,0 @@
package org.eclipse.cdt.core.resources;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
public interface IStandardBuildInfo {
String getBuildLocation();
public String[] getPreprocessorSymbols();
String getFullBuildArguments();
public String[] getIncludePaths();
String getIncrementalBuildArguments();
boolean isStopOnError();
void setBuildLocation(String location);
public void setPreprocessorSymbols(String[] symbols);
void setFullBuildArguments(String arguments);
public void setIncludePaths(String[] paths);
void setIncrementalBuildArguments(String arguments);
void setStopOnError(boolean on);
// boolean isClearBuildConsole();
boolean isDefaultBuildCmd();
void setUseDefaultBuildCmd(boolean on);
/**
* @param doc
* @param rootElement
*/
void serialize(Document doc, Element rootElement);
}

View file

@ -1,181 +0,0 @@
package org.eclipse.cdt.core.resources;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
/**
* @deprecated
*
*/
public class MakeUtil {
final static String MAKE_GOALS = "goals";
final static String MAKE_DIR = "buildir";
final static String TARGET_ID = "org.eclipse.cdt.make";
public static String[] decodeTargets(String property) {
BufferedReader reader = new BufferedReader(new StringReader(property));
ArrayList l = new ArrayList(5);
try {
String line = reader.readLine();
while (line != null && !"".equals(line)) {
l.add(line);
line = reader.readLine();
}
} catch (IOException e) {
// this should not happen, we're reading from a string.
}
String[] result = new String[l.size()];
return (String[]) l.toArray(result);
}
public static String encodeTargets(String[] targets) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < targets.length; i++) {
if (targets[i] != null) {
buf.append(targets[i]);
buf.append("\n");
}
}
return (buf.length() == 0) ? null : buf.toString();
}
public static QualifiedName getQualifiedNameTarget() {
return new QualifiedName(TARGET_ID, MAKE_GOALS);
}
public static QualifiedName getQualifiedNameDir() {
return new QualifiedName(TARGET_ID, MAKE_DIR);
}
public static String getSessionTarget(IResource resource) {
try {
String property = (String) resource.getSessionProperty(getQualifiedNameTarget());
if (property != null)
return property;
} catch (CoreException e) {
}
return new String();
}
public static void setSessionTarget(IResource resource, String target) {
try {
resource.setSessionProperty(getQualifiedNameTarget(), target);
} catch (CoreException e) {
}
}
public static void removeSessionTarget(IResource resource) {
setSessionTarget(resource, null);
}
public static String getSessionBuildDir(IResource resource) {
try {
String dir = (String) resource.getSessionProperty(getQualifiedNameDir());
if (dir != null)
return dir;
} catch (CoreException e) {
}
return new String();
}
public static void setSessionBuildDir(IResource resource, String dir) {
try {
resource.setSessionProperty(getQualifiedNameDir(), dir);
} catch (CoreException e) {
}
}
public static void removeSessionBuildDir(IResource resource) {
setSessionBuildDir(resource, null);
}
public static String[] getPersistentTargets(IResource resource) {
try {
String property = resource.getPersistentProperty(getQualifiedNameTarget());
if (property != null)
return decodeTargets(property);
} catch (CoreException e) {
}
return new String[0];
}
public static void setPersistentTargets(IResource resource, String[] targets) {
String property = null;
if (targets != null)
property = encodeTargets(targets);
//System.out.println ("PROPERTY " + property);
try {
resource.setPersistentProperty(getQualifiedNameTarget(), property);
} catch (CoreException e) {
}
}
public static void addPersistentTarget(IResource resource, String target) {
String[] targets = MakeUtil.getPersistentTargets(resource);
for (int i = 0; i < targets.length; i++) {
if (targets[i].equals(target)) {
return;
}
}
String[] newTargets = new String[targets.length + 1];
System.arraycopy(targets, 0, newTargets, 0, targets.length);
newTargets[targets.length] = target;
MakeUtil.setPersistentTargets(resource, newTargets);
}
public static void removePersistentTarget(IResource resource, String target) {
String[] targets = MakeUtil.getPersistentTargets(resource);
String[] newTargets = new String[targets.length];
for (int i = 0; i < targets.length; i++) {
if (!targets[i].equals(target)) {
newTargets[i] = targets[i];
}
}
MakeUtil.setPersistentTargets(resource, newTargets);
}
/**
* Replace a tag on a resource. Functionally equivalent to
* removePersistantTag(resource, oldtarget)
* addPersistantTag(resource, newtarget)
* If the oldtarget doesn't exist, the newtarget is added.
* If the newtarget is null, the oldtarget is removed.
* @param resource The resource the tag applies to
* @param oldtarget The oldtarget tag
* @param newtarget The newtarget tag to replace the old target tag or null. If
* newtarget is null then this call is the same as removePersistantTarget(resource, oldtarget)
*/
public static void replacePersistentTarget(IResource resource, String oldtarget, String newtarget) {
if (newtarget == null) {
removePersistentTarget(resource, oldtarget);
return;
}
String[] targets = getPersistentTargets(resource);
for (int i = 0; i < targets.length; i++) {
if (targets[i].equals(oldtarget)) {
targets[i] = newtarget;
setPersistentTargets(resource, targets);
return;
}
}
//The target wasn't found, create a new one
addPersistentTarget(resource, newtarget);
}
private MakeUtil() {
}
}

View file

@ -1,286 +0,0 @@
package org.eclipse.cdt.internal.core;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.MakeUtil;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
public class CBuilder extends ACBuilder {
private static final String BUILD_ERROR = "CBuilder.build_error";
public CBuilder() {
}
public IPath getWorkingDirectory() {
IProject currProject = getProject();
IPath workingDirectory = new Path(MakeUtil.getSessionBuildDir((IResource) currProject));
if (workingDirectory.isEmpty())
workingDirectory = currProject.getLocation();
return workingDirectory;
}
public class MyResourceDeltaVisitor implements IResourceDeltaVisitor {
boolean bContinue;
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (resource != null && resource.getProject() == getProject()) {
bContinue = true;
return false;
}
return true;
}
public boolean shouldBuild() {
return bContinue;
}
}
/**
* @see IncrementalProjectBuilder#build
*/
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
boolean bPerformBuild = true;
if (kind == IncrementalProjectBuilder.AUTO_BUILD) {
MyResourceDeltaVisitor vis = new MyResourceDeltaVisitor();
IResourceDelta delta = getDelta(getProject());
if (delta != null ) {
delta.accept(vis);
bPerformBuild = vis.shouldBuild();
} else
bPerformBuild = false;
}
if ( bPerformBuild ) {
boolean isClean = invokeMake((kind == IncrementalProjectBuilder.FULL_BUILD), monitor);
if (isClean) {
forgetLastBuiltState();
}
}
checkCancel(monitor);
return getProject().getReferencedProjects();
}
private boolean invokeMake(boolean fullBuild, IProgressMonitor monitor) {
boolean isClean = false;
IProject currProject = getProject();
SubProgressMonitor subMonitor = null;
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("Invoking the C Builder: " + currProject.getName(), IProgressMonitor.UNKNOWN);
try {
CProjectNature nature = (CProjectNature) currProject.getNature(CProjectNature.C_NATURE_ID);
IPath makepath = nature.getBuildCommand();
if (!makepath.isEmpty()) {
IConsole console = CCorePlugin.getDefault().getConsole();
console.start(currProject);
ConsoleOutputStream cos = console.getOutputStream();
// remove all markers for this project
removeAllMarkers(currProject);
IPath workingDirectory = getWorkingDirectory();
String[] userArgs = parseArguments(fullBuild, nature.getIncrBuildArguments());
if (userArgs.length != 0 && userArgs[userArgs.length - 1].equals("clean"))
isClean = true;
// Before launching give visual cues via the monitor
subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
subMonitor.subTask("Invoking Command: " + makepath.toString());
String errMsg = null;
CommandLauncher launcher = new CommandLauncher();
// Print the command for visual interaction.
launcher.showCommand(true);
// Set the environmennt, some scripts may need the CWD var to be set.
Properties props = launcher.getEnvironment();
props.put("CWD", workingDirectory.toOSString());
props.put("PWD", workingDirectory.toOSString());
String[] env = null;
ArrayList envList = new ArrayList();
Enumeration names = props.propertyNames();
if (names != null) {
while (names.hasMoreElements()) {
String key = (String) names.nextElement();
envList.add(key + "=" + props.getProperty(key));
}
env = (String[]) envList.toArray(new String[envList.size()]);
}
ErrorParserManager epm = new ErrorParserManager(this);
epm.setOutputStream(cos);
OutputStream stdout = epm.getOutputStream();
OutputStream stderr = epm.getOutputStream();
Process p = launcher.execute(makepath, userArgs, env, workingDirectory);
if (p != null) {
try {
// Close the input of the Process explicitely.
// We will never write to it.
p.getOutputStream().close();
} catch (IOException e) {
}
if (launcher.waitAndRead(stdout, stderr, subMonitor) != CommandLauncher.OK)
errMsg = launcher.getErrorMessage();
subMonitor.setTaskName("Refresh From Local");
try {
// do not allow the cancel of the refresh, since the builder is external
// to Eclipse files may have been created/modified and we will be out-of-sync
// The caveat is for hugue projects, it may take sometimes at every build.
currProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
}
subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
subMonitor.subTask("Parsing");
} else {
errMsg = launcher.getErrorMessage();
}
if (errMsg != null) {
String errorDesc = CCorePlugin.getFormattedString(BUILD_ERROR, makepath.toString());
StringBuffer buf = new StringBuffer(errorDesc);
buf.append(System.getProperty("line.separator", "\n"));
buf.append("(").append(errMsg).append(")");
cos.write(buf.toString().getBytes());
cos.flush();
}
stdout.close();
stderr.close();
epm.reportProblems();
subMonitor.done();
}
} catch (Exception e) {
CCorePlugin.log(e);
}
monitor.done();
return (isClean);
}
/**
* Check whether the build has been canceled.
*/
public void checkCancel(IProgressMonitor monitor) {
if (monitor != null && monitor.isCanceled())
throw new OperationCanceledException();
}
private String[] parseArguments(boolean fullBuild, String override_args) {
ArrayList list = new ArrayList();
IProject currProject = getProject();
try {
CProjectNature nature = (CProjectNature) currProject.getNature(CProjectNature.C_NATURE_ID);
if (nature.isDefaultBuildCmd()) {
if (!nature.isStopOnError()) {
list.add("-k");
}
}
else {
String[] ovrd_args = makeArray(nature.getFullBuildArguments());
list.addAll(Arrays.asList(ovrd_args));
}
}
catch (CoreException e) {
}
String sessionTarget = MakeUtil.getSessionTarget((IResource) currProject);
String[] targets = makeArray(sessionTarget);
for (int i = 0; i < targets.length; i++) {
list.add(targets[i]);
}
// Lets try this: if FULL_BUILD; we run "clean all"
if (fullBuild && targets.length == 0) {
list.add("clean");
list.add("all");
}
return (String[]) list.toArray(new String[list.size()]);
}
// Turn the string into an array.
String[] makeArray(String string) {
string.trim();
char[] array = string.toCharArray();
ArrayList aList = new ArrayList();
StringBuffer buffer = new StringBuffer();
boolean inComment = false;
for (int i = 0; i < array.length; i++) {
char c = array[i];
if (array[i] == '"' || array[i] == '\'') {
if (i > 0 && array[i - 1] == '\\') {
inComment = false;
}
else {
inComment = !inComment;
}
}
if (c == ' ' && !inComment) {
aList.add(buffer.toString());
buffer = new StringBuffer();
}
else {
buffer.append(c);
}
}
if (buffer.length() > 0)
aList.add(buffer.toString());
return (String[]) aList.toArray(new String[aList.size()]);
}
//private void clearConsole(final IDocument doc) {
// Display.getDefault().syncExec(new Runnable() {
// public void run() {
// doc.set("");
// }
// });
//}
private void removeAllMarkers(IProject currProject) throws CoreException {
IWorkspace workspace = currProject.getWorkspace();
// remove all markers
IMarker[] markers = currProject.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
if (markers != null) {
workspace.deleteMarkers(markers);
}
}
}

View file

@ -1,52 +0,0 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.internal.core.make;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.IPath;
public class MakeBuilder extends AbstractCExtension /*implements ICBuilder */ {
public IPath[] getIncludePaths() {
return new IPath[0];
}
public void setIncludePaths(IPath[] incPaths) {
}
public IPath[] getLibraryPaths() {
return new IPath[0];
}
public void setLibraryPaths(IPath[] libPaths) {
}
public String[] getLibraries() {
return new String[0];
}
public void setLibraries(String[] libs) {
}
// public IOptimization getOptimization() {
// return null;
// }
//
// public IProject[] build(CIncrementalBuilder cbuilder) {
// ICExtensionReference ref = getExtensionReference();
// System.out.println("MakeBuilder!!!!\n Command is:" + ref.getExtensionData("command"));
// return null;
// }
//
// public void setOptimization(IOptimization o) {
// }
public String getID() {
return CCorePlugin.PLUGIN_ID + ".makeBuilder";
}
}

View file

@ -1,27 +0,0 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.internal.core.make;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.ICOwner;
import org.eclipse.core.runtime.CoreException;
public class MakeProject implements ICOwner {
public void configure(ICDescriptor cproject) throws CoreException {
cproject.remove(CCorePlugin.BUILDER_MODEL_ID);
ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, CCorePlugin.PLUGIN_ID + ".makeBuilder");
ext.setExtensionData("command", "make");
}
public void update(ICDescriptor cproject, String extensionID) throws CoreException {
if ( extensionID.equals(CCorePlugin.BUILDER_MODEL_ID ) ) {
ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, CCorePlugin.PLUGIN_ID + ".makeBuilder");
ext.setExtensionData("command", "make");
}
}
}

View file

@ -1,122 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea;
import org.eclipse.cdt.utils.ui.swt.IValidation;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
/**
* @deprecated
*
*/
public class BinaryParserBlock implements IWizardTab {
//private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
//private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
private static String[][] radios;
private IProject project;
protected RadioButtonsArea radioButtons;
private String id;
// protected Button defButton;
IValidation page;
public BinaryParserBlock(IValidation valid) {
this(valid, null);
}
public BinaryParserBlock(IValidation valid, IProject p) {
page = valid;
project = p;
IExtensionPoint point = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(CCorePlugin.BINARY_PARSER_SIMPLE_ID);
if (point != null) {
IExtension[] exts = point.getExtensions();
radios = new String[exts.length][2];
for (int i = 0; i < exts.length; i++) {
radios[i] = new String[] { exts[i].getLabel(), exts[i].getUniqueIdentifier()};
}
}
if (project != null) {
try {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(p);
ICExtensionReference[] ref = desc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
if (ref.length > 0)
id = ref[0].getID();
} catch (CoreException e) {
//e.printStackTrace();
}
}
if (id == null) {
id = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(CCorePlugin.PREF_BINARY_PARSER);
if (id == null || id.length() == 0) {
id = CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID;
}
}
}
public String getLabel() {
//return CUIPlugin.getResourceString(LABEL);
return "Binary Parser";
}
public Image getImage() {
return null;
}
public Composite getControl(Composite parent) {
Composite composite = ControlFactory.createComposite(parent, 1);
radioButtons = new RadioButtonsArea(composite, "Parsers", 1, radios);
radioButtons.setEnabled(true);
if (id != null) {
radioButtons.setSelectValue(id);
}
return composite;
}
public boolean isValid() {
return true;
}
public void setVisible(boolean visible) {
}
public void doRun(IProject project, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("Parsers", 1);
try {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project);
String identity = radioButtons.getSelectedValue();
if (identity != null) {
if (id == null || !identity.equals(id)) {
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, identity);
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(project);
id = identity;
}
}
} catch (CoreException e) {
}
}
}

View file

@ -1,66 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @deprecated
* C Project wizard that creates a new project resource in
*/
public abstract class CCProjectWizard extends CProjectWizard {
private static final String OP_ERROR= "CCProjectWizard.op_error"; //$NON-NLS-1$
private static final String OP_DESC= "CCProjectWizard.op_description"; //$NON-NLS-1$
private static final String PREFIX= "CCProjectWizard"; //$NON-NLS-1$
private static final String WZ_TITLE= "CCProjectWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC= "CCProjectWizard.description"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "CCProjectWizard.windowTitle"; //$NON-NLS-1$
private String wz_title;
private String wz_desc;
private String op_error;
public CCProjectWizard() {
super();
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
wz_title = CUIPlugin.getResourceString(WZ_TITLE);
wz_desc = CUIPlugin.getResourceString(WZ_DESC);
op_error = CUIPlugin.getResourceString(OP_ERROR);
}
public CCProjectWizard(String title, String description) {
super();
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
wz_title = title;
wz_desc = description;
op_error = CUIPlugin.getResourceString(OP_ERROR);
}
public CCProjectWizard(String title, String description, String error) {
super();
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
wz_title = title;
wz_desc = description;
op_error = error;
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
super.doRun(monitor);
// Add C++ Nature to the newly created project.
if (newProject != null){
CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
}
}
}

View file

@ -1,348 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.build.standard.StandardBuildManager;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.ui.swt.IValidation;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
/**
* @deprecated
* C Project wizard that creates a new project resource in
* a location of the user's choice.
*/
public abstract class CProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
private static final String OP_DESC= "CProjectWizard.op_description"; //$NON-NLS-1$
private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
private static final String WZ_TITLE= "CProjectWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC= "CProjectWizard.description"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "CProjectWizard.windowTitle"; //$NON-NLS-1$
private String wz_title;
private String wz_desc;
private String op_error;
protected IConfigurationElement fConfigElement;
protected CProjectWizardPage fMainPage;
protected TabFolderPage fTabFolderPage;
protected IProject newProject;
List tabItemsList = new ArrayList();
public CProjectWizard() {
this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC),
CUIPlugin.getResourceString(OP_ERROR));
}
public CProjectWizard(String title, String description) {
this(title, description, CUIPlugin.getResourceString(OP_ERROR));
}
public CProjectWizard(String title, String description, String error) {
super();
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
setNeedsProgressMonitor(true);
wz_title = title;
wz_desc = description;
op_error = error;
}
/**
* @see Wizard#createPages
*/
public void addPages() {
fMainPage= new CProjectWizardPage(this, CUIPlugin.getResourceString(PREFIX));
fMainPage.setTitle(wz_title);
fMainPage.setDescription(wz_desc);
addPage(fMainPage);
fTabFolderPage = new TabFolderPage(this);
addPage(fTabFolderPage);
}
public void addTabItem(IWizardTab item) {
tabItemsList.add(item);
}
public IWizardTab [] getTabItems() {
return (IWizardTab[])tabItemsList.toArray(new IWizardTab[0]);
}
public abstract void addTabItems(TabFolder tabFolder);
protected abstract void doRunPrologue(IProgressMonitor monitor);
protected abstract void doRunEpilogue(IProgressMonitor monitor);
protected IStatus isValidName(String name) {
return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, 0, "", null);
}
/**
* Method isValidLocation.
* @param projectFieldContents
* @return IStatus
*/
protected IStatus isValidLocation(String projectFieldContents) {
return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, 0, "", null);
}
/**
* Gets the project location path from the main page
* Overwrite this method if you do not have a main page
*/
protected IPath getLocationPath() throws UnsupportedOperationException {
if (null == fMainPage)
throw new UnsupportedOperationException();
return fMainPage.getLocationPath();
}
/**
* Gets the project handle from the main page.
* Overwrite this method if you do not have a main page
*/
protected IProject getProjectHandle() throws UnsupportedOperationException {
if (null == fMainPage)
throw new UnsupportedOperationException();
return fMainPage.getProjectHandle();
}
/**
* Returns the C project handle corresponding to the project defined in
* in the main page.
*
* @returns the C project
*/
protected IProject getNewProject() {
return newProject;
}
protected IResource getSelectedResource() {
return getNewProject();
}
protected IValidation getValidation() {
return fTabFolderPage;
}
/**
* @see Wizard#performFinish
*/
public boolean performFinish() {
if (!invokeRunnable(getRunnable())) {
return false;
}
BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
IResource resource = getSelectedResource();
selectAndReveal(resource);
if (resource != null && resource.getType() == IResource.FILE) {
IFile file = (IFile)resource;
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
if (dw != null) {
try {
IWorkbenchPage page = dw.getActivePage();
if (page != null)
IDE.openEditor(page, file, true);
} catch (PartInitException e) {
MessageDialog.openError(dw.getShell(),
CUIPlugin.getResourceString(OP_ERROR), e.getMessage());
}
}
}
return true;
}
/**
* Stores the configuration element for the wizard. The config element will be used
* in <code>performFinish</code> to set the result perspective.
*
* @see IExecutableExtension#setInitializationData
*/
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
fConfigElement= cfig;
}
/*
* Reimplemented method from superclass
*/
protected void initializeDefaultPageImageDescriptor() {
setDefaultPageImageDescriptor(CPluginImages.DESC_WIZABAN_NEW_PROJ);
}
/* (non-Javadoc)
* Method declared on IWorkbenchWizard.
*/
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
super.init(workbench, currentSelection);
setWindowTitle(CUIPlugin.getResourceString(WINDOW_TITLE));
}
public IRunnableWithProgress getRunnable() {
return new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
monitor.beginTask(CUIPlugin.getResourceString(OP_DESC), 3);
doRunPrologue(new SubProgressMonitor(monitor, 1));
try {
doRun(new SubProgressMonitor(monitor, 1));
}
catch (CoreException e) {
throw new InvocationTargetException(e);
}
doRunEpilogue(new SubProgressMonitor(monitor, 1));
monitor.done();
}
};
}
/**
* Utility method: call a runnable in a WorkbenchModifyDelegatingOperation
*/
protected boolean invokeRunnable(IRunnableWithProgress runnable) {
IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
try {
getContainer().run(false, true, op);
} catch (InvocationTargetException e) {
Shell shell= getShell();
String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
Throwable th= e.getTargetException();
if (th instanceof CoreException) {
IStatus status= ((CoreException)th).getStatus();
if (status != null) {
ErrorDialog.openError(shell, title, message, status);
CUIPlugin.getDefault().log(status);
return false;
}
}
MessageDialog.openError(shell, title, message);
CUIPlugin.getDefault().log(th);
try {
getProjectHandle().delete(false, false, null);
} catch (CoreException ignore) {
} catch (UnsupportedOperationException ignore) {
}
return false;
} catch (InterruptedException e) {
return false;
}
return true;
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
createNewProject(monitor);
// Associate the project with the standard builder so the clients can get proper information
try {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(newProject);
desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, StandardBuildManager.INTERFACE_IDENTITY);
} catch (CoreException e) {
// TODO Flag the error to the user
}
}
/**
* Creates a new project resource with the selected name.
* <p>
* In normal usage, this method is invoked after the user has pressed Finish on
* the wizard; the enablement of the Finish button implies that all controls
* on the pages currently contain valid values.
* </p>
* <p>
* Note that this wizard caches the new project once it has been successfully
* created; subsequent invocations of this method will answer the same
* project resource without attempting to create it again.
* </p>
*
* @return the created project resource, or <code>null</code> if the project
* was not created
*/
protected IProject createNewProject(IProgressMonitor monitor) throws CoreException {
if (newProject != null)
return newProject;
// get a project handle
IProject newProjectHandle = null;
try {
newProjectHandle = getProjectHandle();
} catch (UnsupportedOperationException e) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, e.getMessage(), null));
}
// get a project descriptor
IPath defaultPath = Platform.getLocation();
IPath newPath = getLocationPath();
if (defaultPath.equals(newPath))
newPath = null;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
description.setLocation(newPath);
newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID());
return newProject;
}
/**
* Method getID.
* @return String
*/
public abstract String getProjectID();
}

View file

@ -1,354 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.File;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.DirectoryDialog;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.internal.IHelpContextIds;
/**
* @deprecated
* Standard main page for a wizard that is creates a project resource.
* <p>
* This page may be used by clients as-is; it may be also be subclassed to suit.
* </p>
* <p>
* Example useage:
* <pre>
* mainPage = new CProjectWizardPage("basicCProjectPage");
* mainPage.setTitle("Project");
* mainPage.setDescription("Create a new project resource.");
* </pre>
* </p>
*/
public class CProjectWizardPage extends WizardPage {
protected boolean useDefaults = true;
// initial value stores
private String initialProjectFieldValue;
private IPath initialLocationFieldValue;
// widgets
private Text projectNameField;
protected Text locationPathField;
protected Label locationLabel;
protected Button browseButton;
protected CProjectWizard wizard;
private Listener nameModifyListener = new Listener() {
public void handleEvent(Event e) {
setLocationForSelection();
setPageComplete(validatePage());
}
};
private Listener locationModifyListener = new Listener() {
public void handleEvent(Event e) {
setPageComplete(validatePage());
}
};
// constants
private static final int SIZING_TEXT_FIELD_WIDTH = 250;
private static final int SIZING_INDENTATION_WIDTH = 10;
/** (non-Javadoc)
* Method declared on IDialogPage.
*/
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
WorkbenchHelp.setHelp(composite, IHelpContextIds.NEW_PROJECT_WIZARD_PAGE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
createProjectNameGroup(composite);
createProjectLocationGroup(composite);
projectNameField.setFocus();
validatePage();
// Show description on opening
setErrorMessage(null);
setMessage(null);
setControl(composite);
}
/**
* Creates the project location specification controls.
*
* @param parent the parent composite
*/
private final void createProjectLocationGroup(Composite parent) {
// project specification group
Composite projectGroup = new Composite(parent,SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Button useDefaultsButton = new Button(projectGroup, SWT.CHECK | SWT.RIGHT);
useDefaultsButton.setText(CUIPlugin.getResourceString("CProjectWizardPage.useDefaultLabel")); //$NON-NLS-1$
useDefaultsButton.setSelection(this.useDefaults);
GridData buttonData = new GridData();
buttonData.horizontalSpan = 3;
useDefaultsButton.setLayoutData(buttonData);
createUserSpecifiedProjectLocationGroup(projectGroup,!this.useDefaults);
SelectionListener listener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
useDefaults = useDefaultsButton.getSelection();
browseButton.setEnabled(!useDefaults);
locationPathField.setEnabled(!useDefaults);
locationLabel.setEnabled(!useDefaults);
setLocationForSelection();
if (!useDefaults)
locationPathField.setText(""); //$NON-NLS-1$
}
};
useDefaultsButton.addSelectionListener(listener);
}
/**
* Creates the project name specification controls.
*
* @param parent the parent composite
*/
private final void createProjectNameGroup(Composite parent) {
// project specification group
Composite projectGroup = new Composite(parent,SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// new project label
Label projectLabel = new Label(projectGroup,SWT.NONE);
projectLabel.setText(CUIPlugin.getResourceString("CProjectWizardPage.nameLabel")); //$NON-NLS-1$
// new project name entry field
projectNameField = new Text(projectGroup, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
projectNameField.setLayoutData(data);
// Set the initial value first before listener
// to avoid handling an event during the creation.
if (initialProjectFieldValue != null)
projectNameField.setText(initialProjectFieldValue);
projectNameField.addListener(SWT.Modify, nameModifyListener);
projectNameField.setVisible(true);
}
/**
* Creates the project location specification controls.
*
* @param projectGroup the parent composite
* @param boolean - the initial enabled state of the widgets created
*/
private void createUserSpecifiedProjectLocationGroup(Composite projectGroup, boolean enabled) {
// location label
locationLabel = new Label(projectGroup,SWT.NONE);
locationLabel.setText(CUIPlugin.getResourceString("CProjectWizardPage.locationLabel")); //$NON-NLS-1$
locationLabel.setEnabled(enabled);
// project location entry field
locationPathField = new Text(projectGroup, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = SIZING_TEXT_FIELD_WIDTH;
locationPathField.setLayoutData(data);
locationPathField.setEnabled(enabled);
// browse button
browseButton = new Button(projectGroup, SWT.PUSH);
browseButton.setText(CUIPlugin.getResourceString("CProjectWizardPage.browseLabel")); //$NON-NLS-1$
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleLocationBrowseButtonPressed();
}
});
browseButton.setEnabled(enabled);
// Set the initial value first before listener
// to avoid handling an event during the creation.
if (initialLocationFieldValue != null)
locationPathField.setText(initialLocationFieldValue.toOSString());
locationPathField.addListener(SWT.Modify, locationModifyListener);
}
/**
* Returns the current project location path as entered by
* the user, or its anticipated initial value.
*
* @return the project location path, its anticipated initial value, or <code>null</code>
* if no project location path is known
*/
public IPath getLocationPath() {
if (useDefaults)
return initialLocationFieldValue;
return new Path(locationPathField.getText());
}
/**
* Creates a project resource handle for the current project name field value.
* <p>
* This method does not create the project resource; this is the responsibility
* of <code>IProject::create</code> invoked by the new project resource wizard.
* </p>
*
* @return the new project resource handle
*/
public IProject getProjectHandle() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
}
/**
* Returns the current project name as entered by the user, or its anticipated
* initial value.
*
* @return the project name, its anticipated initial value, or <code>null</code>
* if no project name is known
*/
public String getProjectName() {
if (projectNameField == null)
return initialProjectFieldValue;
return projectNameField.getText();
}
/**
* Open an appropriate directory browser
*/
protected void handleLocationBrowseButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell());
dialog.setMessage(CUIPlugin.getResourceString("CProjectWizardPage.directoryLabel")); //$NON-NLS-1$
String dirName = locationPathField.getText();
if (!dirName.equals("")) {//$NON-NLS-1$
File path = new File(dirName);
if (path.exists())
dialog.setFilterPath(dirName);
}
String selectedDirectory = dialog.open();
if (selectedDirectory != null)
locationPathField.setText(selectedDirectory);
}
/**
* Creates a new project creation wizard page.
*
* @param pageName the name of this page
*/
public CProjectWizardPage(CProjectWizard wizard, String pageName) {
super(pageName);
setPageComplete(false);
this.initialLocationFieldValue = Platform.getLocation();
this.wizard = wizard;
}
/**
* Set the location to the default location if we are set to useDefaults.
*/
protected void setLocationForSelection() {
if (useDefaults) {
IPath defaultPath = Platform.getLocation().append(projectNameField.getText());
locationPathField.setText(defaultPath.toOSString());
}
}
/**
* Returns whether this page's controls currently all contain valid
* values.
*
* @return <code>true</code> if all controls are valid, and
* <code>false</code> if at least one is invalid
*/
protected boolean validatePage() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
String projectFieldContents = projectNameField.getText();
if (projectFieldContents.equals("")) { //$NON-NLS-1$
setErrorMessage(null);
setMessage(CUIPlugin.getResourceString("CProjectWizardPage.projectNameEmpty")); //$NON-NLS-1$
return false;
}
// Give a chance to the wizard to do its own validation
IStatus validName = wizard.isValidName(projectFieldContents);
if (!validName.isOK()) {
setErrorMessage(validName.getMessage());
return false;
}
IStatus nameStatus =
workspace.validateName(projectFieldContents, IResource.PROJECT);
if (!nameStatus.isOK()) {
setErrorMessage(nameStatus.getMessage());
return false;
}
String locationFieldContents = locationPathField.getText();
if (!locationFieldContents.equals("")) {//$NON-NLS-1$
// Give a chance to the wizard to do its own validation
IStatus validLocation = wizard.isValidLocation(projectFieldContents);
if (!validLocation.isOK()) {
setErrorMessage(validLocation.getMessage());
return false;
}
IPath path = new Path("");//$NON-NLS-1$
if (!path.isValidPath(locationFieldContents)) {
setErrorMessage(CUIPlugin.getResourceString("CProjectWizardPage.locationError")); //$NON-NLS-1$
return false;
}
if (!useDefaults && Platform.getLocation().isPrefixOf(new Path(locationFieldContents))) {
setErrorMessage(CUIPlugin.getResourceString("CProjectWizardPage.defaultLocationError")); //$NON-NLS-1$
return false;
}
}
if (getProjectHandle().exists()) {
setErrorMessage(CUIPlugin.getResourceString("CProjectWizardPage.projectExistsMessage")); //$NON-NLS-1$
return false;
}
setErrorMessage(null);
setMessage(null);
return true;
}
}

View file

@ -1,30 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
/**
* @deprecated
*
*/
public interface IWizardTab {
public String getLabel();
public Image getImage();
public Composite getControl(Composite parent);
public boolean isValid();
public void setVisible(boolean visible);
public void doRun(IProject project, IProgressMonitor monitor);
}

View file

@ -1,182 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.ArrayList;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.swt.IValidation;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
public class ReferenceBlock implements IWizardTab {
private static final String PREFIX = "ReferenceBlock"; // $NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$
private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
private CheckboxTableViewer referenceProjectsViewer;
private static final int PROJECT_LIST_MULTIPLIER = 15;
IProject project;
IValidation page;
/** (non-Javadoc)
* Method declared on IDialogPage.
*/
public Composite getControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(composite, SWT.LEFT);
label.setText(CUIPlugin.getResourceString(DESC));
GridData lbldata = new GridData(GridData.FILL_HORIZONTAL);
lbldata.horizontalSpan = 1;
label.setLayoutData(lbldata);
referenceProjectsViewer = ControlFactory.createListViewer
(composite, null, SWT.DEFAULT, SWT.DEFAULT, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
referenceProjectsViewer.setLabelProvider(new WorkbenchLabelProvider());
referenceProjectsViewer.setContentProvider(getContentProvider());
referenceProjectsViewer.setInput(ResourcesPlugin.getWorkspace());
initializeValues();
return composite;
}
public Image getImage() {
return CPluginImages.get(CPluginImages.IMG_OBJS_PROJECT);
}
public String getLabel() {
return CUIPlugin.getResourceString(LABEL);
}
/**
* Returns a content provider for the reference project
* viewer. It will return all projects in the workspace.
*
* @return the content provider
*/
protected IStructuredContentProvider getContentProvider() {
return new WorkbenchContentProvider() {
public Object[] getChildren(Object element) {
if (!(element instanceof IWorkspace))
return new Object[0];
ArrayList aList = new ArrayList(15);
final IProject[] projects = ((IWorkspace)element).getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
if (CoreModel.getDefault().hasCNature(projects[i])) {
// Do not show the actual project being look at
if ((project != null) && project.equals(projects[i])) {
continue;
}
aList.add(projects[i]);
}
}
return aList.toArray();
}
};
}
/**
* Get the default widget height for the supplied control.
* @return int
* @param control - the control being queried about fonts
* @param lines - the number of lines to be shown on the table.
*/
private static int getDefaultFontHeight(Control control, int lines) {
FontData[] viewerFontData = control.getFont().getFontData();
int fontHeight = 10;
//If we have no font data use our guess
if (viewerFontData.length > 0)
fontHeight = viewerFontData[0].getHeight();
return lines * fontHeight;
}
protected void initializeValues () {
if (project != null) {
try {
IProject[] referenced = project.getReferencedProjects();
referenceProjectsViewer.setCheckedElements(referenced);
} catch (CoreException e) {
}
}
}
/**
* Returns the referenced projects selected by the user.
*
* @return the referenced projects
*/
public IProject[] getReferencedProjects() {
Object[] elements = referenceProjectsViewer.getCheckedElements();
IProject[] projects = new IProject[elements.length];
System.arraycopy(elements, 0, projects, 0, elements.length);
return projects;
}
public boolean isValid() {
return true;
}
public void setVisible(boolean visible) {
}
public void doRun(IProject project, IProgressMonitor monitor) {
IProject[] refProjects = getReferencedProjects();
if (refProjects != null) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("Reference Projects", 1);
try {
IProjectDescription description = project.getDescription();
description.setReferencedProjects(refProjects);
project.setDescription(description, new SubProgressMonitor(monitor, 1));
} catch (CoreException e) {
}
}
}
/**
*
*/
public ReferenceBlock(IValidation page) {
this(page, null);
}
public ReferenceBlock(IValidation page, IProject project) {
super();
this.page = page;
this.project = project;
}
}

View file

@ -1,104 +0,0 @@
package org.eclipse.cdt.ui.wizards;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.cdt.internal.ui.wizards.swt.MGridData;
import org.eclipse.cdt.internal.ui.wizards.swt.MGridLayout;
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
import org.eclipse.cdt.utils.ui.swt.IValidation;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
/**
* @deprecated
* Standard main page for a wizard that is creates a project resource.
* <p>
* This page may be used by clients as-is; it may be also be subclassed to suit.
* </p>
* <p>
* Example useage:
* <pre>
* mainPage = new CProjectWizardPage("basicCProjectPage");
* mainPage.setTitle("Project");
* mainPage.setDescription("Create a new project resource.");
* </pre>
* </p>
*/
public class TabFolderPage extends WizardPage implements IValidation {
private static final String WZ_TITLE= "TabFolderPage.title";
private static final String WZ_DESC= "TabFolderPage.desc";
protected TabFolder tabFolder;
protected CProjectWizard wizard;
/** (non-Javadoc)
* Method declared on IDialogPage.
*/
public void createControl(Composite parent) {
Composite composite= new Composite(parent, SWT.NONE);
MGridLayout layout= new MGridLayout();
layout.marginWidth= 0;
layout.marginHeight= 5;
layout.minimumWidth= 450;
layout.minimumHeight= 350;
layout.numColumns= 1;
composite.setLayout(layout);
tabFolder = new TabFolder(composite, SWT.NONE);
tabFolder.setLayout(new TabFolderLayout());
MGridData gd= new MGridData();
gd.horizontalAlignment= MGridData.FILL;
gd.grabExcessHorizontalSpace= true;
gd.verticalAlignment= MGridData.FILL;
gd.grabExcessVerticalSpace= true;
tabFolder.setLayoutData(gd);
wizard.addTabItems(tabFolder);
//tabFolder.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// //tabChanged(e.item);
// }
//});
setControl(composite);
}
public void setComplete(boolean complete) {
setPageComplete(isPageComplete());
}
public TabFolder getTabFolder() {
return tabFolder;
}
public void setVisible(boolean visible) {
super.setVisible(visible);
IWizardTab[] items = wizard.getTabItems();
for (int i = 0; i < items.length; i++) {
items[i].setVisible(visible);
}
}
public boolean isPageComplete() {
IWizardTab[] items = wizard.getTabItems();
for (int i = 0; i < items.length; i++) {
if (!(items[i].isValid()))
return false;
}
return true;
}
public TabFolderPage(CProjectWizard wizard) {
super("CProjectWizardTabPage");
this.wizard = wizard;
}
}

View file

@ -1,15 +0,0 @@
package org.eclipse.cdt.utils.ui.swt;
/**
* @deprecated
*
*/
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
public interface IValidation {
public void setComplete(boolean complete);
}