Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 86855d66a7331a8848a8a442845f05bd7665f3cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) 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:
 *     Soyatec - initial API and implementation
 *******************************************************************************/
package org.eclipse.papyrus.xwt.databinding;

import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.internal.databinding.viewers.ViewerObservableValueDecorator;
import org.eclipse.jface.viewers.Viewer;

public class TypedViewerObservableValueDecorator extends ViewerObservableValueDecorator {

	protected Object elementType;

	public TypedViewerObservableValueDecorator(IObservableValue decorated, Viewer viewer) {
		super(decorated, viewer);
	}

	public Object getElementType() {
		return elementType;
	}

	public void setElementType(Object elementType) {
		this.elementType = elementType;
	}

	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof TypedViewerObservableValueDecorator)) {
			return false;
		}
		TypedViewerObservableValueDecorator decorator = (TypedViewerObservableValueDecorator)obj;
		if(elementType != null) {
			if(!elementType.equals(decorator.elementType)) {
				return false;
			}
		} else if(decorator.elementType != null) {
			return false;
		}
		return super.equals(obj);
	}

	@Override
	public int hashCode() {
		if(elementType == null) {
			return super.hashCode();
		}
		return elementType.hashCode() * super.hashCode();
	}

	@Override
	public Object getValueType() {
		Object elementType = getElementType();
		if(elementType != null) {
			return elementType;
		}
		return super.getValueType();
	}
}

Back to the top