Ignore:
Timestamp:
2017-08-26T20:45:43+02:00 (7 years ago)
Author:
zverik
Message:

Upgrade API for geochat

Location:
applications/editors/josm/plugins/geochat
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geochat/build.xml

    r32680 r33545  
    55    <property name="commit.message" value="[josm_geochat] copypaste from keyboard, font size advanced parameters"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10580"/>
     7    <property name="plugin.main.version" value="12643"/>
    88
    99    <property name="plugin.author" value="Ilya Zverev"/>
  • applications/editors/josm/plugins/geochat/src/geochat/ChatMessage.java

    r32544 r33545  
    8484        }
    8585        final ChatMessage other = (ChatMessage) obj;
    86         if (this.id != other.id) {
    87             return false;
    88         }
    89         return true;
     86        return this.id == other.id;
    9087    }
    9188
  • applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java

    r32544 r33545  
    2525import org.openstreetmap.josm.Main;
    2626import org.openstreetmap.josm.gui.util.GuiHelper;
     27import org.openstreetmap.josm.tools.Logging;
    2728
    2829/**
     
    116117                    doc.insertString(doc.getLength(), nline, attrs);
    117118                } catch (BadLocationException ex) {
    118                     Main.warn(ex);
     119                    Logging.warn(ex);
    119120                }
    120121                thepane.setCaretPosition(doc.getLength());
  • applications/editors/josm/plugins/geochat/src/geochat/ChatServerConnection.java

    r32544 r33545  
    2323import org.openstreetmap.josm.data.coor.LatLon;
    2424import org.openstreetmap.josm.data.projection.Projection;
     25import org.openstreetmap.josm.gui.MainApplication;
    2526import org.openstreetmap.josm.gui.MapView;
     27import org.openstreetmap.josm.tools.Logging;
    2628
    2729/**
     
    122124                    }
    123125                } catch (InterruptedException e) {
    124                     Main.warn(e);
     126                    Logging.warn(e);
    125127                }
    126128                autoLogin(userName);
     
    164166            });
    165167        } catch (UnsupportedEncodingException e) {
    166             Main.error(e);
     168            Logging.error(e);
    167169        }
    168170    }
     
    266268            });
    267269        } catch (UnsupportedEncodingException e) {
    268             Main.error(e);
     270            Logging.error(e);
    269271        }
    270272    }
     
    274276     */
    275277    private static LatLon getPosition() {
    276         if (Main.map == null || Main.map.mapView == null)
     278        if (!MainApplication.isDisplayingMapView())
    277279            return null;
    278280        if (getCurrentZoom() < 10)
    279281            return null;
    280282        Projection proj = Main.getProjection();
    281         return proj.eastNorth2latlon(Main.map.mapView.getCenter());
     283        return proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    282284    }
    283285
     
    294296
    295297    public static int getCurrentZoom() {
    296         if (Main.map == null || Main.map.mapView == null) {
     298        if (!MainApplication.isDisplayingMapView()) {
    297299            return 1;
    298300        }
    299         MapView mv = Main.map.mapView;
     301        MapView mv = MainApplication.getMap().mapView;
    300302        LatLon topLeft = mv.getLatLon(0, 0);
    301303        LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
     
    434436                    result.add(cm);
    435437                } catch (JsonException e) {
    436                     Main.trace(e);
     438                    Logging.trace(e);
    437439                }
    438440            }
     
    450452                    result.put(name, new LatLon(lat, lon));
    451453                } catch (JsonException e) {
    452                     Main.trace(e);
     454                    Logging.trace(e);
    453455                }
    454456            }
  • applications/editors/josm/plugins/geochat/src/geochat/GeoChatPanel.java

    r32544 r33545  
    3737import org.openstreetmap.josm.data.Bounds;
    3838import org.openstreetmap.josm.data.coor.LatLon;
    39 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    40 import org.openstreetmap.josm.gui.MapView;
    41 import org.openstreetmap.josm.gui.Notification;
     39import org.openstreetmap.josm.gui.*;
    4240import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    4341import org.openstreetmap.josm.gui.layer.MapViewPaintable;
    4442import org.openstreetmap.josm.gui.util.GuiHelper;
    4543import org.openstreetmap.josm.tools.GBC;
     44import org.openstreetmap.josm.tools.Logging;
    4645
    4746/**
     
    156155            }
    157156        } catch (IOException e) {
    158             Main.warn("Failed to logout from geochat server: " + e.getMessage());
     157            Logging.warn("Failed to logout from geochat server: " + e.getMessage());
    159158        }
    160159        super.destroy();
     
    317316        this.users = newUsers;
    318317        updateTitleAlarm();
    319         if (userLayerActive && Main.map.mapView != null)
    320             Main.map.mapView.repaint();
     318        if (userLayerActive && MainApplication.isDisplayingMapView())
     319            MainApplication.getMap().mapView.repaint();
    321320    }
    322321
  • applications/editors/josm/plugins/geochat/src/geochat/GeoChatPopupAdapter.java

    r32544 r33545  
    1313import javax.swing.JPopupMenu;
    1414
    15 import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.gui.MainApplication;
    1616
    1717/**
     
    114114        ToggleUserLayerAction() {
    115115            super(tr("Show users on map"));
    116             putValue(SELECTED_KEY, Boolean.valueOf(panel.userLayerActive));
     116            putValue(SELECTED_KEY, panel.userLayerActive);
    117117        }
    118118
    119119        @Override
    120120        public void actionPerformed(ActionEvent e) {
    121             if (Main.map == null || Main.map.mapView == null)
     121            if (!MainApplication.isDisplayingMapView())
    122122                return;
    123             boolean wasAdded = Main.map.mapView.addTemporaryLayer(panel);
     123            boolean wasAdded = MainApplication.getMap().mapView.addTemporaryLayer(panel);
    124124            if (!wasAdded)
    125                 Main.map.mapView.removeTemporaryLayer(panel);
     125                MainApplication.getMap().mapView.removeTemporaryLayer(panel);
    126126            panel.userLayerActive = wasAdded;
    127             putValue(SELECTED_KEY, Boolean.valueOf(panel.userLayerActive));
    128             Main.map.mapView.repaint();
     127            putValue(SELECTED_KEY, panel.userLayerActive);
     128            MainApplication.getMap().mapView.repaint();
    129129        }
    130130    }
  • applications/editors/josm/plugins/geochat/src/geochat/JPanelTextField.java

    r32544 r33545  
    1616import javax.swing.text.DefaultEditorKit;
    1717
    18 import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.gui.MainApplication;
    1919import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    2020
     
    8787                }
    8888            } else if (code == KeyEvent.VK_ESCAPE) {
    89                 if (Main.map != null && Main.map.mapView != null)
    90                     Main.map.mapView.requestFocus();
     89                if (MainApplication.isDisplayingMapView())
     90                    MainApplication.getMap().mapView.requestFocus();
    9191            }
    9292
  • applications/editors/josm/plugins/geochat/src/geochat/JsonQueryUtil.java

    r32544 r33545  
    1414
    1515import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.gui.MainApplication;
     17import org.openstreetmap.josm.tools.Logging;
    1618
    1719/**
     
    7072     */
    7173    public static void queryAsync(String query, JsonQueryCallback callback) {
    72         Main.worker.submit(new JsonQueryUtil(query, callback));
     74        MainApplication.worker.submit(new JsonQueryUtil(query, callback));
    7375    }
    7476
     
    7880            obj = query(query);
    7981        } catch (IOException e) {
    80             Main.warn(e.getClass().getName() + " while connecting to a chat server: " + e.getMessage());
     82            Logging.warn(e.getClass().getName() + " while connecting to a chat server: " + e.getMessage());
    8183            obj = null;
    8284        }
Note: See TracChangeset for help on using the changeset viewer.