This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252174

Summary: EditorCookie.getEditorPanes() does not return both editors in split multiview
Product: platform Reporter: Jaroslav Tulach <jtulach>
Component: Window SystemAssignee: Stanislav Aubrecht <saubrecht>
Status: NEW ---    
Severity: normal CC: theofanis, tulach
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Two editors, but only one is found

Description Jaroslav Tulach 2015-04-30 07:53:38 UTC
Created attachment 153471 [details]
Two editors, but only one is found

Here is a sample action that prints all known JEditorPanes for currently selected node:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JEditorPane;
import org.openide.cookies.EditorCookie;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.IOProvider;
import org.openide.windows.OutputWriter;

@ActionID(
    category = "Edit",
    id = "cz.xelfi.bug.listeditors.ListEditors"
)
@ActionRegistration(
    displayName = "#CTL_ListEditors"
)
@ActionReference(path = "Menu/Tools", position = 0)
@Messages("CTL_ListEditors=List Editors")
public final class ListEditors implements ActionListener {

    private final EditorCookie context;

    public ListEditors(EditorCookie context) {
        this.context = context;
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        OutputWriter out = IOProvider.getDefault().getStdOut();
        out.println("Listing editor panes for " + context);
        for (JEditorPane openedPane : context.getOpenedPanes()) {
            out.println("  pane: " + openedPane);
        }
        out.println("And that is all!");
    }
}


if you open multiview editor and split it to two parts (as the attached image shows), the action returns just one JEditorPane in spite it is clear that there are two.

This violates the expected API contract and makes it hard to 3rd party code to find out currently selected editor and its caret.