Ignore:
Timestamp:
2012-05-05T16:48:35+02:00 (12 years ago)
Author:
donvip
Message:

[josm_opendata] fix EDT violation

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  
    2222import org.openstreetmap.josm.gui.ExtendedDialog;
    2323
    24 public abstract class DialogPrompter implements Runnable {
     24public class DialogPrompter <T extends ExtendedDialog> implements Runnable {
    2525       
     26        private T dialog;
    2627        private int value = -1;
    2728
    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        }
    2942       
    3043        @Override
    3144        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();
    3550                }
    3651        }
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java

    r28191 r28374  
    3838import org.openstreetmap.josm.plugins.opendata.core.OdConstants;
    3939import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
     40import org.openstreetmap.josm.plugins.opendata.core.gui.DialogPrompter;
    4041import org.openstreetmap.josm.plugins.opendata.core.io.NeptuneReader;
    4142import org.openstreetmap.josm.plugins.opendata.core.io.geographic.GmlReader;
     
    9293        }
    9394
    94         public DataSet parseDoc(ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException  {
     95        public DataSet parseDoc(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException  {
    9596               
    9697            final File temp = createTempDir();
     
    156157                       
    157158                        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                                }
    163168                        } else if (candidates.size() == 1) {
    164169                                file = candidates.get(0);
    165170                        }
    166171                       
    167                         if (file != null) {
     172                        if (file == null) {
     173                                return null;
     174                        } else {
    168175                                DataSet from = null;
    169176                                FileInputStream in = new FileInputStream(file);
Note: See TracChangeset for help on using the changeset viewer.