Ignore:
Timestamp:
2016-01-11T23:12:52+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Minor beauty fixes both codewise and GUI-wise

  • Adds mapillary icon to mapillary preferences tab
  • Simplify access token parsing
Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31972 r31976  
    22package org.openstreetmap.josm.plugins.mapillary;
    33
     4import java.awt.Image;
    45import java.io.IOException;
    56
     
    4849  /** 16x16 icon. */
    4950  public static final ImageIcon ICON16 = new ImageProvider("icon16.png").get();
     51  /** 12x12 icon. */
     52  public static final ImageIcon ICON12 = new ImageIcon(ICON24.getImage().getScaledInstance(12, 12, Image.SCALE_SMOOTH));
    5053  /** Icon representing an image in the map. */
    5154  public static final ImageIcon MAP_ICON = new ImageProvider("mapicon.png").get();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java

    r31975 r31976  
    7474    panel.add(this.reverseButtons, GBC.eol());
    7575    // Sets the value of the ComboBox.
    76     if (Main.pref.get("mapillary.download-mode").equals(MapillaryDownloader.MODES.Automatic.toString())
    77         || Main.pref.get("mapillary.download-mode").equals(MapillaryDownloader.MODES.Semiautomatic.toString())
    78         || Main.pref.get("mapillary.download-mode").equals(MapillaryDownloader.MODES.Manual.toString())) {
     76    String downloadMode = Main.pref.get("mapillary.download-mode");
     77    if (MapillaryDownloader.MODES.Automatic.toString().equals(downloadMode)
     78        || MapillaryDownloader.MODES.Semiautomatic.toString().equals(downloadMode)
     79        || MapillaryDownloader.MODES.Manual.toString().equals(downloadMode)) {
    7980      this.downloadMode.setSelectedItem(Main.pref.get("mapillary.download-mode"));
    8081    }
     
    9495    panel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.BOTH));
    9596
    96     gui.getDisplayPreference().addSubTab(this, "Mapillary", new JScrollPane(panel));
     97    synchronized (gui.getDisplayPreference().getTabPane()) {
     98      gui.getDisplayPreference().addSubTab(this, "Mapillary", new JScrollPane(panel));
     99      gui.getDisplayPreference().getTabPane().setIconAt(gui.getDisplayPreference().getTabPane().getTabCount()-1, MapillaryPlugin.ICON12);
     100    }
    97101
    98102    new Thread(new Runnable() {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java

    r31833 r31976  
    1010import java.net.Socket;
    1111import java.util.Scanner;
     12import java.util.regex.Matcher;
     13import java.util.regex.Pattern;
    1214
    1315import org.openstreetmap.josm.Main;
     
    4749      while (in.hasNextLine() && accessToken == null) {
    4850        s = in.nextLine();
    49         if (s.contains("access_token=")) {
    50           String[] ss = s.split("&");
    51           for (int i = 0; i < ss.length && accessToken == null; i++) {
    52             if (ss[i].startsWith("access_token=")) {
    53               accessToken = ss[i].substring(ss[i].indexOf("access_token=") + 13, ss[i].length());
    54             }
    55           }
     51        Matcher tokenMatcher = Pattern.compile("^.*&access_token=([^&]+)&.*$").matcher('&'+s+'&');
     52        if (tokenMatcher.matches()) {
     53          accessToken = tokenMatcher.group(1);
    5654          break;
    5755        } else if (s.contains("keep-alive")) {
     
    6159
    6260      writeContent(out);
    63 
    64       out.close();
    65       in.close();
    66       serverSocket.close();
     61      out.flush();
    6762
    6863      MapillaryUser.reset();
Note: See TracChangeset for help on using the changeset viewer.