1 package cz
.cvut
.promod
.services
.projectService
.dialogs
;
4 import java
.awt
.event
.*;
7 * ProMod, master thesis project
8 * User: Petr Zverina, petr.zverina@gmail.com
9 * Date: 22:05:47, 13.11.2009
13 * SyncDialog controller.
15 public class SyncDialog
extends SyncDialogView
{
17 public static final String NEW_LINE_MARK
= "\n";
19 private SwingWorker swingWorker
= null;
22 * Creates a new SyncDialog.
24 * @param title is the SyncDialog title.
26 public SyncDialog(final String title
){
31 okButton
.setEnabled(false);
32 cancelButton
.setEnabled(false);
34 getRootPane().setDefaultButton(okButton
);
36 setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
42 * Initialize event handling.
44 private void initEventHandling() {
45 okButton
.addActionListener(new ActionListener(){
46 public void actionPerformed(ActionEvent e
) {
51 cancelButton
.addActionListener(new ActionListener(){
52 public void actionPerformed(ActionEvent e
) {
53 swingWorker
.cancel(true);
57 getRootPane().registerKeyboardAction(new ActionListener(){
58 public void actionPerformed(ActionEvent actionEvent
) {
62 KeyStroke
.getKeyStroke(KeyEvent
.VK_ESCAPE
, 0),
63 JComponent
.WHEN_IN_FOCUSED_WINDOW
);
65 addWindowListener(new WindowAdapter(){
67 public void windowClosing(WindowEvent windowEvent
) {
74 * When the EXC or cross buton is pressed.
76 private void escape() {
77 if(okButton
.isEnabled()){
83 * Controls dialogs final appearance.
85 * @param errors if true the dialog remains visible, false -> the dialog will be disposed
87 public void syncComplete(final boolean errors
){
89 okButton
.setEnabled(true);
96 * Sets the cancel button enabled.
98 public void disableCancelButton(){
99 cancelButton
.setEnabled(false);
103 * Disposes the dialog.
105 public void disposeDialog(){
111 * Appends a new error message to the synchronization error dialog.
113 * @param message is the error message
115 * @param addEmptyLine if true then there will be added an empty line after this error message
117 public void appendErrorInfo(final String message
, final boolean addEmptyLine
){
118 errorsTextArea
.append(message
);
120 errorsTextArea
.append(NEW_LINE_MARK
);
123 errorsTextArea
.append(NEW_LINE_MARK
);
128 * Update current sync position.
129 * @param text the location
131 public void updatePosition(final String text
){
132 currentSearchLocationLabel
.setText(text
);
136 * Sets the sync worker.
137 * @param swingWorker the sync worker.
139 public void setSyncWorker(final SwingWorker swingWorker
) {
140 if(swingWorker
== null){
144 this.swingWorker
= swingWorker
;
146 cancelButton
.setEnabled(true);