f@0: /* f@0: CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool f@0: f@0: Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/) f@0: f@0: This program is free software: you can redistribute it and/or modify f@0: it under the terms of the GNU General Public License as published by f@0: the Free Software Foundation, either version 3 of the License, or f@0: (at your option) any later version. f@0: f@0: This program is distributed in the hope that it will be useful, f@0: but WITHOUT ANY WARRANTY; without even the implied warranty of f@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the f@0: GNU General Public License for more details. f@0: f@0: You should have received a copy of the GNU General Public License f@0: along with this program. If not, see . f@0: */ f@0: f@0: package uk.ac.qmul.eecs.ccmi.simpletemplate; f@0: f@0: import java.awt.Frame; f@0: import java.awt.event.ActionEvent; f@0: import java.awt.event.KeyEvent; f@0: import java.util.ResourceBundle; f@0: f@0: import javax.swing.AbstractAction; f@0: import javax.swing.JButton; f@0: import javax.swing.JComponent; f@0: import javax.swing.JRootPane; f@0: import javax.swing.KeyStroke; f@0: import javax.swing.event.ChangeEvent; f@0: f@0: import jwizardcomponent.dialog.SimpleJWizardDialog; f@0: f@0: /* f@0: * The dialog where the template wizard is displayed f@0: * f@0: * @see Wizard f@0: * f@0: */ f@0: @SuppressWarnings("serial") f@0: public class SpeechWizardDialog extends SimpleJWizardDialog { f@0: public SpeechWizardDialog(Frame owner){ f@0: super(owner,true); f@0: finished = false; f@0: f@0: ResourceBundle resources = ResourceBundle.getBundle(getClass().getName()); f@0: setSize(350, 200); f@0: setTitle(resources.getString("dialog.wizard.title")); f@0: setLocationRelativeTo(owner); f@0: f@0: JButton button; f@0: button = getWizardComponents().getNextButton(); f@0: button.setText(resources.getString("button.next.label")); f@0: button.getAccessibleContext().setAccessibleName(resources.getString("button.next.speech")); f@0: f@0: button = getWizardComponents().getBackButton(); f@0: button.setText(resources.getString("button.previous.label")); f@0: button.getAccessibleContext().setAccessibleName(resources.getString("button.previous.speech")); f@0: f@0: button = getWizardComponents().getCancelButton(); f@0: button.setText(resources.getString("button.cancel.label")); f@0: f@0: button = getWizardComponents().getFinishButton(); f@0: button.setText(resources.getString("button.finish.label")); f@0: button.addChangeListener(new javax.swing.event.ChangeListener(){ f@0: @Override f@0: public void stateChanged(ChangeEvent e) { f@0: ((JButton)e.getSource()).setEnabled(finished); f@0: } f@0: }); f@0: JRootPane rootPane = getRootPane(); f@0: rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "close"); f@0: rootPane.getActionMap().put("close", new AbstractAction(){ f@0: @Override f@0: public void actionPerformed(ActionEvent arg0) { f@0: dispose(); f@0: } f@0: }); f@0: } f@0: f@0: /** f@0: * Enables or disables the finish button. f@0: * @param enabled {@code true} to enable the button, {@code false} to disable f@0: */ f@0: public void setFinishButtonEnabled(boolean enabled){ f@0: finished = enabled; f@0: getWizardComponents().getFinishButton().setEnabled(true); f@0: } f@0: f@0: private boolean finished; f@0: } f@0: