changeset: 271817:f0fd6b446828 tag: tip user: Vladimir Voskresensky date: Wed Feb 12 21:36:01 2014 +0400 summary: fixing #241692 - can not open FindUsages result and jump from Navigator diff --git a/openide.text/src/org/openide/text/CloneableEditorSupport.java b/openide.text/src/org/openide/text/CloneableEditorSupport.java --- a/openide.text/src/org/openide/text/CloneableEditorSupport.java +++ b/openide.text/src/org/openide/text/CloneableEditorSupport.java @@ -905,6 +905,16 @@ return null; } + + @Override + protected void redirectedOpen(CloneableOpenSupport redirectedTo) { + super.redirectedOpen(redirectedTo); + // synchronize last selected field for correct getRecentPane query + if (redirectedTo instanceof CloneableEditorSupport) { + CloneableEditorSupport other = ((CloneableEditorSupport)redirectedTo); + this.lastSelected = other.lastSelected; + } + } /** Returns the lastly selected Pane or null */ diff --git a/openide.windows/src/org/openide/windows/CloneableOpenSupport.java b/openide.windows/src/org/openide/windows/CloneableOpenSupport.java --- a/openide.windows/src/org/openide/windows/CloneableOpenSupport.java +++ b/openide.windows/src/org/openide/windows/CloneableOpenSupport.java @@ -97,6 +97,7 @@ CloneableOpenSupport redirect = CloneableOpenSupportRedirector.findRedirect(this); if (redirect != null) { redirect.open(); + redirectedOpenImpl(redirect); return; } //Bugfix #10688 open() is now run in AWT thread @@ -246,6 +247,29 @@ */ protected abstract String messageOpened(); + private void redirectedOpenImpl(CloneableOpenSupport redirectedTo) { + // there is a common patern in user code: + // CloneableEditorSupport ces = ...; + // ces.edit(); + // JEditorPane[] panes = ces.getOpenedPanes(); + // if (panes != null) panes[0].setPosition(offset); + // in case when redirection has happened during edit() call + // 'ces' instance returns null for getOpenedPanes + // but we want panes to be available for 'ces' instance after redirection; + // remember editors from redirected instance to have correct opened panes + // for this instance as well + this.allEditors = redirectedTo.allEditors; +// this.env = redirect.env; + redirectedOpen(redirectedTo); + } + + /** + * notify that other redirected cos was opened instead of this one. + * @param redirectedTo redirected instance which was opened instead of this one + */ + protected void redirectedOpen(CloneableOpenSupport redirectedTo) { + } + /** Abstract interface that is used by CloneableOpenSupport to * talk to outside world. */