KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > domain > EditingDomain


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EditingDomain.java,v 1.3 2005/06/08 06:17:06 nickb Exp $
16  */

17 package org.eclipse.emf.edit.domain;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.eclipse.emf.common.command.Command;
24 import org.eclipse.emf.common.command.CommandStack;
25 import org.eclipse.emf.common.util.TreeIterator;
26 import org.eclipse.emf.ecore.resource.Resource;
27 import org.eclipse.emf.ecore.resource.ResourceSet;
28 import org.eclipse.emf.edit.command.CommandParameter;
29 import org.eclipse.emf.edit.command.OverrideableCommand;
30
31
32 /**
33  * An editing domain manages a self-contained set of interrelated EMF models and the {@link Command}s that modify them.
34  * The models are maintained in the form of a {@link ResourceSet}.
35  * Commands that modify the model are typically created through the domain and are executed using the {@link CommandStack}.
36  * An optional feature of an editing domain, which is used to implement mapping domains,
37  * is the ability to override primitive commands, see {@link OverrideableCommand}.
38  *
39  * <p>
40  * The domain imposes a hierarchical structure upon the models
41  * via the results of the {@link #getChildren getChildren} and {@link #getParent getParent} methods.
42  * This is useful for implementing commands such as
43  * {@link org.eclipse.emf.edit.command.RemoveCommand}, which often needs to deduce the parent from which to remove a particular object,
44  * and {@link org.eclipse.emf.edit.command.CopyCommand}, which often needs to deduce all the children to copy recursively.
45  * This also meshes well with user interfaces, which often present a model hierarchically, i.e., as a tree.
46  */

47 public interface EditingDomain
48 {
49   /**
50    * This creates the specified resource in this editing domain's resource set.
51    */

52   Resource createResource(String JavaDoc fileNameURI);
53
54   /**
55    * This loads the specified resource into this editing domain's resource set.
56    */

57   Resource loadResource(String JavaDoc fileNameURI);
58
59   /**
60    * This returns the resource set within which all the created and loaded resources reside.
61    */

62   ResourceSet getResourceSet();
63
64   /**
65    * This creates a command of the type of the specified by the command class
66    * and acting upon the information specified in the given command parameter.
67    */

68   Command createCommand(Class JavaDoc commandClass, CommandParameter commandParameter);
69
70   /**
71    * This creates an override for the given command.
72    */

73   Command createOverrideCommand(OverrideableCommand command);
74
75   /**
76    * This returns a command queue for executing commands.
77    */

78   CommandStack getCommandStack();
79
80   /**
81    * This returns the children of the object.
82    */

83   Collection JavaDoc getChildren(Object JavaDoc object);
84
85   /**
86    * This returns the parent of the object.
87    */

88   Object JavaDoc getParent(Object JavaDoc object);
89
90   /**
91    * This returns the root of the object, i.e., .
92    */

93   Object JavaDoc getRoot(Object JavaDoc object);
94
95   /**
96    * This returns a collection of objects describing the different children
97    * that can be added under the specified object. If a sibling is
98    * specified (non-null), the children should be as close to immediately
99    * following that sibling as possible.
100    */

101   Collection JavaDoc getNewChildDescriptors(Object JavaDoc object, Object JavaDoc sibling);
102
103   /**
104    * This returns a tree iterator that will yield the object, the children of the object, their children, and so on.
105    */

106   TreeIterator treeIterator(Object JavaDoc object);
107
108   /**
109    * This returns a path from the root object to the given object in the tree.
110    */

111   List JavaDoc getTreePath(Object JavaDoc object);
112
113
114   /**
115    * This returns the clipboard of the editing domain.
116    */

117   Collection JavaDoc getClipboard();
118
119   /**
120    * This sets the clipboard of the editing domain.
121    */

122   void setClipboard(Collection JavaDoc clipboard);
123
124   /**
125    * This returns whether or not copy command optimizations are safe in this domain.
126    */

127   boolean getOptimizeCopy();
128
129   /**
130    * This returns whether the resource is read only in editing domain.
131    */

132   boolean isReadOnly(Resource resource);
133 }
134
Popular Tags