KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > structuremergeviewer > DiffElement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.compare.structuremergeviewer;
12
13 import org.eclipse.swt.graphics.Image;
14 import org.eclipse.compare.ITypedElement;
15
16 /**
17  * An abstract base implementation of the <code>IDiffElement</code> interface.
18  * <p>
19  * Subclasses may add behavior and state, and may override <code>getImage</code>
20  * and <code>getType</code> to suit.
21  * </p>
22  */

23 public abstract class DiffElement implements IDiffElement {
24
25     private int fKind;
26     private IDiffContainer fParent;
27
28     /**
29      * Creates a new <code>DiffElement</code> as a child of the given parent.
30      * If parent is not <code>null</code> the new element is added to the parent.
31      *
32      * @param parent the parent of this child; if not <code>null</code> this element is automatically added as a child
33      * @param kind the kind of change
34      */

35     public DiffElement(IDiffContainer parent, int kind) {
36         fParent= parent;
37         fKind= kind;
38         if (parent != null)
39             parent.add(this);
40     }
41
42     /**
43      * The <code>DiffElement</code> implementation of this <code>ITypedInput</code>
44      * method returns <code>null</code>. Subclasses may re-implement to provide
45      * an image for this element.
46      * @return <code>null</code>.
47      */

48     public Image getImage() {
49         return null;
50     }
51
52     /**
53      * The <code>DiffElement</code> implementation of this <code>ITypedElement</code>
54      * method returns <code>ITypedElement.UNKNOWN_TYPE</code>. Subclasses may
55      * re-implement to provide a type for this element.
56      * @return <code>ITypedElement.UNKNOWN_TYPE</code>.
57      */

58     public String JavaDoc getType() {
59         return ITypedElement.UNKNOWN_TYPE;
60     }
61
62     /**
63      * Sets the kind of difference for this element.
64      *
65      * @param kind set the kind of difference this element represents
66      * @see Differencer
67      */

68     public void setKind(int kind) {
69         fKind= kind;
70     }
71
72     /* (non Javadoc)
73      * see IDiffElement.getKind
74      */

75     public int getKind() {
76         return fKind;
77     }
78
79     /* (non Javadoc)
80      * see IDiffElement.getParent
81      */

82     public IDiffContainer getParent() {
83         return fParent;
84     }
85
86     /* (non Javadoc)
87      * see IDiffElement.setParent
88      */

89     public void setParent(IDiffContainer parent) {
90         fParent= parent;
91     }
92 }
93
94
Popular Tags