Changeset 28374 in osm for applications/editors/josm
- Timestamp:
- 2012-05-05T16:48:35+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/DialogPrompter.java
r28191 r28374 22 22 import org.openstreetmap.josm.gui.ExtendedDialog; 23 23 24 public abstract class DialogPrompterimplements Runnable {24 public class DialogPrompter <T extends ExtendedDialog> implements Runnable { 25 25 26 private T dialog; 26 27 private int value = -1; 27 28 28 protected abstract ExtendedDialog buildDialog(); 29 protected T buildDialog() {return null;} // To be overriden if needed 30 31 public DialogPrompter() { 32 this(null); 33 } 34 35 public DialogPrompter(T dialog) { 36 this.dialog = dialog; 37 } 38 39 public final T getDialog() { 40 return dialog; 41 } 29 42 30 43 @Override 31 44 public final void run() { 32 ExtendedDialog dlg = buildDialog(); 33 if (dlg != null) { 34 value = dlg.showDialog().getValue(); 45 if (dialog == null) { 46 dialog = buildDialog(); 47 } 48 if (dialog != null) { 49 value = dialog.showDialog().getValue(); 35 50 } 36 51 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r28191 r28374 38 38 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 39 39 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 40 import org.openstreetmap.josm.plugins.opendata.core.gui.DialogPrompter; 40 41 import org.openstreetmap.josm.plugins.opendata.core.io.NeptuneReader; 41 42 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.GmlReader; … … 92 93 } 93 94 94 public DataSet parseDoc( ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException {95 public DataSet parseDoc(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 95 96 96 97 final File temp = createTempDir(); … … 156 157 157 158 if (candidates.size() > 1) { 158 CandidateChooser dialog = (CandidateChooser) new CandidateChooser(progressMonitor.getWindowParent(), candidates).showDialog(); 159 if (dialog.getValue() != 1) { 160 return null; // User clicked Cancel 161 } 162 file = dialog.getSelectedFile(); 159 DialogPrompter<CandidateChooser> prompt = new DialogPrompter() { 160 @Override 161 protected CandidateChooser buildDialog() { 162 return new CandidateChooser(progressMonitor.getWindowParent(), candidates); 163 } 164 }; 165 if (prompt.promptInEdt().getValue() == 1) { 166 file = prompt.getDialog().getSelectedFile(); 167 } 163 168 } else if (candidates.size() == 1) { 164 169 file = candidates.get(0); 165 170 } 166 171 167 if (file != null) { 172 if (file == null) { 173 return null; 174 } else { 168 175 DataSet from = null; 169 176 FileInputStream in = new FileInputStream(file);
Note:
See TracChangeset
for help on using the changeset viewer.