Changeset 29776 in osm for applications/editors/josm


Ignore:
Timestamp:
2013-07-25T03:26:37+02:00 (11 years ago)
Author:
donvip
Message:

[josm_directdownload] see #josm6355 - Move menu entry to GPS menu + code cleanup

Location:
applications/editors/josm/plugins/DirectDownload
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/DirectDownload/README

    r23585 r29776  
    77track using the "Open file ..." dialog.
    88
    9 The plugin provides a new entry "Download track ..." in the file
     9The plugin provides a new entry "Download track ..." in the GPS
    1010menu (no keyboard shortcut yet). This opens a dialog that will
    1111present a list of your uploaded tracks, showing the tracks timestamp
  • applications/editors/josm/plugins/DirectDownload/build.xml

    r29435 r29776  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <!--
    3 ** This is a template build file for a JOSM  plugin.
    4 **
    5 ** Maintaining versions
    6 ** ====================
    7 ** see README.template
    8 **
    9 ** Usage
    10 ** =====
    11 ** To build it run
    12 **
    13 **    > ant  dist
    14 **
    15 ** To install the generated plugin locally (in you default plugin directory) run
    16 **
    17 **    > ant  install
    18 **
    19 ** The generated plugin jar is not automatically available in JOSMs plugin configuration
    20 ** dialog. You have to check it in first.
    21 **
    22 ** Use the ant target 'publish' to check in the plugin and make it available to other
    23 ** JOSM users:
    24 **    set the properties commit.message and plugin.main.version
    25 ** and run
    26 **    > ant  publish
    27 **
    28 **
    29 -->
    302<project name="DirectDownload" default="dist" basedir=".">
    313    <!-- enter the SVN commit message -->
    324    <property name="commit.message" value="Commit message"/>
    335    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    34     <property name="plugin.main.version" value="5679"/>
    35     <!--
    36       ************************************************
    37       ** should not be necessary to change the following properties
    38      -->
    39     <property name="josm" location="../../core/dist/josm-custom.jar"/>
    40     <property name="plugin.build.dir" value="build"/>
    41     <property name="plugin.src.dir" value="src"/>
    42     <!-- this is the directory where the plugin jar is copied to -->
    43     <property name="plugin.dist.dir" value="../../dist"/>
    44     <property name="ant.build.javac.target" value="1.5"/>
    45     <property name="plugin.dist.dir" value="../../dist"/>
    46     <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
    47     <!--
    48     **********************************************************
    49     ** init - initializes the build
    50     **********************************************************
     6    <property name="plugin.main.version" value="6082"/>
     7
     8    <!-- Configure these properties (replace "..." accordingly).
     9         See http://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
    5110    -->
    52     <target name="init">
    53         <mkdir dir="${plugin.build.dir}"/>
    54     </target>
    55     <!--
    56     **********************************************************
    57     ** compile - complies the source tree
    58     **********************************************************
    59     -->
    60     <target name="compile" depends="init">
    61         <echo message="compiling sources for  ${plugin.jar} ... "/>
    62         <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
    63             <compilerarg value="-Xlint:deprecation"/>
    64             <compilerarg value="-Xlint:unchecked"/>
    65         </javac>
    66     </target>
    67     <!--
    68     **********************************************************
    69     ** dist - creates the plugin jar
    70     **********************************************************
    71     -->
    72     <target name="dist" depends="compile,revision">
    73         <echo message="creating ${ant.project.name}.jar ... "/>
    74         <copy todir="${plugin.build.dir}/resources">
    75             <fileset dir="resources"/>
    76         </copy>
    77         <copy todir="${plugin.build.dir}/images">
    78             <fileset dir="images"/>
    79         </copy>
    80         <copy todir="${plugin.build.dir}/data">
    81             <fileset dir="data"/>
    82         </copy>
    83         <copy todir="${plugin.build.dir}">
    84             <fileset dir=".">
    85                 <include name="README"/>
    86                 <include name="LICENSE"/>
    87             </fileset>
    88         </copy>
    89         <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
    90             <!--
    91         ************************************************
    92         ** configure these properties. Most of them will be copied to the plugins
    93         ** manifest file. Property values will also show up in the list available
    94         ** plugins: http://josm.openstreetmap.de/wiki/Plugins.
    95         **
    96         ************************************************
    97     -->
    98             <manifest>
    99                 <attribute name="Author" value="Hartmut Holzgraefe"/>
    100                 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.directdownload.DirectDownload"/>
    101                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    102                 <attribute name="Plugin-Description" value="Download your GPX tracks from openstreetmap.org"/>
    103                 <attribute name="Plugin-Icon" value="images/DownloadAction.png"/>
    104 <!--            <attribute name="Plugin-Link" value="..."/> -->
    105                 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
    106                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    107             </manifest>
    108         </jar>
    109     </target>
    110     <!--
    111     **********************************************************
    112     ** revision - extracts the current revision number for the
    113     **    file build.number and stores it in the XML property
    114     **    version.*
    115     **********************************************************
    116     -->
    117     <target name="revision">
    118         <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
    119             <env key="LANG" value="C"/>
    120             <arg value="info"/>
    121             <arg value="--xml"/>
    122             <arg value="."/>
    123         </exec>
    124         <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
    125         <delete file="REVISION"/>
    126     </target>
    127     <!--
    128     **********************************************************
    129     ** clean - clean up the build environment
    130     **********************************************************
    131     -->
    132     <target name="clean">
    133         <delete dir="${plugin.build.dir}"/>
    134         <delete file="${plugin.jar}"/>
    135     </target>
    136     <!--
    137     **********************************************************
    138     ** install - install the plugin in your local JOSM installation
    139     **********************************************************
    140     -->
    141     <target name="install" depends="dist">
    142         <property environment="env"/>
    143         <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
    144             <and>
    145                 <os family="windows"/>
    146             </and>
    147         </condition>
    148         <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
    149     </target>
    150     <!--
    151     ************************** Publishing the plugin ***********************************
    152     -->
    153     <!--
    154         ** extracts the JOSM release for the JOSM version in ../core and saves it in the
    155         ** property ${coreversion.info.entry.revision}
    156         **
    157         -->
    158     <target name="core-info">
    159         <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
    160             <env key="LANG" value="C"/>
    161             <arg value="info"/>
    162             <arg value="--xml"/>
    163             <arg value="../../core"/>
    164         </exec>
    165         <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
    166         <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
    167         <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
    168         <delete file="core.info.xml"/>
    169     </target>
    170     <!--
    171         ** commits the source tree for this plugin
    172         -->
    173     <target name="commit-current">
    174         <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
    175         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    176             <env key="LANG" value="C"/>
    177             <arg value="commit"/>
    178             <arg value="-m '${commit.message}'"/>
    179             <arg value="."/>
    180         </exec>
    181     </target>
    182     <!--
    183         ** updates (svn up) the source tree for this plugin
    184         -->
    185     <target name="update-current">
    186         <echo>Updating plugin source ...</echo>
    187         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    188             <env key="LANG" value="C"/>
    189             <arg value="up"/>
    190             <arg value="."/>
    191         </exec>
    192         <echo>Updating ${plugin.jar} ...</echo>
    193         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    194             <env key="LANG" value="C"/>
    195             <arg value="up"/>
    196             <arg value="../dist/${plugin.jar}"/>
    197         </exec>
    198     </target>
    199     <!--
    200         ** commits the plugin.jar
    201         -->
    202     <target name="commit-dist">
    203         <echo>
    204     ***** Properties of published ${plugin.jar} *****
    205     Commit message    : '${commit.message}'                   
    206     Plugin-Mainversion: ${plugin.main.version}
    207     JOSM build version: ${coreversion.info.entry.revision}
    208     Plugin-Version    : ${version.entry.commit.revision}
    209     ***** / Properties of published ${plugin.jar} *****                   
    210                        
    211     Now commiting ${plugin.jar} ...
    212     </echo>
    213         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
    214             <env key="LANG" value="C"/>
    215             <arg value="-m '${commit.message}'"/>
    216             <arg value="commit"/>
    217             <arg value="${plugin.jar}"/>
    218         </exec>
    219     </target>
    220     <!-- ** make sure svn is present as a command line tool ** -->
    221     <target name="ensure-svn-present">
    222         <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
    223             <env key="LANG" value="C"/>
    224             <arg value="--version"/>
    225         </exec>
    226         <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
    227             <!-- return code not set at all? Most likely svn isn't installed -->
    228             <condition>
    229                 <not>
    230                     <isset property="svn.exit.code"/>
    231                 </not>
    232             </condition>
    233         </fail>
    234         <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
    235             <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
    236             <condition>
    237                 <isfailure code="${svn.exit.code}"/>
    238             </condition>
    239         </fail>
    240     </target>
    241     <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
    242     </target>
     11    <property name="plugin.author" value="Hartmut Holzgraefe"/>
     12    <property name="plugin.class" value="org.openstreetmap.josm.plugins.directdownload.DirectDownload"/>
     13    <property name="plugin.description" value="Download your GPX tracks from openstreetmap.org"/>
     14    <property name="plugin.icon" value="images/DownloadAction.png"/>
     15    <!-- <property name="plugin.link" value="..."/>-->
     16    <!--<property name="plugin.early" value="..."/>-->
     17    <!--<property name="plugin.requires" value="..."/>-->
     18    <!--<property name="plugin.stage" value="..."/>-->
     19
     20    <!-- ** include targets that all plugins have in common ** -->
     21    <import file="../build-common.xml"/>
    24322</project>
  • applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/DirectDownload.java

    r29222 r29776  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
     5import java.awt.event.ActionEvent;
    56import java.io.InputStream;
    6 import java.io.IOException;
    7 
    87import java.net.URL;
    98
    10 import java.util.List;
    11 
    12 import java.awt.event.ActionEvent;
     9import javax.swing.JOptionPane;
    1310
    1411import org.openstreetmap.josm.Main;
    1512import org.openstreetmap.josm.actions.JosmAction;
    16 
     13import org.openstreetmap.josm.gui.MainMenu;
     14import org.openstreetmap.josm.gui.layer.GpxLayer;
     15import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     16import org.openstreetmap.josm.io.GpxReader;
     17import org.openstreetmap.josm.io.OsmApi;
    1718import org.openstreetmap.josm.plugins.Plugin;
    1819import org.openstreetmap.josm.plugins.PluginInformation;
    19 
    20 import org.openstreetmap.josm.gui.download.DownloadSelection;
    21 
    22 import org.openstreetmap.josm.gui.layer.GpxLayer;
    23 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    24 
    25 import org.openstreetmap.josm.io.GpxReader;
    26 
    27 import javax.swing.JOptionPane;
    28 
    2920import org.xml.sax.SAXException;
    3021
    3122public class DirectDownload extends Plugin {
    32     DownloadAction openaction;
     23    private DownloadAction openaction;
    3324
    34      /**
    35       * Will be invoked by JOSM to bootstrap the plugin
    36       *
    37       * @param info  information about the plugin and its local installation   
    38       */
    39       public DirectDownload(PluginInformation info) {
    40          super(info);
     25    /**
     26     * Will be invoked by JOSM to bootstrap the plugin
     27     *
     28     * @param info  information about the plugin and its local installation   
     29     */
     30    public DirectDownload(PluginInformation info) {
     31        super(info);
    4132
    42         openaction = new DownloadAction();
    43          Main.main.menu.fileMenu.add(openaction);
    44       }
     33        openaction = new DownloadAction();
     34        MainMenu.add(Main.main.menu.gpsMenu, openaction);
     35    }
    4536
    46     class DownloadAction extends JosmAction{
    47         public DownloadAction(){
    48             super(tr("Download Track ..."), "DownloadAction", tr("Download GPX track from openstreetmap.org"),
    49             null, false);
     37    class DownloadAction extends JosmAction {
     38        public DownloadAction() {
     39            super(tr("Download Track ..."), "DownloadAction",
     40                    tr("Download GPX track from openstreetmap.org"), null, false);
    5041        }
     42
    5143        public void actionPerformed(ActionEvent event) {
    5244            DownloadDataGui go = new DownloadDataGui();
    5345            go.setVisible(true);
    5446
    55             UserTrack track = go.getSelectedUserTrack();
     47            UserTrack track = go.getSelectedUserTrack();
    5648
    57             if ((go.getValue() == 1) && (track != null)) {
    58                 String apiBaseUrl = "http://api.openstreetmap.org/api/0.6/";
    59                 String urlString = apiBaseUrl + "gpx/" + track.id + "/data";
     49            if ((go.getValue() == 1) && (track != null)) {
     50                String urlString = OsmApi.getOsmApi().getBaseUrl() + "gpx/" + track.id + "/data";
    6051
    61                 try {
    62                     URL trackDataUrl = new URL(urlString);
    63                     InputStream is = trackDataUrl.openStream();
     52                try {
     53                    URL trackDataUrl = new URL(urlString);
     54                    InputStream is = trackDataUrl.openStream();
    6455
    65                     GpxReader r = new GpxReader(is);
    66                     boolean parsedProperly = r.parse(true);
    67                     GpxLayer gpxLayer = new GpxLayer(r.getGpxData(), track.filename, true);
     56                    GpxReader r = new GpxReader(is);
     57                    boolean parsedProperly = r.parse(true);
     58                    GpxLayer gpxLayer = new GpxLayer(r.getGpxData(), track.filename, true);
    6859
    6960                    if (r.getGpxData().hasRoutePoints() || r.getGpxData().hasTrackPoints()) {
     
    7869                    }
    7970                    if (!parsedProperly) {
    80                         JOptionPane.showMessageDialog(null, tr("Error occurred while parsing gpx file {0}. Only a part of the file will be available.", urlString));
     71                        JOptionPane.showMessageDialog(Main.parent,
     72                            tr("Error occurred while parsing gpx file {0}. Only a part of the file will be available.", urlString));
    8173                    }
    8274
    83                 } catch (java.net.MalformedURLException e) {
    84                     JOptionPane.showMessageDialog(null, tr("Invalid URL {0}", urlString));
    85                 } catch (java.io.IOException e) {
    86                     JOptionPane.showMessageDialog(null, tr("Error fetching URL {0}", urlString));
    87                 } catch (SAXException e) {
    88                     JOptionPane.showMessageDialog(null, tr("Error parsing data from URL {0}", urlString));
    89                 }
    90             }
     75                } catch (java.net.MalformedURLException e) {
     76                    JOptionPane.showMessageDialog(Main.parent,
     77                            tr("Invalid URL {0}", urlString));
     78                } catch (java.io.IOException e) {
     79                    JOptionPane.showMessageDialog(Main.parent,
     80                            tr("Error fetching URL {0}", urlString));
     81                } catch (SAXException e) {
     82                    JOptionPane.showMessageDialog(Main.parent,
     83                            tr("Error parsing data from URL {0}", urlString));
     84                }
     85            }
    9186        }
    9287    }
    93 
    9488}
    95 
  • applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/DownloadDataGui.java

    r23585 r29776  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.io.InputStream;
    6 import java.io.IOException;
    7 
     5import java.awt.BorderLayout;
     6import java.awt.Component;
     7import java.awt.Dimension;
    88import java.net.URL;
    9 
    109import java.util.ArrayList;
    1110import java.util.LinkedList;
    1211import java.util.List;
    13 import java.util.StringTokenizer;
    14 
    15 import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.gui.ExtendedDialog;
    17 
    18 import java.awt.BorderLayout;
    19 import java.awt.Component;
    20 import java.awt.Dimension;
    2112
    2213import javax.swing.BorderFactory;
    23 import javax.swing.DefaultListModel;
    2414import javax.swing.DefaultListSelectionModel;
    2515import javax.swing.JLabel;
    26 import javax.swing.JList;
    2716import javax.swing.JOptionPane;
    2817import javax.swing.JPanel;
     
    3120import javax.swing.ListSelectionModel;
    3221import javax.swing.UIManager;
    33 
    3422import javax.swing.event.ListSelectionEvent;
    3523import javax.swing.event.ListSelectionListener;
    36 
    3724import javax.swing.table.DefaultTableColumnModel;
    3825import javax.swing.table.DefaultTableModel;
    3926import javax.swing.table.TableCellRenderer;
    4027import javax.swing.table.TableColumn;
    41 
    42 import org.xml.sax.*;
    43 import org.xml.sax.helpers.*;
    44 
    45 import javax.xml.parsers.SAXParserFactory;
    4628import javax.xml.parsers.ParserConfigurationException;
    4729import javax.xml.parsers.SAXParser;
    48 
     30import javax.xml.parsers.SAXParserFactory;
     31
     32import org.openstreetmap.josm.Main;
     33import org.openstreetmap.josm.gui.ExtendedDialog;
     34import org.openstreetmap.josm.io.OsmApi;
     35import org.xml.sax.Attributes;
     36import org.xml.sax.SAXException;
     37import org.xml.sax.helpers.DefaultHandler;
    4938
    5039public class DownloadDataGui extends ExtendedDialog {
    51     private String apiBaseUrl = "http://api.openstreetmap.org/api/0.6/";
    52 
    53     // User for log in when downloading trace
    54     private String username = Main.pref.get("osm-server.username");
    55     private String password = Main.pref.get("osm-server.password");
    5640
    5741    private NamedResultTableModel model;
     
    6246        // Initalizes ExtendedDialog
    6347        super(Main.parent,
    64               tr("Download Track"),
    65               new String[] {tr("Download Track"), tr("Cancel")},
    66               true
    67               );
    68 
    69         JPanel panel = new JPanel();
    70         panel.setLayout(new BorderLayout());
    71        
     48          tr("Download Track"),
     49          new String[] {tr("Download Track"), tr("Cancel")},
     50          true
     51          );
     52
     53        JPanel panel = new JPanel();
     54        panel.setLayout(new BorderLayout());
     55   
    7256        DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    7357        model = new NamedResultTableModel(selectionModel);
     
    8064        panel.add(scrollPane, BorderLayout.CENTER);
    8165
    82         model.setData(getTrackList());
    83 
    84         setContent(panel);
    85         setupDialog();
     66    model.setData(getTrackList());
     67
     68    setContent(panel);
     69    setupDialog();
    8670    }
    8771
    8872    private static class TrackListHandler extends DefaultHandler {
    8973        private LinkedList<UserTrack> data = new LinkedList<UserTrack>();
    90         private String cdata = new String();
    91 
    92         @Override
    93         public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    94         throws SAXException {
    95             if (qName.equals("gpx_file")) {
    96                 UserTrack track = new UserTrack();
    97 
    98                 track.id       = atts.getValue("id");
    99                 track.filename = atts.getValue("name");
    100                 track.datetime = atts.getValue("timestamp").replaceAll("[TZ]", " "); // TODO: do real parsing and time zone conversion
    101                
    102                 data.addFirst(track);
    103             }
    104             cdata = new String();
    105         }
    106 
    107         public void characters(char ch[], int start, int length)
    108             throws SAXException {
    109             cdata += new String(ch, start, length);
    110         }
    111 
    112         public void endElement(String uri, String localName,
    113                                String qName)
    114             throws SAXException {
    115             if (qName.equals("description")) {
    116                 data.getFirst().description = cdata;
    117             }
    118             /*
    119             else if (qName.equals("tag")) {
    120                 data.getFirst().tags = cdata;
    121                 cdata = new String();
    122             }   
    123             */
    124         }
    125 
     74       
     75        private String cdata = new String();
     76   
     77        @Override
     78        public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
     79            if (qName.equals("gpx_file")) {
     80            UserTrack track = new UserTrack();
     81   
     82            track.id       = atts.getValue("id");
     83            track.filename = atts.getValue("name");
     84            track.datetime = atts.getValue("timestamp").replaceAll("[TZ]", " "); // TODO: do real parsing and time zone conversion
     85           
     86            data.addFirst(track);
     87            }
     88            cdata = new String();
     89        }
     90   
     91        public void characters(char ch[], int start, int length)
     92            throws SAXException {
     93            cdata += new String(ch, start, length);
     94        }
     95   
     96        public void endElement(String uri, String localName, String qName) throws SAXException {
     97            if (qName.equals("description")) {
     98            data.getFirst().description = cdata;
     99            }
     100            /*
     101            else if (qName.equals("tag")) {
     102            data.getFirst().tags = cdata;
     103            cdata = new String();
     104            }   
     105            */
     106        }
    126107
    127108        public List<UserTrack> getResult() {
     
    131112
    132113    private List<UserTrack> getTrackList() {
    133         String urlString = apiBaseUrl + "user/gpx_files";
    134 
    135         try {
    136             URL userTracksUrl = new URL(urlString);
    137 
    138             SAXParserFactory spf = SAXParserFactory.newInstance();
    139             TrackListHandler handler = new TrackListHandler();
    140 
    141             //get a new instance of parser
    142             SAXParser sp = spf.newSAXParser();
    143            
    144             //parse the file and also register this class for call backs
    145             sp.parse(userTracksUrl.openStream(), handler);
    146            
    147             return handler.getResult();
    148         } catch (java.net.MalformedURLException e) {
    149             JOptionPane.showMessageDialog(null, tr("Invalid URL {0}", urlString));
    150         } catch (java.io.IOException e) {
    151             JOptionPane.showMessageDialog(null, tr("Error fetching URL {0}", urlString));
    152         } catch (SAXException e) {
    153             JOptionPane.showMessageDialog(null, tr("Error parsing data from URL {0}", urlString));
    154         } catch(ParserConfigurationException pce) {
    155             JOptionPane.showMessageDialog(null, tr("Error parsing data from URL {0}", urlString));
    156         }
    157 
    158         return new LinkedList<UserTrack>();
     114        String urlString = OsmApi.getOsmApi().getBaseUrl() + "user/gpx_files";
     115
     116        try {
     117            URL userTracksUrl = new URL(urlString);
     118   
     119            SAXParserFactory spf = SAXParserFactory.newInstance();
     120            TrackListHandler handler = new TrackListHandler();
     121   
     122            //get a new instance of parser
     123            SAXParser sp = spf.newSAXParser();
     124           
     125            //parse the file and also register this class for call backs
     126            sp.parse(userTracksUrl.openStream(), handler);
     127           
     128            return handler.getResult();
     129        } catch (java.net.MalformedURLException e) {
     130            JOptionPane.showMessageDialog(null, tr("Invalid URL {0}", urlString));
     131        } catch (java.io.IOException e) {
     132            JOptionPane.showMessageDialog(null, tr("Error fetching URL {0}", urlString));
     133        } catch (SAXException e) {
     134            JOptionPane.showMessageDialog(null, tr("Error parsing data from URL {0}", urlString));
     135        } catch(ParserConfigurationException pce) {
     136            JOptionPane.showMessageDialog(null, tr("Error parsing data from URL {0}", urlString));
     137        }
     138
     139        return new LinkedList<UserTrack>();
    159140    }
    160141
     
    167148            this.selectionModel = selectionModel;
    168149        }
     150       
    169151        @Override
    170152        public int getRowCount() {
     
    187169            fireTableDataChanged();
    188170        }
     171       
    189172        @Override
    190173        public boolean isCellEditable(int row, int column) {
     
    200183
    201184    public UserTrack getSelectedUserTrack() {
    202         return model.getSelectedUserTrack();
    203     }
    204    
     185        return model.getSelectedUserTrack();
     186    }
    205187
    206188    static class NamedResultTableColumnModel extends DefaultTableColumnModel {
     
    234216
    235217            // column 3 - tags
    236             /*
     218        /*
    237219            col = new TableColumn(3);
    238220            col.setHeaderValue(tr("Tags"));
     
    241223            col.setCellRenderer(renderer);
    242224            addColumn(col);
    243             */
     225        */
    244226        }
    245227
     
    286268            switch(column) {
    287269            case 0:
    288                 setText(sr.datetime);
     270                setText(sr.datetime);
    289271                break;
    290272            case 1:
    291273                setText(sr.filename);
    292                 break;         
    293             case 2:
     274                break;       
     275            case 2:
    294276                setText(sr.description);
    295277                break;
    296                 /*
     278        /*
    297279            case 3:
    298280                setText(sr.tags);
    299281                break;
    300                 */
     282        */
    301283            }
    302284            return this;
    303285        }
    304286    }
    305 
    306287}
Note: See TracChangeset for help on using the changeset viewer.