Skip to main content
summaryrefslogtreecommitdiffstats
blob: 36e6e55222278dc85539176690fd3da8c945f7bf (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
package org.eclipse.emf.refactor.refactoring.papyrus.managers;

import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
import org.eclipse.emf.refactor.refactoring.managers.SelectionManager;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.jface.viewers.ISelection;

@SuppressWarnings("restriction")
public class PapyrusSelectionManager extends SelectionManager {

	public static List<EObject> getESelection(ISelection selection) {
		if (selection == null)
			return null;
		List<EObject> r = SelectionManager.getESelection(selection);
		for (Object o : getSelection(selection)) {
			if (o instanceof ModelElementItem) {
				System.out.println("instanceof ModelElementItem");
				ModelElementItem mei = (ModelElementItem) o;
	    		System.out.println("element: " + mei.getEObject());
	    		r.add(mei.getEObject());
			} else {
				if (o instanceof IGraphicalEditPart) {
		    		System.out.println("instanceof IGraphicalEditPart");
		    		IGraphicalEditPart gep = (IGraphicalEditPart) o;
		    		System.out.println("element: " + gep.resolveSemanticElement());
		    		r.add(gep.resolveSemanticElement());
		    	} else {
		    		return null;
		    	}
			}
		}
		return r;
	}
	
}

Back to the top