Search in sources :

Example 1 with FileEditor

use of com.mucommander.viewer.FileEditor in project mucommander by mucommander.

the class FileEditorPresenter method show.

@Override
protected void show(AbstractFile file) throws IOException {
    setCurrentFile(file);
    if (fileEditor == null) {
        getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        getFrame().addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                if (fileEditor != null) {
                    try {
                        fileEditor.close();
                    } catch (CloseCancelledException ex) {
                        return;
                    }
                }
                getFrame().dispose();
            }
        });
        MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
        editorMenu.addSeparator();
        closeMenuItem = MenuToolkit.addMenuItem(editorMenu, Translator.get("file_editor.close"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), (e) -> {
            try {
                fileEditor.close();
                getFrame().dispose();
            } catch (CloseCancelledException ex) {
            // cancelled
            }
        });
        editorMenu.add(closeMenuItem);
        try {
            switchFileEditor(0);
        } catch (CloseCancelledException ex) {
            Logger.getLogger(FileViewerPresenter.class.getName()).log(Level.SEVERE, "Unexpected cancellation", ex);
        }
    }
}
Also used : Cursor(java.awt.Cursor) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) EditorPresenter(com.mucommander.viewer.EditorPresenter) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) FileEditorService(com.mucommander.viewer.FileEditorService) JFrame(javax.swing.JFrame) Translator(com.mucommander.text.Translator) CloseCancelledException(com.mucommander.viewer.CloseCancelledException) FileEditor(com.mucommander.viewer.FileEditor) JComponent(javax.swing.JComponent) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu) IOException(java.io.IOException) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) Logger(java.util.logging.Logger) WindowEvent(java.awt.event.WindowEvent) List(java.util.List) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) AbstractFile(com.mucommander.commons.file.AbstractFile) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) CloseCancelledException(com.mucommander.viewer.CloseCancelledException) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)1 MenuToolkit (com.mucommander.commons.util.ui.helper.MenuToolkit)1 MnemonicHelper (com.mucommander.commons.util.ui.helper.MnemonicHelper)1 Translator (com.mucommander.text.Translator)1 CloseCancelledException (com.mucommander.viewer.CloseCancelledException)1 EditorPresenter (com.mucommander.viewer.EditorPresenter)1 FileEditor (com.mucommander.viewer.FileEditor)1 FileEditorService (com.mucommander.viewer.FileEditorService)1 Cursor (java.awt.Cursor)1 KeyEvent (java.awt.event.KeyEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 ButtonGroup (javax.swing.ButtonGroup)1 JComponent (javax.swing.JComponent)1 JFrame (javax.swing.JFrame)1