1 package cz
.cvut
.promod
.gui
.dialogs
.simpleTextFieldDialog
;
3 import com
.jgoodies
.binding
.adapter
.Bindings
;
4 import com
.jgoodies
.binding
.PresentationModel
;
7 import java
.awt
.event
.ActionListener
;
8 import java
.awt
.event
.ActionEvent
;
9 import java
.awt
.event
.KeyEvent
;
13 * ProMod, master thesis project
14 * User: Petr Zverina, petr.zverina@gmail.com
15 * Date: 23:49:43, 23.10.2009
17 * A implementation of SimpleTextFieldDialog.
19 public class SimpleTextFieldDialog
extends SimpleTextFieldDialogView
{
21 private final SimpleTextFieldDialogModel model
= new SimpleTextFieldDialogModel();
23 private final PresentationModel
<SimpleTextFieldDialogModel
> presentation
= new PresentationModel
<SimpleTextFieldDialogModel
>(model
);
25 private final SimpleTextFieldDialogExecutor executor
;
28 public SimpleTextFieldDialog(final String title
,
29 final String textLabelString
,
30 final String inputTextFieldText
,
31 final String confirmButtonText
,
32 final String cancelButtonString
,
33 final SimpleTextFieldDialogExecutor executor
,
34 final Component locateRelativeToComponent
,
37 if(locateRelativeToComponent
!= null){
38 setLocationRelativeTo(locateRelativeToComponent
);
44 textLabel
.setText(textLabelString
);
45 confirmButton
.setText(confirmButtonText
);
46 cancelButton
.setText(cancelButtonString
);
48 this.executor
= executor
;
52 inputTextField
.setText(inputTextFieldText
);
58 getRootPane().setDefaultButton(confirmButton
);
63 private void initBinding() {
64 Bindings
.bind(inputTextField
, presentation
.getModel(SimpleTextFieldDialogModel
.PROPERTY_SUBFOLDER_NAME
));
67 private void initEventHandling() {
68 cancelButton
.addActionListener(new ActionListener(){
69 public void actionPerformed(ActionEvent e
) {
74 confirmButton
.addActionListener(new ActionListener(){
75 public void actionPerformed(ActionEvent e
) {
76 final String result
= executor
.execute(model
.getInputText());
81 errorLabel
.setText(result
);
86 getRootPane().registerKeyboardAction(new ActionListener(){
87 public void actionPerformed(ActionEvent actionEvent
) {
91 KeyStroke
.getKeyStroke(KeyEvent
.VK_ESCAPE
, 0),
92 JComponent
.WHEN_IN_FOCUSED_WINDOW
);
95 private void disposeDialog(){