Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b8bd9e2a7fa87621ca03cff7db929c28e9bdd3cc (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
package org.eclipse.papyrus.uml.properties.xtext.sheet;

import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.papyrus.extensionpoints.editors.Activator;
import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;

public class AdvancedEditingPropertySectionFilter implements IFilter {

	public boolean select(Object toTest) {
		if (toTest instanceof IGraphicalEditPart) {
			IGraphicalEditPart part = (IGraphicalEditPart) toTest;
			if (part.resolveSemanticElement() == null) {
				return false;
			}
			IPreferenceStore store = Activator.getDefault().getPreferenceStore();
			String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
					+ part.resolveSemanticElement().eClass().getInstanceClassName();
			String languagePreferred = store.getString(key);
			
			if (languagePreferred != null && !languagePreferred.equals("")) {
				IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(
						languagePreferred, part.resolveSemanticElement().eClass()
								.getInstanceClassName());
				return configuration instanceof ICustomDirectEditorConfiguration;
			}

		}
		return false;
	}
}

Back to the top