Changeset 1435 in josm for trunk


Ignore:
Timestamp:
2009-02-21T14:49:52+01:00 (15 years ago)
Author:
stoecker
Message:

remove dead code. patch by xeen

Location:
trunk/src/org/openstreetmap/josm/gui/layer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r1425 r1435  
    272272            new JMenuItem(new SaveAction(this)),
    273273            new JMenuItem(new SaveAsAction(this)),
    274             // new JMenuItem(new UploadTraceAction()),
    275274            color,
    276275            line,
     
    633632                for (WayPoint p : seg) {
    634633                    v.visit(p.eastNorth);
    635                 }
    636             }
    637         }
    638     }
    639 
    640     public class UploadTraceAction extends AbstractAction {
    641         public UploadTraceAction() {
    642             super(tr("Upload this trace..."), ImageProvider.get("uploadtrace"));
    643         }
    644         public void actionPerformed(ActionEvent e) {
    645             JPanel msg = new JPanel(new GridBagLayout());
    646             msg.add(new JLabel(tr("<html>This functionality has been added only recently. Please<br>"+
    647             "use with care and check if it works as expected.</html>")), GBC.eop());
    648             ButtonGroup bg = new ButtonGroup();
    649             JRadioButton c1 = null;
    650             JRadioButton c2 = null;
    651 
    652             //TODO
    653             //check whether data comes from server
    654             //check whether data changed sind last save/open
    655 
    656             c1 = new JRadioButton(tr("Upload track filtered by JOSM"), true);
    657             c2 = new JRadioButton(tr("Upload raw file: "), false);
    658             c2.setEnabled(false);
    659             c1.setEnabled(false);
    660             bg.add(c1);
    661             bg.add(c2);
    662 
    663             msg.add(c1, GBC.eol());
    664             msg.add(c2, GBC.eop());
    665 
    666 
    667             JLabel description = new JLabel((String) data.attr.get("desc"));
    668             JTextField tags = new JTextField();
    669             tags.setText((String) data.attr.get("keywords"));
    670             msg.add(new JLabel(tr("Description:")), GBC.std());
    671             msg.add(description, GBC.eol().fill(GBC.HORIZONTAL));
    672             msg.add(new JLabel(tr("Tags (keywords in GPX):")), GBC.std());
    673             msg.add(tags, GBC.eol().fill(GBC.HORIZONTAL));
    674             JCheckBox c3 = new JCheckBox("public");
    675             msg.add(c3, GBC.eop());
    676             msg.add(new JLabel("Please ensure that you don't upload your traces twice."), GBC.eop());
    677 
    678             int answer = JOptionPane.showConfirmDialog(Main.parent, msg, tr("GPX-Upload"), JOptionPane.OK_CANCEL_OPTION);
    679             if (answer == JOptionPane.OK_OPTION)
    680             {
    681                 try {
    682                     String version = Main.pref.get("osm-server.version", "0.5");
    683                     URL url = new URL(Main.pref.get("osm-server.url") + "/" + version + "/gpx/create");
    684 
    685                     // create a boundary string
    686                     String boundary = MultiPartFormOutputStream.createBoundary();
    687                     URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
    688                     urlConn.setRequestProperty("Accept", "*/*");
    689                     urlConn.setRequestProperty("Content-Type", MultiPartFormOutputStream.getContentType(boundary));
    690                     // set some other request headers...
    691                     urlConn.setRequestProperty("Connection", "Keep-Alive");
    692                     urlConn.setRequestProperty("Cache-Control", "no-cache");
    693                     // no need to connect cuz getOutputStream() does it
    694                     MultiPartFormOutputStream out = new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
    695                     out.writeField("description", description.getText());
    696                     out.writeField("tags", tags.getText());
    697                     out.writeField("public", (c3.getSelectedObjects() != null) ? "1" : "0");
    698                     // upload a file
    699                     // out.writeFile("gpx_file", "text/xml", associatedFile);
    700                     // can also write bytes directly
    701                     // out.writeFile("myFile", "text/plain", "C:\\test.txt",
    702                     // "This is some file text.".getBytes("ASCII"));
    703                     File tmp = File.createTempFile("josm", "tmp.gpx");
    704                     FileOutputStream outs = new FileOutputStream(tmp);
    705                     new GpxWriter(outs).write(data);
    706                     outs.close();
    707                     FileInputStream ins = new FileInputStream(tmp);
    708                     new GpxWriter(System.out).write(data);
    709                     out.writeFile("gpx_file", "text/xml", data.storageFile.getName(), ins);
    710                     out.close();
    711                     tmp.delete();
    712                     // read response from server
    713                     BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
    714                     String line = "";
    715                     while((line = in.readLine()) != null) {
    716                         System.out.println(line);
    717                     }
    718                     in.close();
    719 
    720                     //TODO check response
    721                     /*                  int retCode = urlConn.getResponseCode();
    722                     System.out.println("got return: " + retCode);
    723                     String retMsg = urlConn.getResponseMessage();
    724                     urlConn.disconnect();
    725                     if (retCode != 200) {
    726                         // Look for a detailed error message from the server
    727                         if (urlConn.getHeaderField("Error") != null)
    728                             retMsg += "\n" + urlConn.getHeaderField("Error");
    729 
    730                         // Report our error
    731                         ByteArrayOutputStream o = new ByteArrayOutputStream();
    732                         System.out.println(new String(o.toByteArray(), "UTF-8").toString());
    733                         throw new RuntimeException(retCode+" "+retMsg);
    734                     }
    735                      */
    736                 } catch (UnknownHostException ex) {
    737                     throw new RuntimeException(tr("Unknown host")+": "+ex.getMessage(), ex);
    738                 } catch (Exception ex) {
    739                     //if (cancel)
    740                     //  return; // assume cancel
    741                     if (ex instanceof RuntimeException)
    742                         throw (RuntimeException)ex;
    743                     throw new RuntimeException(ex.getMessage(), ex);
    744634                }
    745635            }
  • trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java

    r1169 r1435  
    8484            Main.main.addLayer(new OsmDataLayer(ds, tr("Converted from: {0}", RawGpsLayer.this.name), null));
    8585            Main.main.removeLayer(RawGpsLayer.this);
    86         }
    87     }
    88 
    89     public class UploadTraceAction extends AbstractAction {
    90         public UploadTraceAction() {
    91             super(tr("Upload this trace..."), ImageProvider.get("uploadtrace"));
    92         }
    93         public void actionPerformed(ActionEvent e) {
    94             JPanel msg = new JPanel(new GridBagLayout());
    95             msg.add(new JLabel(tr("<html>This functionality has been added only recently. Please<br>"+
    96                                   "use with care and check if it works as expected.</html>")), GBC.eop());
    97             ButtonGroup bg = new ButtonGroup();
    98             JRadioButton c1 = null;
    99             JRadioButton c2 = null;
    100 
    101             if (associatedFile != null) {
    102                 c1 = new JRadioButton(tr("Upload track filtered by JOSM"), false);
    103                 c2 = new JRadioButton(tr("Upload raw file: {0}", associatedFile.getName()), true);
    104             }
    105             else
    106             {
    107                 c1 = new JRadioButton(tr("Upload track filtered by JOSM"), true);
    108                 c2 = new JRadioButton(tr("Upload raw file: "), false);
    109                 c2.setEnabled(false);
    110             }
    111             c1.setEnabled(false);
    112             bg.add(c1);
    113             bg.add(c2);
    114 
    115             msg.add(c1, GBC.eol());
    116             msg.add(c2, GBC.eop());
    117 
    118 
    119             JTextField description = new JTextField();
    120             JTextField tags = new JTextField();
    121             msg.add(new JLabel(tr("Description:")), GBC.std());
    122             msg.add(description, GBC.eol().fill(GBC.HORIZONTAL));
    123             msg.add(new JLabel(tr("Tags:")), GBC.std());
    124             msg.add(tags, GBC.eol().fill(GBC.HORIZONTAL));
    125             JCheckBox c3 = new JCheckBox("public");
    126             msg.add(c3, GBC.eop());
    127             msg.add(new JLabel("Please ensure that you don't upload your traces twice."), GBC.eop());
    128 
    129             int answer = JOptionPane.showConfirmDialog(Main.parent, msg, tr("GPX-Upload"), JOptionPane.OK_CANCEL_OPTION);
    130             if (answer == JOptionPane.OK_OPTION)
    131             {
    132                 try {
    133                     String version = Main.pref.get("osm-server.version", "0.5");
    134                     URL url = new URL(Main.pref.get("osm-server.url") +
    135                             "/" + version + "/gpx/create");
    136 
    137                     // create a boundary string
    138                     String boundary = MultiPartFormOutputStream.createBoundary();
    139                     URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
    140                     urlConn.setRequestProperty("Accept", "*/*");
    141                     urlConn.setRequestProperty("Content-Type",
    142                         MultiPartFormOutputStream.getContentType(boundary));
    143                     // set some other request headers...
    144                     urlConn.setRequestProperty("Connection", "Keep-Alive");
    145                     urlConn.setRequestProperty("Cache-Control", "no-cache");
    146                     // no need to connect cuz getOutputStream() does it
    147                     MultiPartFormOutputStream out =
    148                         new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
    149                     out.writeField("description", description.getText());
    150                     out.writeField("tags", tags.getText());
    151                     out.writeField("public", (c3.getSelectedObjects() != null) ? "1" : "0");
    152                     // upload a file
    153                     out.writeFile("gpx_file", "text/xml", associatedFile);
    154                     // can also write bytes directly
    155                     // out.writeFile("myFile", "text/plain", "C:\\test.txt",
    156                     // "This is some file text.".getBytes("ASCII"));
    157                     out.close();
    158                     // read response from server
    159                     BufferedReader in = new BufferedReader(
    160                         new InputStreamReader(urlConn.getInputStream()));
    161                     String line = "";
    162                     while((line = in.readLine()) != null) {
    163                          System.out.println(line);
    164                     }
    165                     in.close();
    166 
    167                     /*
    168                     int retCode = activeConnection.getResponseCode();
    169                     System.out.println("got return: "+retCode);
    170                     String retMsg = activeConnection.getResponseMessage();
    171                     activeConnection.disconnect();
    172                     if (retCode != 200) {
    173                         // Look for a detailed error message from the server
    174                         if (activeConnection.getHeaderField("Error") != null)
    175                             retMsg += "\n" + activeConnection.getHeaderField("Error");
    176 
    177                         // Report our error
    178                         ByteArrayOutputStream o = new ByteArrayOutputStream();
    179                         System.out.println(new String(o.toByteArray(), "UTF-8").toString());
    180                         throw new RuntimeException(retCode+" "+retMsg);
    181                     }
    182                     */
    183                 } catch (UnknownHostException ex) {
    184                     throw new RuntimeException(tr("Unknown host")+": "+ex.getMessage(), ex);
    185                 } catch (Exception ex) {
    186                     //if (cancel)
    187                     //  return; // assume cancel
    188                     if (ex instanceof RuntimeException)
    189                         throw (RuntimeException)ex;
    190                     throw new RuntimeException(ex.getMessage(), ex);
    191                 }
    192             }
    19386        }
    19487    }
     
    348241                line,
    349242                new JMenuItem(new ConvertToDataLayerAction()),
    350                 //new JMenuItem(new UploadTraceAction()),
    351243                new JSeparator(),
    352244                new JMenuItem(new RenameLayerAction(associatedFile, this)),
     
    361253                line,
    362254                new JMenuItem(new ConvertToDataLayerAction()),
    363                 //new JMenuItem(new UploadTraceAction()),
    364255                new JSeparator(),
    365256                new JMenuItem(new RenameLayerAction(associatedFile, this)),
Note: See TracChangeset for help on using the changeset viewer.