KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > ChangeElement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ltk.internal.ui.refactoring;
12
13 import org.eclipse.core.runtime.CoreException;
14
15 import org.eclipse.ltk.core.refactoring.Change;
16 import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;
17
18 /**
19  * Instances of <code>ChangeElement<code> are used to present <code>
20  * IChange</code> object as nodes in a tree.
21  */

22 public abstract class ChangeElement {
23     
24     /** Flag indicating that the change element isn't active */
25     public final static int INACTIVE= 0;
26     /** Flag indicating that the change element is partly active (some children are inactive) */
27     public final static int PARTLY_ACTIVE= 1;
28     /** Flage indicating that the change element is active */
29     public final static int ACTIVE= 2;
30     
31     protected final static int[][] ACTIVATION_TABLE= new int[][] {
32                                 /*INACTIVE*/ /*PARTLY_ACTIVE */ /*ACTIVE */
33         /* INACTIVE */ { INACTIVE, PARTLY_ACTIVE, PARTLY_ACTIVE },
34         /* PARTLY_ACTIVE*/ { PARTLY_ACTIVE, PARTLY_ACTIVE, PARTLY_ACTIVE },
35         /* ACTIVE */ { PARTLY_ACTIVE, PARTLY_ACTIVE, ACTIVE}
36     };
37     
38     protected static final ChangeElement[] EMPTY_CHILDREN= new ChangeElement[0];
39     
40     private ChangeElement fParent;
41
42     /**
43      * Creates a new <code>ChangeElement</code> with the
44      * given parent
45      *
46      * @param parent the change element's parent or <code>null
47      * </code> if the change element doesn't have a parent
48      */

49     public ChangeElement(ChangeElement parent) {
50         fParent= parent;
51     }
52
53     /**
54      * Returns the change element's parent.
55      *
56      * @return the change element's parent
57      */

58     public ChangeElement getParent() {
59         return fParent;
60     }
61     
62     /**
63      * Returns the viewer descriptor used to present a preview of this change element
64      *
65      * @return the viewer suitable to present a preview of this change or
66      * <code>null</code> if no previewer is configured.
67      *
68      * @throws CoreException if an error occurred while creating the descriptor
69      */

70     public abstract ChangePreviewViewerDescriptor getChangePreviewViewerDescriptor() throws CoreException;
71     
72     public abstract void feedInput(IChangePreviewViewer viewer) throws CoreException;
73     
74     /**
75      * Returns the change directly associated with this change element or <code
76      * null</code> if the element isn't associated with a change.
77      *
78      * @return the change or <code>null</code>
79      */

80     public abstract Change getChange();
81     
82     /**
83      * Sets the activation status for this <code>ChangeElement</code>. When a
84      * change element is not active, then executing it is expected to do nothing.
85      *
86      * @param enabled the activation status for this change element
87      */

88     public abstract void setEnabled(boolean enabled);
89     
90     /**
91      * Sets the activation status for this <code>ChangeElement</code>. When a
92      * change element is not active, then executing it is expected to do nothing.
93      *
94      * @param enabled the activation status for this change element
95      */

96     public abstract void setEnabledShallow(boolean enabled);
97     
98     /**
99      * Returns the activation status of this <code>ChangeElement</code>.
100      * Returns one of the following values: <code>IChange.ACTIVE</code>
101      * if the node and all its children are active, <code>IChange.INACTIVE</code>
102      * if all children and the node itself is inactive, and <code>IChange.PARTLY_ACTIVE
103      * </code>otherwise.
104      *
105      * @return the change element's activation status.
106      */

107     public abstract int getActive();
108     
109     /**
110      * Returns the element the change node represents. The method may return
111      * <code>null</code> if the change node isn't related to an element.
112      *
113      * @return the element modified by this change node
114      */

115     public abstract Object JavaDoc getModifiedElement();
116     
117     /**
118      * Returns the change element's children.
119      *
120      * @return the change element's children.
121      */

122     public abstract ChangeElement[] getChildren();
123 }
Popular Tags