Selected widget on Grapfical Viewer [message #872677] |
Wed, 16 May 2012 15:22  |
Eclipse User |
|
|
|
Hello
I have to create a view for extendet property editing. For this I need the 'element' of the selected widget in the window builder (GrapficalViewer).
Currently I have only found a way to get the 'selected text' (provided from the 'DesignerEditor'):
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(...)
Is there a way to get and manipulate the current selected widget?
Thanks for your help!
fs
|
|
|
Re: Selected widget on Grapfical Viewer [message #874644 is a reply to message #872677] |
Mon, 21 May 2012 10:02  |
Eclipse User |
|
|
|
Just for completeness below the prototype of my eclipse view. As we can see, there is only a way to get the current code line, the editor is 'editing'. But I have not found a way to get some informations about the selected widget (e.g. type or name)
Do you have an idea or hint to get this informations?
public class AdditionalWidgetInfoView extends ViewPart {
public AdditionalWidgetInfoView() {
}
@Override
public void createPartControl(Composite parent) {
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener("org.eclipse.wb.core.guiEditor", new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
TextSelection textSelection = (TextSelection)selection;
System.out.println("text: " + textSelection.getText());
IWorkbenchPart designerEditor = (DesignerEditor)part;
designerEditor.getSite().getSelectionProvider().getSelection();
}
});
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
// Evaluate the selection in the active editor.
IWorkbenchWindow workbenchWindow = getSite().getWorkbenchWindow();
if (workbenchWindow == null)
{
return;
}
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage == null)
{
return;
}
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor instanceof DesignerEditor)
{
DesignerEditor designerEditor = (DesignerEditor) activeEditor;
@SuppressWarnings("restriction")
TextSelection textSelection = (TextSelection)designerEditor.getSelectionProvider().getSelection();
int startLine = textSelection.getStartLine();
System.out.println("Element selected, line: " + startLine);
}
}
});
}
@Override
public void setFocus() {}
}
Best regards
fs
|
|
|
Powered by
FUDForum. Page generated in 0.03351 seconds