문제

I can get opened editors

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()

this way, but they are unordered(always returned the same way, it doesnt matter which window is first and which second). For plugin I implement its important for me to get them in order they are opened it, is there any way to do that?

도움이 되었습니까?

해결책

There's some indication here that you can't get what you want directly from the API.

But how about this: register an IPartListener (or, better yet, IPartListener2) with the page's IPartService. Then you ought to get part-opened and part-closed messages. From that you can keep your own ordering of editor parts (IEditorPart). You can use that directly, or combine it with what you get from getEditorReferences().

So I'm talking about something like:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(
   new IPartListener2() {
      private Stack<IWorkbenchPartReference> partStack = new Stack<IworkbenchPartReference>();

      public void partOpened(IWorkbenchPartReference ref) {
          partStack.push(ref);
      }

      public void partClosed(IWorkbenchPartReference ref) {
          partStack.pop(ref);
      }

      /* you'll need to implement or stub out the other methods of IPartListener2 */
      public void partActivated(IWorkbenchpartReference ref) {}
      public void partDeactivated(IWorkbenchpartReference ref) {}
      /* etc */

   }
);

Then you'll access that stack in your plugin.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top