Ignore:
Timestamp:
2009-07-21T07:42:53+02:00 (15 years ago)
Author:
jttt
Message:

Made plug-in work with JOSM new ProgressMonitor API

Location:
applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/AgpifojLayer.java

    r16315 r16603  
    3030import org.openstreetmap.josm.actions.RenameLayerAction;
    3131import org.openstreetmap.josm.data.coor.CachedLatLon;
    32 import org.openstreetmap.josm.data.coor.EastNorth;
    3332import org.openstreetmap.josm.data.coor.LatLon;
    3433import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     
    103102        private final File[] selection;
    104103        private HashSet<String> loadedDirectories = new HashSet<String>();
     104        private String errorMessage = "";
    105105
    106106        public Loader(File[] selection) {
     
    111111        @Override protected void realRun() throws IOException {
    112112
    113             Main.pleaseWaitDlg.currentAction.setText(tr("Starting directory scan"));
     113            progressMonitor.subTask(tr("Starting directory scan"));
    114114            List<File> files = new ArrayList<File>();
    115115            try {
     
    123123            }
    124124
    125             Main.pleaseWaitDlg.currentAction.setText(tr("Read photos..."));
     125            progressMonitor.subTask(tr("Read photos..."));
     126            progressMonitor.setTicksCount(files.size());
    126127
    127128            // read the image files
    128129            ArrayList<ImageEntry> data = new ArrayList<ImageEntry>(files.size());
    129130
    130             int progress = 0;
    131             Main.pleaseWaitDlg.progress.setMaximum(files.size());
    132             Main.pleaseWaitDlg.progress.setValue(progress);
    133 
    134131            for (File f : files) {
    135132
     
    138135                }
    139136
    140                 Main.pleaseWaitDlg.currentAction.setText(tr("Reading {0}...", f.getName()));
    141                 Main.pleaseWaitDlg.progress.setValue(progress++);
     137                progressMonitor.subTask(tr("Reading {0}...", f.getName()));
     138                progressMonitor.worked(1);
    142139
    143140                ImageEntry e = new ImageEntry();
     
    157154            layer = new AgpifojLayer(data);
    158155            files.clear();
     156            progressMonitor.setErrorMessage(errorMessage);
    159157        }
    160158
     
    189187                    File[] children = f.listFiles(AgpifojPlugin.JPEG_FILE_FILTER);
    190188                    if (children != null) {
    191                         Main.pleaseWaitDlg.currentAction.setText(tr("Scanning directory {0}", f.getPath()));
     189                        progressMonitor.subTask(tr("Scanning directory {0}", f.getPath()));
    192190                        try {
    193191                            addRecursiveFiles(files, children);
     
    197195                        }
    198196                    } else {
    199                         errorMessage += tr("Error while getting files from directory {0}\n", f.getPath());
     197                        errorMessage += tr("Error while getting files from directory {0}\n", f.getPath());
    200198                    }
    201199
  • applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java

    r16315 r16603  
    1010import java.awt.Cursor;
    1111import java.awt.Dimension;
    12 import java.awt.event.ActionEvent;
    13 import java.awt.event.ActionListener;
    1412import java.awt.FlowLayout;
    1513import java.awt.GridBagConstraints;
    1614import java.awt.GridBagLayout;
     15import java.awt.event.ActionEvent;
     16import java.awt.event.ActionListener;
    1717import java.io.File;
    1818import java.io.FileInputStream;
     19import java.io.IOException;
    1920import java.io.InputStream;
    20 import java.io.IOException;
    2121import java.text.ParseException;
    2222import java.text.SimpleDateFormat;
     
    3535import javax.swing.AbstractListModel;
    3636import javax.swing.ButtonGroup;
    37 import javax.swing.event.ChangeEvent;
    38 import javax.swing.event.ChangeListener;
    39 import javax.swing.event.ListSelectionEvent;
    40 import javax.swing.event.ListSelectionListener;
    41 import javax.swing.filechooser.FileFilter;
    4237import javax.swing.JButton;
    4338import javax.swing.JComboBox;
     
    5247import javax.swing.JTextField;
    5348import javax.swing.ListSelectionModel;
    54 
    55 import org.openstreetmap.josm.data.coor.EastNorth;
     49import javax.swing.event.ChangeEvent;
     50import javax.swing.event.ChangeListener;
     51import javax.swing.event.ListSelectionEvent;
     52import javax.swing.event.ListSelectionListener;
     53import javax.swing.filechooser.FileFilter;
     54
     55import org.openstreetmap.josm.Main;
    5656import org.openstreetmap.josm.data.gpx.GpxData;
    5757import org.openstreetmap.josm.data.gpx.GpxTrack;
     
    6262import org.openstreetmap.josm.gui.layer.Layer;
    6363import org.openstreetmap.josm.io.GpxReader;
    64 import org.openstreetmap.josm.Main;
    6564import org.openstreetmap.josm.plugins.agpifoj.AgpifojLayer.ImageEntry;
    6665import org.openstreetmap.josm.tools.ExifReader;
     
    678677        }
    679678
    680         // Free the user's vision
    681         Main.pleaseWaitDlg.setVisible(false);
    682679        AgpifojDialog dialog = AgpifojDialog.getInstance();
    683680        dialog.action.button.setSelected(true);
Note: See TracChangeset for help on using the changeset viewer.