[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-ui-dev] Workbench editor cycling
|
Jared,
Are you writing a patch to the Workbench code or a separate plugin?
I was under the impression you were making a patch, in which case you
could just use cycleEditors as is. In this case, it would make more sense
for it to go in your patch rather than the current Workbench code since
it's no longer needed by the Workbench (which is why I deleted it, and
suggested you just copy it, to make your patch more self-contained).
If you're writing a separate plugin (which is probably the better way to
go anyway), then WorkbenchPage.getSortedEditors() cannot be used since it is non-API. WorkbenchPage is an internal class.
The interface IWorkbenchPage is the public API.
However, it is unlikely we will be adding new API in this area in the 2.0
timeframe.
For now, I've added the method back to WorkbenchPage. Despite it being
internal, you can use it for now and we'll consider what API would be
appropriate to add post 2.0.
It may be better to add something more general, akin to Control.moveAbove
and moveBelow in SWT, but for workbench parts.
Nick
Jared Burns <jared-eclipse@xxxxxxxxx>
Sent by: platform-ui-dev-admin@xxxxxxxxxxx
06/04/2002 12:37 AM
Please respond to platform-ui-dev
To: platform-ui-dev@xxxxxxxxxxx
cc:
Subject: Re: [platform-ui-dev] Workbench editor cycling
Quick recap: I'm writing a view for editor management which includes the
ability to navigate forward and backward through the editor activation
history. A few weeks ago I mentioned that a method I was using on
WorkbenchPage wasn't API, but that it should be considered for API because
it
could be useful to others. For some reason (Sorry, Nick, I still don't
understand), the response to this request was to delete the existing
method.
I was encouraged to reproduce the deleted functionality in my view.
Unfortunately, I haven't been able to do this since my view doesn't have
access to the internals of the workbench page's activation list.
The public method cycleEditors(boolean forward) on WorkbenchPage that I
was
using to cycle editors just activated the editor returned from the
cycleEditors method on the ActivationList (private inner class in the
WorkbenchPage). This method reads:
EditorPart cycleEditors(boolean forward) {
ArrayList editors = getEditors();
if (editors.size() >= 2) {
if (forward) {
// move the topmost editor to the bottom
IEditorPart top = (IEditorPart) editors.get(editors.size()-1);
parts.remove(top);
parts.add(0, top);
// get the next editor and move it on top of any views
IEditorPart next = (IEditorPart) editors.get(editors.size()-2);
setActive(next);
return next;
} else {
// move the bottom-most editor to the top
IEditorPart prev = (IEditorPart) editors.get(0);
setActive(prev);
return prev;
}
}
return null;
}
The WorkbenchPage still provides a public method getSortedEditors() that
returns the same editors as the getEditors() call above. So I can
reproduce
the part activation code. However, I can't copy the code in the "if
(forward)" case that moves the top editor to the bottom of the "parts"
collection.
Unless I'm mistaken (and I very well could be), the most I can do is:
public void cycleEditors(boolean forward) {
WorkbenchPage page= (WorkbenchPage)getPage();
IEditorPart[] editors= page.getSortedEditors();
if (editors.length >= 2) {
if (forward) {
// move the topmost editor to the bottom
page.activate(editors[editors.length-2]);
} else {
// move the bottom-most editor to the top
page.activate(editors[0]);
}
}
}
This code isn't enough, however, as it doesn't make the necessary updates
to
the state of the page's activation list.
The simplest fix is to return the old cycleEditors() to the WorkbenchPage.
Short of this, is there anything I can do to get the functionality that
was
removed?
Thanks,
- Jared
On Tuesday 26 March 2002 01:31 pm, you wrote:
> Jared,
>
> WorkbenchPage.cycleEditors(boolean) was stale code, left over from when
> Ctrl+F6 cycled the editors (a la MDI) rather than bringing up the editor
> switcher.
> I have deleted it (sorry).
>
> We currently have no plans to expose the activation history as API,
> although if you're working in the UI component, you can get it using the
> non-API method WorkbenchPage.getSortedEditors().
>
> Nick
>
>
> Jared Burns <jared-eclipse@xxxxxxxxx>
> Sent by: platform-ui-dev-admin@xxxxxxxxxxx
> 03/22/02 10:37 PM
> Please respond to platform-ui-dev
>
>
> To: platform-ui-dev@xxxxxxxxxxx
> cc:
> Subject: [platform-ui-dev] Workbench editor cycling
>
>
> WorkbenchPage includes a method cycleEditors(boolean forward) that
cycles
> through a history of editors (forward or backward) that is maintained in
> the
> page. I'd originally implemented my own mechanism for the EditorView I'm
> working on (http://dev.eclipse.org/bugs/show_bug.cgi?id=10941). Now that
> I've found this mechanism, of course, I'd rather throw out my duplicate
> work.
>
> Is there any plan to promote this method to API on IWorkbenchPage? Since
> I'm
> working in the UI component, I *could* just cast the page to the
> implementation type, but I'd prefer to use the interface.
>
> Thanks,
> - Jared
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ui-dev
>
>
>
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ui-dev
_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-ui-dev