use of org.omegat.gui.preferences.PreferencePanel 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;
}
Aggregations