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

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to