java - Get the selected model element in GMF editor -
i have gmf editor different elements on model. once select particular model element, how in handler ? currently, fetch elements present, using following code fragment:
palladiocomponentmodeldiagrameditor diag = (palladiocomponentmodeldiagrameditor)handlerutil.getactiveeditorchecked(event); final list children = diag.getdiagrameditpart().getchildren();
i quite new gmf , hence question.
not 100% sure understand question. if want find element that's selected in diagram editor, can use selectionprovider
, example this:
iselectionprovider selprovider = diagrameditor.geteditorsite().getselectionprovider(); if (selprovider.getselection() instanceof istructuredselection) { istructuredselection selection = (istructuredselection) selprovider.getselection(); object selected = selection.getfirstelement(); if (selected instanceof igraphicaleditpart) { igraphicaleditpart editpart = (igraphicaleditpart) selected; eobject eobject = ((view) editpart.getmodel()).getelement(); // stuff selected eobject } }
Comments
Post a Comment