org.eclipse.compare.structuremergeviewer.DiffElement Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2000, 2011 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.compare.structuremergeviewer;
import org.eclipse.compare.ITypedElement;
import org.eclipse.swt.graphics.Image;
/**
* An abstract base implementation of the IDiffElement
interface.
*
* Subclasses may add behavior and state, and may override getImage
* and getType
to suit.
*
*/
public abstract class DiffElement implements IDiffElement {
private int fKind;
private IDiffContainer fParent;
/**
* Creates a new DiffElement
as a child of the given parent.
* If parent is not null
the new element is added to the parent.
*
* @param parent the parent of this child; if not null
this element is automatically added as a child
* @param kind the kind of change
*/
public DiffElement(IDiffContainer parent, int kind) {
fParent= parent;
fKind= kind;
if (parent != null)
parent.add(this);
}
/**
* The DiffElement
implementation of this ITypedInput
* method returns null
. Subclasses may re-implement to provide
* an image for this element.
* @return null
.
*/
@Override
public Image getImage() {
return null;
}
/**
* The DiffElement
implementation of this ITypedElement
* method returns ITypedElement.UNKNOWN_TYPE
. Subclasses may
* re-implement to provide a type for this element.
* @return ITypedElement.UNKNOWN_TYPE
.
*/
@Override
public String getType() {
return ITypedElement.UNKNOWN_TYPE;
}
/**
* Sets the kind of difference for this element.
*
* @param kind set the kind of difference this element represents
* @see Differencer
*/
public void setKind(int kind) {
fKind= kind;
}
@Override
public int getKind() {
return fKind;
}
@Override
public IDiffContainer getParent() {
return fParent;
}
@Override
public void setParent(IDiffContainer parent) {
fParent= parent;
}
}