Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] model changes

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.2
diff -u -r1.2 ChangeLog
--- ChangeLog	14 Oct 2002 20:24:28 -0000	1.2
+++ ChangeLog	15 Oct 2002 17:36:47 -0000
@@ -12,3 +12,15 @@
 	* 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.
+		  
\ No newline at end of file
Index: org/eclipse/cdt/core/model/CoreModel.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java,v
retrieving revision 1.3
diff -u -r1.3 CoreModel.java
--- org/eclipse/cdt/core/model/CoreModel.java	26 Sep 2002 17:21:39 -0000	1.3
+++ org/eclipse/cdt/core/model/CoreModel.java	15 Oct 2002 17:33:15 -0000
@@ -11,7 +11,6 @@
 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.
 
@@ -21,64 +20,6 @@
 	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 @@
 		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 @@
 
 	private CoreModel() {
 	}
+
 }
Index: org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.4
diff -u -r1.4 CModelManager.java
--- org/eclipse/cdt/internal/core/model/CModelManager.java	13 Oct 2002 21:30:28 -0000	1.4
+++ org/eclipse/cdt/internal/core/model/CModelManager.java	15 Oct 2002 17:33:15 -0000
@@ -7,13 +7,12 @@
  
 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.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 @@
 
 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 @@
 		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 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 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);
Index: org/eclipse/cdt/internal/core/model/CModelStatus.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelStatus.java,v
retrieving revision 1.1
diff -u -r1.1 CModelStatus.java
--- org/eclipse/cdt/internal/core/model/CModelStatus.java	26 Jun 2002 20:37:14 -0000	1.1
+++ org/eclipse/cdt/internal/core/model/CModelStatus.java	15 Oct 2002 17:33:15 -0000
@@ -4,17 +4,15 @@
  * (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 @@
 
 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 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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;
 	}
 

Back to the top