Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Selected widget on Grapfical Viewer(How to get informations about the selected widget on the Grapfical Viewer)
Selected widget on Grapfical Viewer [message #872677] Wed, 16 May 2012 15:22 Go to next message
F S is currently offline F SFriend
Messages: 2
Registered: May 2012
Junior Member
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 Go to previous message
F S is currently offline F SFriend
Messages: 2
Registered: May 2012
Junior Member
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
Previous Topic:dropdown for table column
Next Topic:No Java Application with Window Builder
Goto Forum:
  


Current Time: Fri Apr 26 05:38:36 GMT 2024

Powered by FUDForum. Page generated in 0.03571 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top