1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00
This commit is contained in:
David Inglis 2002-10-15 17:47:49 +00:00
parent 0a42098b56
commit f1f4284c8c
4 changed files with 30 additions and 178 deletions

View file

@ -12,3 +12,14 @@
* src/../core/resources/ACBuilder.java:
* src/../internal/core/CBuilder.java:
Remove unused imports.
2002-10-15 David Inglis
* model/../core/model/CoreModel.java
* model/../internal/core/model/CModelManager.java
* model/../internal/core/model/CModelStatus.java
Clean up model
- removed plugin and nature id from model
refernce core plugin and nature classes for ID.
- removed unsed methods in model for adding/removing
natures.

View file

@ -11,7 +11,6 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
// This should be done in the Plugin.
@ -20,64 +19,6 @@ public class CoreModel {
private static CoreModel cmodel = null;
private static CModelManager manager = null;
/**
* Plugin string id.
*/
public final static String PLUGIN_ID = "org.eclipse.cdt.core";
/**
* C nature string name, "cnature".
*/
public final static String C_NATURE_NAME = "cnature";
/**
* C nature string id, PLUGIN_ID + C_NATURE_NAME
*/
public final static String C_NATURE_ID = PLUGIN_ID + "." + C_NATURE_NAME;
/**
* C++ nature string name, "ccnature"
*/
public final static String CC_NATURE_NAME = "ccnature";
/**
* C++ nature string id, PLUGIN_ID + CC_NATURE_NAME
*/
public final static String CC_NATURE_ID = PLUGIN_ID + "." + CC_NATURE_NAME;
/**
* Returns the plugin id.
*/
public static String getPluginId() {
return PLUGIN_ID;
}
/**
* Returns the C nature Name.
*/
public static String getCNatureName () {
return C_NATURE_NAME;
}
/**
* Returns the C++ nature name.
*/
public static String getCCNatureName () {
return CC_NATURE_NAME;
}
/**
* Returns the C nature Id.
*/
public static String getCNatureId () {
return C_NATURE_ID;
}
/**
* Returns the C++ nature Id.
*/
public static String getCCNatureId () {
return CC_NATURE_ID;
}
/**
* Creates an ICElement form and IPath.
* Returns null if not found.
@ -185,32 +126,6 @@ public class CoreModel {
return manager.hasCCNature(project);
}
public static void addCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.addCNature(project, monitor);
}
public static void addCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.addCCNature(project, monitor);
}
public static void removeCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.removeCNature(project, monitor);
}
public static void removeCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
manager.removeCCNature(project, monitor);
}
public static void addNature(IProject project, String natureId, IProgressMonitor monitor)
throws CModelException {
manager.addNature(project, natureId, monitor);
}
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor)
throws CModelException {
manager.removeNature(project, natureId, monitor);
}
/**
* Return the singleton.
*/
@ -238,4 +153,5 @@ public class CoreModel {
private CoreModel() {
}
}

View file

@ -7,13 +7,12 @@ package org.eclipse.cdt.internal.core.model;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IBinary;
@ -30,7 +29,6 @@ import org.eclipse.cdt.utils.elf.Elf;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
@ -45,10 +43,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class CModelManager implements IResourceChangeListener {
// FIXME: Get it from the plugin class.
private static String C_NATURE_ID = CoreModel.getCNatureId();
private static String CC_NATURE_ID = CoreModel.getCCNatureId();
private HashMap fParsedResources = new HashMap();
/**
@ -253,70 +247,6 @@ public class CModelManager implements IResourceChangeListener {
return croot;
}
public static void addCNature(IProject project, IProgressMonitor monitor) throws CModelException {
addNature(project, C_NATURE_ID, monitor);
}
public static void addCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
addNature(project, CC_NATURE_ID, monitor);
}
public static void removeCNature(IProject project, IProgressMonitor monitor) throws CModelException {
removeNature(project, C_NATURE_ID, monitor);
}
public static void removeCCNature(IProject project, IProgressMonitor monitor) throws CModelException {
removeNature(project, CC_NATURE_ID, monitor);
}
/**
* 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.
*
*/
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CModelException {
try {
IProjectDescription description = project.getDescription();
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];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= natureId;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
} catch (CoreException e) {
throw new CModelException(e);
}
}
/**
* 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.
*/
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CModelException {
try {
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
List newNatures = new ArrayList(Arrays.asList(prevNatures));
newNatures.remove(natureId);
description.setNatureIds((String[])newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, monitor);
} catch (CoreException e) {
throw new CModelException(e);
}
}
private void removeChildrenContainer(Parent container, IResource resource) {
if ( container.hasChildren() ) {
ICElement[] children = container.getChildren();
@ -489,7 +419,7 @@ public class CModelManager implements IResourceChangeListener {
public static boolean hasCNature (IProject p) {
boolean ok = false;
try {
ok = (p.isOpen() && p.hasNature(C_NATURE_ID));
ok = (p.isOpen() && p.hasNature(CProjectNature.C_NATURE_ID));
} catch (CoreException e) {
//throws exception if the project is not open.
//System.out.println (e);
@ -502,7 +432,7 @@ public class CModelManager implements IResourceChangeListener {
public static boolean hasCCNature (IProject p) {
boolean ok = false;
try {
ok = (p.isOpen() && p.hasNature(CC_NATURE_ID));
ok = (p.isOpen() && p.hasNature(CCProjectNature.CC_NATURE_ID));
} catch (CoreException e) {
//throws exception if the project is not open.
//System.out.println (e);

View file

@ -4,17 +4,15 @@ package org.eclipse.cdt.internal.core.model;
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* @see ICModelStatus
@ -22,9 +20,6 @@ import org.eclipse.cdt.core.model.CoreModel;
public class CModelStatus extends Status implements ICModelStatus, ICModelStatusConstants, IResourceStatus {
// FIXME: Use the value in the plugin.
private static String PLUGIN_ID = CoreModel.getPluginId();
/**
* The elements related to the failure, or <code>null</code>
* if no elements are involved.
@ -56,14 +51,14 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
*/
public CModelStatus() {
// no code for an multi-status
super(ERROR, PLUGIN_ID, 0, "CModelStatus", null); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, 0, "CModelStatus", null); //$NON-NLS-1$
}
/**
* Constructs an C model status with no corresponding elements.
*/
public CModelStatus(int code) {
super(ERROR, PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
//fElements= CElementInfo.fgEmptyChildren;
}
@ -72,7 +67,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* elements.
*/
public CModelStatus(int code, ICElement[] elements) {
super(ERROR, PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
fElements= elements;
fPath= null;
}
@ -81,7 +76,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* Constructs an C model status with no corresponding elements.
*/
public CModelStatus(int code, String string) {
super(ERROR, PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
//fElements= CElementInfo.fgEmptyChildren;
fPath= null;
fString = string;
@ -91,7 +86,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* Constructs an C model status with no corresponding elements.
*/
public CModelStatus(int code, Throwable throwable) {
super(ERROR, PLUGIN_ID, code, "CModelStatus", throwable); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, code, "CModelStatus", throwable); //$NON-NLS-1$
//fElements= CElementInfo.fgEmptyChildren;
}
@ -99,7 +94,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* Constructs an C model status with no corresponding elements.
*/
public CModelStatus(int code, IPath path) {
super(ERROR, PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, code, "CModelStatus", null); //$NON-NLS-1$
//fElements= CElementInfo.fgEmptyChildren;
fPath= path;
}
@ -125,7 +120,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* Constructs an C model status with no corresponding elements.
*/
public CModelStatus(CoreException coreException) {
super(ERROR, PLUGIN_ID, CORE_EXCEPTION, "CModelStatus", coreException); //$NON-NLS-1$
super(ERROR, CCorePlugin.PLUGIN_ID, CORE_EXCEPTION, "CModelStatus", coreException); //$NON-NLS-1$
//fElements= CElementInfo.fgEmptyChildren;
}