Hi there,

I am struggling how to get access to the TopComponent of a file editor from
MultidataDataObject.

I register a multi view editor for that object type and now have all the
default cookies installed. However, I want to selette the source editor
view on "Edit" acion and the visual view on "Open".

So I did:

public RosterDataObject(FileObject pf, MultiFileLoader loader) throws
DataObjectExistsException, IOException {
        super(pf, loader);
        registerEditor("text/roster+xml", true);
        getCookieSet().add(new OpenCookie() {
            @Override
            public void open() {
                EditorCookie ec =
getCookieSet().getCookie(EditorCookie.class);
                ((CloneableEditorSupport)ec).
                ec.open();
                // TC is now supposed to be open and activated so we get it
                TopComponent activated =
WindowManager.getDefault().getRegistry().getActivated();
                MultiViewHandler mvh =
MultiViews.findMultiViewHandler(activated);
                for (MultiViewPerspective perspective :
mvh.getPerspectives()) {
                    if
(RosterVisualElement.ID.equals(perspective.preferredID())) {
                        mvh.requestActive(perspective);
                    }
                    System.err.println(perspective);
                }
            }
        });
    }

However, the problem is that I open the editor twice and I am not sure the
latter one is actually the active one.

Reply via email to