You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Joacim Breiler <jo...@gmail.com> on 2020/11/11 20:11:46 UTC

Single editor window

Hi,

I am trying to figure out how to make a an editor so that it only show one file at the time. Any previous open editor should be closed or replaced.

We have solved this temporarily where we close all other open files after we've initiated the OpenCookie.open() of the new file, but would like to know the "right" way of doing this:
private void openFile() {
        try {
            FileObject fo = FileUtil.toFileObject(backend.getGcodeFile());
            DataObject dOb = DataObject.find(fo);
            dOb.getLookup().lookup(OpenCookie.class).open();
            java.awt.EventQueue.invokeLater(this::closeOpenFile);
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
}

https://github.com/winder/Universal-G-Code-Sender/blob/master/ugs-platform/ugs-platform-gcode-editor/src/main/java/com/willwinder/ugs/nbp/editor/actions/EditGcodeFile.java#L127 <https://github.com/winder/Universal-G-Code-Sender/blob/master/ugs-platform/ugs-platform-gcode-editor/src/main/java/com/willwinder/ugs/nbp/editor/actions/EditGcodeFile.java#L127>

Thanks,
Joacim Breiler