Ignore:
Timestamp:
2014-06-10T00:04:18+02:00 (11 years ago)
Author:
zverik
Message:

wow, it works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPlugin.java

    r27939 r30491  
    22
    33import java.awt.event.ActionEvent;
     4import java.io.IOException;
     5import java.util.List;
    46import javax.swing.JFileChooser;
     7import javax.swing.JOptionPane;
    58import org.openstreetmap.josm.Main;
    69import org.openstreetmap.josm.actions.JosmAction;
    710import org.openstreetmap.josm.gui.MapFrame;
     11import org.openstreetmap.josm.gui.MapView;
    812import org.openstreetmap.josm.plugins.Plugin;
    913import org.openstreetmap.josm.plugins.PluginInformation;
     
    1822    public NanoLogPlugin( PluginInformation info ) {
    1923        super(info);
    20         Main.main.menu.fileMenu.add(new OpenNanoLogLayerAction());
     24        Main.main.menu.fileMenu.insert(new OpenNanoLogLayerAction(), 4);
    2125    }
    2226   
     
    2428    public void mapFrameInitialized( MapFrame oldFrame, MapFrame newFrame ) {
    2529        if( oldFrame == null && newFrame != null ) {
    26             newFrame.addToggleDialog(new NanoLogPanel());
     30            NanoLogPanel panel = new NanoLogPanel();
     31            newFrame.addToggleDialog(panel);
     32            MapView.addLayerChangeListener(panel);
    2733        }
    2834    }
     
    3743            JFileChooser fc = new JFileChooser();
    3844            if( fc.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION ) {
    39                 // open layer, ok
     45                try {
     46                    List<NanoLogEntry> entries = NanoLogLayer.readNanoLog(fc.getSelectedFile());
     47                    if( !entries.isEmpty() ) {
     48                        NanoLogLayer layer = new NanoLogLayer(entries);
     49                        Main.main.addLayer(layer);
     50                    }
     51                } catch( IOException ex ) {
     52                    JOptionPane.showMessageDialog(Main.parent, tr("Could not read NanoLog file:") + "\n" + ex.getMessage());
     53                }
    4054            }
    4155        }       
Note: See TracChangeset for help on using the changeset viewer.