Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: adbcd4e8ff6be730b293afd2e9c49e741dd1083e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.examples.model;

import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;

public abstract class ModelObject extends PlatformObject {

	public static ModelObject create(IResource resource) {
		switch (resource.getType()) {
		case IResource.ROOT:
			return new ModelWorkspace();
		case IResource.PROJECT:
			return new ModelProject((IProject)resource);
		case IResource.FOLDER:
			return new ModelFolder((IFolder)resource);
		case IResource.FILE:
			if (ModelObjectDefinitionFile.isModFile(resource)) {
				return new ModelObjectDefinitionFile((IFile)resource);
			}
		}
		return null;
	}
	
	/**
	 * Return the name of the model object.
	 * @return the name of the model object
	 */
	public abstract String getName();

	/**
	 * Return the path of this object in the model namespace.
	 * @return the path of this object in the model namespace
	 */
	public abstract String getPath();

	/**
	 * Return the children of this object.
	 * @return the children of this object
	 */
	public abstract ModelObject[] getChildren() throws CoreException;

	/**
	 * Return the parent of this object.
	 * @return the parent of this object
	 */
	public abstract ModelObject getParent();

	/**
	 * Delete the model object
	 */
	public abstract void delete() throws CoreException;

	/**
	 * Return the project that contains this model object.
	 * @return the project that contains this model object
	 */
	public abstract ModelProject getProject();
}

Back to the top