Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Eclipse Integration (How to get the current object selected)

0 views
Skip to first unread message

Dave Couture

unread,
Jan 30, 2007, 3:33:45 PM1/30/07
to
I tried to create a Eclipse Plugin that open as Web Page based on the
stereotype of the element selected in Together. The purpose is to give to
the user documentation about the selected stereotype.

I create a Plugin with an Extension with a Point on
org.eclipse.ui.popupMenus. The object class on which the popup menu is
displayed is com.tssap.selena.model.ui.IElementWrapper and I add a filter
for metaclass Class20. My problem is that I'm not able to get an handle to
the class currently selected on the diagram. So I'm net able to ask for its
stereotype.

public class PopUpReferentiel implements IObjectActionDelegate {
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
// What should I do there?
}

Can anyone help?

Dave


ElenaA

unread,
Jan 31, 2007, 8:07:30 AM1/31/07
to

try the following:

public void run(IAction action) {

IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
ISelection mySelection =
workbenchWindow.getSelectionService().getSelection();
IStructuredSelection structuredSelection = (IStructuredSelection)
mySelection;

if (structuredSelection.size() == 1) {

Object selectedObject =
structuredSelection.getFirstElement();
EObject selectedEObject = (EObject)
Platform.getAdapterManager()
.getAdapter(selectedObject, EObject.class);

if (selectedEObject instanceof
com.borland.tg.emfapi.uml20.classes.Class) {

com.borland.tg.emfapi.uml20.classes.Class cls =
(com.borland.tg.emfapi.uml20.classes.Class) selectedEObject;

// write your code here
}
}

"Dave Couture" <dave_c...@dmr.ca> wrote in message
news:45bfab6e$1...@newsgroups.borland.com...

Dave Couture

unread,
Jan 31, 2007, 11:55:17 AM1/31/07
to
Great! It's working.

"ElenaA" <Elena.A...@borland.com> a écrit dans le message de news:
45c09453$1...@newsgroups.borland.com...

0 new messages