Search in sources :

Example 1 with FurtherActionListener

use of org.omegat.gui.preferences.IPreferencesController.FurtherActionListener in project omegat by omegat-org.

the class PreferencesDialog method show.

public boolean show(Window parent) {
    JDialog dialog = new JDialog();
    dialog.setTitle(view.toString());
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    StaticUIUtils.setEscapeClosable(dialog);
    StaticUIUtils.setWindowIcon(dialog);
    panel = new PreferencePanel();
    dialog.getContentPane().add(panel);
    panel.prefsViewPanel.add(view.getGui(), BorderLayout.CENTER);
    view.addFurtherActionListener(new FurtherActionListener() {

        @Override
        public void setRestartRequired(boolean restartRequired) {
            updateMessage();
        }

        @Override
        public void setReloadRequired(boolean reloadRequired) {
            updateMessage();
        }
    });
    panel.okButton.addActionListener(e -> {
        view.persist();
        userDidConfirm = true;
        StaticUIUtils.closeWindowByEvent(dialog);
    });
    panel.cancelButton.addActionListener(e -> StaticUIUtils.closeWindowByEvent(dialog));
    panel.undoButton.addActionListener(e -> undoCurrentView());
    panel.resetButton.addActionListener(e -> resetCurrentView());
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            if (view.isReloadRequired()) {
                ProjectUICommands.promptReload();
            }
        }
    });
    dialog.getRootPane().setDefaultButton(panel.okButton);
    dialog.pack();
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
    return userDidConfirm;
}
Also used : WindowEvent(java.awt.event.WindowEvent) FurtherActionListener(org.omegat.gui.preferences.IPreferencesController.FurtherActionListener) WindowAdapter(java.awt.event.WindowAdapter) PreferencePanel(org.omegat.gui.preferences.PreferencePanel) JDialog(javax.swing.JDialog)

Aggregations

WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 JDialog (javax.swing.JDialog)1 FurtherActionListener (org.omegat.gui.preferences.IPreferencesController.FurtherActionListener)1 PreferencePanel (org.omegat.gui.preferences.PreferencePanel)1