Revision 36679 branches/v2_0_0_prep/libraries/org.gvsig.annotation/org.gvsig.annotation.swing/org.gvsig.annotation.swing.impl/src/main/java/org/gvsig/annotation/swing/impl/DefaultAnnotationWindowManager.java
DefaultAnnotationWindowManager.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.awt.BorderLayout; |
25 | 25 |
import java.awt.Dimension; |
26 |
import java.awt.Frame; |
|
27 | 26 |
import java.awt.Toolkit; |
28 | 27 |
import java.awt.event.ComponentEvent; |
29 | 28 |
import java.awt.event.ComponentListener; |
... | ... | |
31 | 30 |
import javax.swing.JFrame; |
32 | 31 |
import javax.swing.JOptionPane; |
33 | 32 |
import javax.swing.JPanel; |
34 |
import javax.swing.Timer; |
|
35 | 33 |
|
36 | 34 |
import org.gvsig.annotation.swing.AnnotationWindowManager; |
37 | 35 |
import org.gvsig.annotation.swing.AnnotationWizardPanelActionListener; |
38 | 36 |
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel; |
39 | 37 |
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel; |
40 |
import org.gvsig.annotation.swing.thread.AnnotationCreationTask; |
|
41 |
import org.gvsig.i18n.Messages; |
|
42 |
import org.gvsig.utils.swing.threads.IProgressMonitorIF; |
|
43 |
import org.gvsig.utils.swing.threads.TaskMonitorTimerListener; |
|
44 |
import org.gvsig.utils.swing.threads.UndefinedProgressMonitor; |
|
45 | 38 |
|
46 | 39 |
/** |
47 | 40 |
* Default implementation for the {@link AnnotationWindowManager}. |
... | ... | |
122 | 115 |
} |
123 | 116 |
} |
124 | 117 |
|
125 |
public void showWindow(final AnnotationCreationTask annotationCreationTask) { |
|
126 |
final org.gvsig.utils.swing.threads.SwingWorker worker = new org.gvsig.utils.swing.threads.SwingWorker() { |
|
127 |
public Object construct() { |
|
128 |
try { |
|
129 |
annotationCreationTask.run(); |
|
130 |
} catch (Exception e) { |
|
131 |
// TODO Auto-generated catch block |
|
132 |
e.printStackTrace(); |
|
133 |
} |
|
134 |
return annotationCreationTask; |
|
135 |
} |
|
136 |
/** |
|
137 |
* Called on the event dispatching thread (not on the worker thread) |
|
138 |
* after the <code>construct</code> method has returned. |
|
139 |
*/ |
|
140 |
public void finished() { |
|
141 |
annotationCreationTask.finished(); |
|
142 |
} |
|
143 |
}; |
|
144 |
|
|
145 |
JFrame mainFrame = new JFrame(); |
|
146 |
|
|
147 |
IProgressMonitorIF progressMonitor = null; |
|
148 |
String title = Messages.getText("PluginServices.Procesando"); |
|
149 |
progressMonitor = new UndefinedProgressMonitor((Frame) mainFrame, title); |
|
150 |
progressMonitor.setIndeterminated(!annotationCreationTask.isDefined()); |
|
151 |
progressMonitor.setInitialStep(annotationCreationTask.getInitialStep()); |
|
152 |
progressMonitor.setLastStep(annotationCreationTask.getFinishStep()); |
|
153 |
progressMonitor.setCurrentStep(annotationCreationTask.getCurrentStep()); |
|
154 |
progressMonitor.setMainTitleLabel(annotationCreationTask.getStatusMessage()); |
|
155 |
progressMonitor.setNote(annotationCreationTask.getNote()); |
|
156 |
progressMonitor.open(); |
|
157 |
int delay = 500; |
|
158 |
TaskMonitorTimerListener timerListener = new TaskMonitorTimerListener( |
|
159 |
progressMonitor, annotationCreationTask); |
|
160 |
Timer timer = new Timer(delay, timerListener); |
|
161 |
timerListener.setTimer(timer); |
|
162 |
timer.start(); |
|
163 |
|
|
164 |
worker.start(); |
|
165 |
} |
|
166 |
|
|
167 | 118 |
public boolean showFileExistsPopup(String title, String text) { |
168 | 119 |
int resp = JOptionPane.showConfirmDialog( |
169 | 120 |
new JFrame(), text, |
Also available in: Unified diff