Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b665befb85eb3931bae390787b82ba7f133e14fd (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*******************************************************************************
 * Copyright (c) 2007 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.jface.tests.labelProviders;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.tests.viewers.ViewerTestCase;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;

/**
 * CompositeLabelProviderTest is the abstract superclass of the LabelProvider
 * tests that use multiple label provider suppliers.
 *
 * @since 3.3
 *
 */
public abstract class CompositeLabelProviderTest extends ViewerTestCase {

	class LabelTableContentProvider implements IStructuredContentProvider<TestElement,TestElement> {

		/*
		 * (non-Javadoc)
		 *
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
		 */
		public TestElement[] getElements(TestElement inputElement) {
			return fRootElement.getChildren();
		}

		/*
		 * (non-Javadoc)
		 *
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
		 */
		public void dispose() {

		}

		/*
		 * (non-Javadoc)
		 *
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
		 *      java.lang.Object, java.lang.Object)
		 */
		public void inputChanged(Viewer<? extends TestElement> viewer, TestElement oldInput, TestElement newInput) {

		}

	}

	Color background;
	Color foreground;
	Font font;

	/**
	 * Create a new instance of the receiver.
	 *
	 * @param name
	 */
	public CompositeLabelProviderTest(String name) {
		super(name);
	}

	/**
	 * Initialize the colors used by the receiver.
	 *
	 * @param parent
	 */
	void initializeColors(Control parent) {
		background = parent.getDisplay().getSystemColor(SWT.COLOR_RED);
		foreground = parent.getDisplay().getSystemColor(SWT.COLOR_BLUE);
		font = JFaceResources.getBannerFont();
	}

	class TestTreeContentProvider implements ITreeContentProvider<TestElement,TestElement> {

		public TestElement[] getChildren(TestElement parentElement) {
			return parentElement.getChildren();
		}

		public TestElement getParent(TestElement element) {
			return element.getContainer();
		}

		public boolean hasChildren(TestElement element) {
			return getChildren(element).length > 0;
		}

		public TestElement[] getElements(TestElement inputElement) {
			return fRootElement.getChildren();
		}

		public void dispose() {
		}

		public void inputChanged(Viewer<? extends TestElement> viewer, TestElement oldInput, TestElement newInput) {
		}

	}
}

Back to the top