KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > patch > PatchDiffNode


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.internal.patch;
12
13 import org.eclipse.compare.ITypedElement;
14 import org.eclipse.compare.patch.PatchConfiguration;
15 import org.eclipse.compare.structuremergeviewer.*;
16
17 public abstract class PatchDiffNode extends DiffNode {
18
19     private Object JavaDoc fElement;
20
21     public PatchDiffNode(Object JavaDoc patchElement, IDiffContainer parent, int kind,
22             ITypedElement ancestor, ITypedElement left, ITypedElement right) {
23         super(parent, kind, ancestor, left, right);
24         fElement = patchElement;
25     }
26
27     public PatchDiffNode(Object JavaDoc patchElement, IDiffContainer parent, int kind) {
28         super(parent, kind);
29         fElement = patchElement;
30     }
31
32     public boolean isEnabled() {
33         return getPatcher().isEnabled(getPatchElement());
34     }
35
36     public void setEnabled(boolean enabled) {
37         getPatcher().setEnabled(getPatchElement(), enabled);
38     }
39
40     protected final Patcher getPatcher() {
41         return Patcher.getPatcher(getConfiguration());
42     }
43
44     public Object JavaDoc getPatchElement() {
45         return fElement;
46     }
47
48     protected abstract PatchConfiguration getConfiguration();
49     
50     public boolean equals(Object JavaDoc other) {
51         if (other instanceof PatchDiffNode) {
52             PatchDiffNode node = (PatchDiffNode) other;
53             return (node.getPatchElement().equals(getPatchElement()));
54         }
55         return super.equals(other);
56     }
57     
58     public int hashCode() {
59         return getPatchElement().hashCode();
60     }
61
62 }
63
Popular Tags