Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4e59a920b3863b2a5f3a83bf54ae896b8194ea62 (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
116
117
118
119
120
121
122
123
/*******************************************************************************
 * Copyright (c) 2012 Mia-Software.
 * 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:
 *     Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
 *     Vincent Lorenzo (CEA-LIST) -  Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
 *******************************************************************************/
package org.eclipse.emf.facet.efacet.ui.internal.widget;

import java.util.Collection;
import java.util.List;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
import org.eclipse.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.FilteredTree;

public class SynchronizedETypedElementSelectionWidget extends SynchronizedObject<ETypedElementSelectionControlManager> implements
		IETypedElementSelectionWidgetInternal {

	private final ETypedElementSelectionControlManager control;

	protected IETypedElementSelectionWidgetInternal getControl() {
		return this.control;
	}

	public SynchronizedETypedElementSelectionWidget(final ETypedElementSelectionControlManager control) {
		super(control, control.getFilteredTree().getDisplay());
		this.control = control;
	}

	public void setAvailableETypedElements(final Collection<? extends ETypedElement> available) {
		voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
			@Override
			public void voidSafeRun() {
				getControl().setAvailableETypedElements(available);
			}
		});
	}

	public List<ETypedElement> getSelectedETypedElements() {
		return safeSyncExec(new AbstractExceptionFreeRunnable<List<ETypedElement>>() {
			@Override
			public List<ETypedElement> safeRun() {
				return getControl().getSelectedETypedElements();
			}
		});
	}

	public void setSelectedETypedElements(final Collection<? extends ETypedElement> elementsToSelect) {
		voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
			@Override
			public void voidSafeRun() {
				getControl().setSelectedETypedElements(elementsToSelect);
			}
		});
	}

	public void addOpenListener(final IOpenListener openListener) {
		voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
			@Override
			public void voidSafeRun() {
				getControl().addOpenListener(openListener);
			}
		});
	}

	public void addSelectionChangedListener(final ISelectionChangedListener listener) {
		voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
			@Override
			public void voidSafeRun() {
				getControl().addSelectionChangedListener(listener);
			}
		});
	}

	public IStatus getValidationStatus() {
		return safeSyncExec(new AbstractExceptionFreeRunnable<IStatus>() {
			@Override
			public IStatus safeRun() {
				return getControl().getValidationStatus();
			}
		});
	}

	public boolean isDisposed() {
		return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
			@Override
			public Boolean safeRun() {
				return Boolean.valueOf(getControl().isDisposed());
			}
		}).booleanValue();
	}

	public FilteredTree getFilteredTree() {
		// should not be used!
		throw new UnsupportedOperationException();
	}

	public void createContents() {
		// //nothing to do
		throw new UnsupportedOperationException();
	}

	public void setSelection(final IStructuredSelection selection) {
		voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
			@Override
			public void voidSafeRun() {
				getControl().setSelection(selection);
			}
		});
	}

}

Back to the top