0

If I want to get a view by entering the ID using this code,so from where I can get the MyView.ID?

IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
        .findView(MyView.ID);
    if (part instanceof MyView) {
        MyView view = (MyView) part;

1 Answer 1

1

You can either find the plugin that contributes the view and look in its 'plugin.xml' to find the org.eclipse.ui.views extension point that defines the view.

Or you can use the Eclipse plugin spy tool to identify the view.

Debug has many views so I'm not sure which one you are asking about. The one labelled 'Debug' has id org.eclipse.debug.ui.DebugView

8
  • what's the difference between MyView and MyView.ID
    – BO.J
    Commented Jun 30, 2016 at 7:25
  • The findView parameter is a string containing the view id. The returned object will be a class implementing IViewPart which you can cast to the actual view class if you know what it is. MyView.ID and MyView are just example names.
    – greg-449
    Commented Jun 30, 2016 at 7:35
  • and how I can know the class of the actual view?
    – BO.J
    Commented Jun 30, 2016 at 7:43
  • for example if I want to read the contents of the debug View and the ID is org.eclipse.debug.ui.DebugView , how to know the class?
    – BO.J
    Commented Jun 30, 2016 at 7:45
  • 1
    Plugin spy will tell you or you look at the plugin's plugin.xml. However for org.eclipse.debug.ui.DebugView the class is org.eclipse.debug.internal.ui.views.launch.LaunchView which is an internal class. You must not use internal classes Eclipse API Rules of Engagement. The debug system provides plenty of extension points which provide a much better way to get information.
    – greg-449
    Commented Jun 30, 2016 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.