Ignore:
Timestamp:
2012-06-19T22:18:52+02:00 (13 years ago)
Author:
jttt
Message:

adapt to latest josm

Location:
applications/editors/josm/plugins/pdfimport
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pdfimport/.classpath

    r23863 r28446  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" path="resources"/>
    45        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    56        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
  • applications/editors/josm/plugins/pdfimport/build.xml

    r27852 r28446  
    3333    <property name="commit.message" value="Initial pdfimport version"/>
    3434    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    35     <property name="plugin.main.version" value="4980"/>
     35    <property name="plugin.main.version" value="5236"/>
    3636    <!-- compilation properties -->
    3737    <property name="josm.build.dir" value="../../core"/>
     
    113113    </target>
    114114    <!--
    115     ************************** Publishing the plugin *********************************** 
     115    ************************** Publishing the plugin ***********************************
    116116    -->
    117117    <!--
    118         ** extracts the JOSM release for the JOSM version in ../core and saves it in the 
     118        ** extracts the JOSM release for the JOSM version in ../core and saves it in the
    119119        ** property ${coreversion.info.entry.revision}
    120120        **
     
    162162    </target>
    163163    <!--
    164         ** commits the plugin.jar 
     164        ** commits the plugin.jar
    165165        -->
    166166    <target name="commit-dist">
    167167        <echo>
    168168    ***** Properties of published ${plugin.jar} *****
    169     Commit message    : '${commit.message}'                 
     169    Commit message    : '${commit.message}'
    170170    Plugin-Mainversion: ${plugin.main.version}
    171171    JOSM build version: ${coreversion.info.entry.revision}
    172172    Plugin-Version    : ${version.entry.commit.revision}
    173     ***** / Properties of published ${plugin.jar} *****                 
    174                        
     173    ***** / Properties of published ${plugin.jar} *****
     174
    175175    Now commiting ${plugin.jar} ...
    176176    </echo>
  • applications/editors/josm/plugins/pdfimport/src/pdfimport/FilePlacement.java

    r25546 r28446  
    55import java.awt.geom.AffineTransform;
    66import java.awt.geom.Point2D;
    7 import java.util.Arrays;
    8 import java.util.Collection;
    97import java.util.Properties;
    108
     
    1311import org.openstreetmap.josm.data.coor.LatLon;
    1412import org.openstreetmap.josm.data.projection.Projection;
    15 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;
    16 import org.openstreetmap.josm.data.projection.Projections;
    17 import org.openstreetmap.josm.tools.Utils;
     13import org.openstreetmap.josm.data.projection.ProjectionInfo;
    1814
    1915public class FilePlacement {
     
    4642        }
    4743
    48         private String fromCollection(Collection<String> val) {
    49                 if (val != null && !val.isEmpty())
    50                     return Utils.join("\u001e", val);
    51                 return null;
    52         }
    53 
    54         private Collection<String> toCollection(String s) {
    55                 if (s != null && s.length() != 0) {
    56                         return Arrays.asList(s.split("\u001e", -1));
    57                 }
    58                 return null;
    59         }
    60 
    6144        public Properties toProperties() {
    6245                Properties p = new Properties();
    6346                if (projection != null) {
    64                         p.setProperty("Projection", projection.getClass().getCanonicalName());
    65 
    66                         if (projection instanceof ProjectionSubPrefs) {
    67                                 ProjectionSubPrefs projPrefs = (ProjectionSubPrefs) projection;
    68                                 String code = projection.toCode();
    69                                 String prefs = fromCollection(projPrefs.getPreferencesFromCode(code));
    70                                 if (prefs != null) {
    71                                     p.setProperty("ProjectionPrefs", prefs);
    72                                 }
    73                         }
     47                        p.setProperty("Projection", projection.toCode());
    7448                }
    7549
     
    8761
    8862        public void fromProperties(Properties p){
    89 
    90                 String className = p.getProperty("Projection", null);
    91                 projection = null;
    92 
    93                 if (className != null) {
    94                         for(Projection proj: Projections.getProjections()){
    95                                 if (proj.getClass().getCanonicalName().equals(className)){
    96                                         projection = proj;
    97                                         break;
    98                                 }
    99                         }
    100                         if (projection instanceof ProjectionSubPrefs) {
    101                                 ProjectionSubPrefs projPrefs = (ProjectionSubPrefs) projection;
    102 
    103                                 String s;
    104                                 s = p.getProperty("ProjectionPrefs", null);
    105                                 Collection<String> prefs = toCollection(s);
    106                                 if (prefs != null) {
    107                                     projPrefs.setPreferences(prefs);
    108                                 }
    109                         }
     63                String projectionCode = p.getProperty("Projection", null);
     64                if (projectionCode != null) {
     65                        projection = ProjectionInfo.getProjectionByCode(projectionCode);
     66                } else {
     67                        projection = null;
    11068                }
    11169
  • applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java

    r25527 r28446  
    11package pdfimport;
    22
     3import static org.openstreetmap.josm.tools.I18n.tr;
     4
    35import java.awt.BorderLayout;
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    66import java.awt.Color;
    77import java.awt.Component;
     
    2424import java.util.Collection;
    2525import java.util.Properties;
     26
    2627import javax.swing.AbstractAction;
    27 
    2828import javax.swing.BorderFactory;
    2929import javax.swing.BoxLayout;
     
    5050import org.openstreetmap.josm.data.osm.Node;
    5151import org.openstreetmap.josm.data.osm.OsmPrimitive;
    52 import org.openstreetmap.josm.data.projection.Projection;
    53 import org.openstreetmap.josm.data.projection.Projections;
    54 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;
     52import org.openstreetmap.josm.gui.SideButton;
    5553import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     54import org.openstreetmap.josm.gui.preferences.projection.ProjectionChoice;
     55import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    5656import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    5757import org.openstreetmap.josm.gui.progress.ProgressRenderer;
    5858import org.openstreetmap.josm.gui.progress.SwingRenderingProgressMonitor;
    59 import org.openstreetmap.josm.gui.SideButton;
    60 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
    6159import org.openstreetmap.josm.io.OsmExporter;
    6260import org.openstreetmap.josm.tools.ImageProvider;
     
    8280                }
    8381
     82                @Override
    8483                public void setCustomText(String message) {
    8584                        this.pBar.setString(this.title + message);
    8685                }
    8786
     87                @Override
    8888                public void setIndeterminate(boolean indeterminate) {
    8989                        this.pBar.setIndeterminate(indeterminate);
    9090                }
    9191
     92                @Override
    9293                public void setMaximum(int maximum) {
    9394                        this.pBar.setMaximum(maximum);
    9495                }
    9596
     97                @Override
    9698                public void setTaskTitle(String taskTitle) {
    9799                        this.title = taskTitle;
     
    99101                }
    100102
     103                @Override
    101104                public void setValue(int value) {
    102105                        this.pBar.setValue(value);
     
    168171
    169172                this.projectionCombo.addActionListener(new ActionListener() {
     173                        @Override
    170174                        public void actionPerformed(ActionEvent e) {
    171175                                updateProjectionPrefButton();
     
    174178                });
    175179                this.projectionPreferencesButton.addActionListener(new ActionListener() {
     180                        @Override
    176181                        public void actionPerformed(ActionEvent e) {
    177182                                showProjectionPreferences();
     
    180185
    181186                this.loadFileButton.addActionListener(new ActionListener() {
     187                        @Override
    182188                        public void actionPerformed(ActionEvent e) {
    183189                                loadFilePressed();
     
    186192
    187193                this.okButton.addActionListener(new ActionListener() {
     194                        @Override
    188195                        public void actionPerformed(ActionEvent e) {
    189196                                okPressed();
     
    192199
    193200                this.saveButton.addActionListener(new ActionListener() {
     201                        @Override
    194202                        public void actionPerformed(ActionEvent e) {
    195203                                savePressed();
     
    198206
    199207                this.showButton.addActionListener(new ActionListener() {
     208                        @Override
    200209                        public void actionPerformed(ActionEvent e) {
    201210                                showPressed();
     
    204213
    205214                this.cancelButton.addActionListener(new ActionListener() {
     215                        @Override
    206216                        public void actionPerformed(ActionEvent e) {
    207217                                cancelPressed();
     
    218228
    219229                this.getMinButton.addActionListener(new ActionListener() {
     230                        @Override
    220231                        public void actionPerformed(ActionEvent e) {
    221232                                getMinPressed();
     
    224235
    225236                this.getMaxButton.addActionListener(new ActionListener() {
     237                        @Override
    226238                        public void actionPerformed(ActionEvent e) {
    227239                                getMaxPressed();
     
    236248
    237249                this.projectionCombo = new JComboBox();
    238                 this.projectionCombo.addItem(tr("Select projection..."));
    239                 for (Projection p: Projections.getProjections()) {
     250                for (ProjectionChoice p: ProjectionPreference.getProjectionChoices()) {
    240251                        this.projectionCombo.addItem(p);
    241252                }
     
    419430
    420431        private class ProjectionSubPrefsDialog extends JDialog {
    421                 private ProjectionSubPrefs projPref;
     432                private final ProjectionChoice projPref;
    422433                private OKAction actOK;
    423434                private CancelAction actCancel;
    424435                private JPanel projPrefPanel;
    425436
    426                 public ProjectionSubPrefsDialog(Component parent, ProjectionSubPrefs pr) {
     437                public ProjectionSubPrefsDialog(Component parent, ProjectionChoice pr) {
    427438                        super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL);
    428439
     
    442453
    443454                protected JPanel buildInputForm() {
    444                         JPanel pnl = new JPanel();
    445                         projPref.setupPreferencePanel(pnl, null);
    446                         return pnl;
     455                        return projPref.getPreferencePanel(null);
    447456                }
    448457
     
    480489                        }
    481490
     491                        @Override
    482492                        public void actionPerformed(ActionEvent e) {
    483493                        projPref.setPreferences(projPref.getPreferences(projPrefPanel));
     
    493503                        }
    494504
     505                        @Override
    495506                        public void actionPerformed(ActionEvent e) {
    496507                        setVisible(false);
     
    512523
    513524        private void updateProjectionPrefButton() {
    514                 Object proj = projectionCombo.getSelectedItem();
    515 
     525//              ProjectionChoice proj = (ProjectionChoice) projectionCombo.getSelectedItem();
     526
     527                //TODO
    516528                // Enable/disable pref button
    517                 if(!(proj instanceof ProjectionSubPrefs)) {
    518                         projectionPreferencesButton.setEnabled(false);
    519                 } else {
     529//              if(!(proj instanceof ProjectionSubPrefs)) {
     530//                      projectionPreferencesButton.setEnabled(false);
     531//              } else {
    520532                        projectionPreferencesButton.setEnabled(true);
    521                 }
     533//              }
    522534        }
    523535
    524536        private void showProjectionPreferences() {
    525                 Object proj = projectionCombo.getSelectedItem();
    526 
    527                 if(proj instanceof ProjectionSubPrefs) {
    528                         ProjectionSubPrefsDialog dlg =
    529                         new ProjectionSubPrefsDialog(this, (ProjectionSubPrefs)proj);
    530                         dlg.setVisible(true);
    531                 }
     537                ProjectionChoice proj = (ProjectionChoice) projectionCombo.getSelectedItem();
     538
     539                ProjectionSubPrefsDialog dlg = new ProjectionSubPrefsDialog(this, proj);
     540                dlg.setVisible(true);
     541
    532542        }
    533543
     
    546556                this.runAsBackgroundTask(
    547557                                new Runnable() {
     558                                        @Override
    548559                                        public void run() {
    549560                                                //async part
     
    563574                                new ActionListener() {
    564575
     576                                        @Override
    565577                                        public void actionPerformed(ActionEvent e) {
    566578                                                //sync part
     
    608620                this.runAsBackgroundTask(
    609621                                new Runnable() {
     622                                        @Override
    610623                                        public void run() {
    611624                                                //async part
     
    617630                                new ActionListener() {
    618631
     632                                        @Override
    619633                                        public void actionPerformed(ActionEvent e) {
    620634                                                //sync part
     
    643657                this.runAsBackgroundTask(
    644658                                new Runnable() {
     659                                        @Override
    645660                                        public void run() {
    646661                                                //async part
     
    652667                                new ActionListener() {
    653668
     669                                        @Override
    654670                                        public void actionPerformed(ActionEvent e) {
    655671                                                //sync part
     
    769785                Thread t = new Thread(new Runnable()
    770786                {
     787                        @Override
    771788                        public void run() {
    772789                                task.run();
    773790
    774791                                SwingUtilities.invokeLater(new Runnable(){
     792                                        @Override
    775793                                        public void run() {
    776794                                                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     
    930948
    931949        private FilePlacement parsePlacement() {
    932                 Object selectedProjection = this.projectionCombo.getSelectedItem();
    933 
    934                 if (!(selectedProjection instanceof Projection))
     950                ProjectionChoice selectedProjection = (ProjectionChoice) this.projectionCombo.getSelectedItem();
     951
     952                if (selectedProjection == null)
    935953                {
    936954                        JOptionPane.showMessageDialog(Main.parent, tr("Please set a projection."));
     
    940958                FilePlacement placement = new FilePlacement();
    941959
    942                 placement.projection = (Projection)this.projectionCombo.getSelectedItem();
     960                placement.projection = selectedProjection.getProjection();
    943961
    944962                try
     
    970988                }
    971989
    972                 this.projectionCombo.setSelectedItem(placement.projection);
     990                if (placement.projection != null) {
     991                        String projectionCode = placement.projection.toCode();
     992                        BIG_LOOP:
     993                        for (ProjectionChoice projectionChoice: ProjectionPreference.getProjectionChoices()) {
     994                                for (String code: projectionChoice.allCodes()) {
     995                                        if (code.equals(projectionCode)) {
     996                                                projectionChoice.getPreferencesFromCode(projectionCode);
     997                                                this.projectionCombo.setSelectedItem(projectionChoice);
     998                                                break BIG_LOOP;
     999                                        }
     1000                                }
     1001                        }
     1002                }
     1003
    9731004                this.minXField.setText(Double.toString(placement.minX));
    9741005                this.maxXField.setText(Double.toString(placement.maxX));
Note: See TracChangeset for help on using the changeset viewer.