Changeset 32076 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2016-02-19T17:54:54+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r31976 r32076 2 2 package org.openstreetmap.josm.plugins.mapillary.gui; 3 3 4 import java.awt.FlowLayout; 4 import java.awt.BorderLayout; 5 import java.awt.Color; 5 6 import java.awt.GridBagConstraints; 6 7 import java.awt.GridBagLayout; 7 8 import java.awt.event.ActionEvent; 8 9 import java.io.IOException; 9 10 import java.io.InputStream; 11 12 import javax.imageio.ImageIO; 10 13 import javax.swing.AbstractAction; 11 14 import javax.swing.BorderFactory; 12 15 import javax.swing.Box; 16 import javax.swing.BoxLayout; 17 import javax.swing.ImageIcon; 13 18 import javax.swing.JButton; 14 19 import javax.swing.JCheckBox; … … 28 33 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser; 29 34 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener; 35 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryColorScheme; 36 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryColorScheme.MapillaryButton; 30 37 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryURL; 31 38 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; … … 42 49 43 50 private final JCheckBox reverseButtons = new JCheckBox(I18n.tr("Reverse buttons position when displaying images.")); 44 private final JComboBox<String> downloadMode = new JComboBox<>(new String[]{51 private final JComboBox<String> downloadModeComboBox = new JComboBox<>(new String[]{ 45 52 MapillaryDownloader.MODES.Automatic.toString(), 46 53 MapillaryDownloader.MODES.Semiautomatic.toString(), … … 51 58 private final JCheckBox moveTo = new JCheckBox(I18n.tr("Move to picture''s location with next/previous buttons")); 52 59 53 private final JButton loginButton = new JButton(new LoginAction(this));54 private final JButton logoutButton = new JButton(new LogoutAction());60 private final JButton loginButton = new MapillaryButton(I18n.tr("Login"), new LoginAction(this)); 61 private final JButton logoutButton = new MapillaryButton(I18n.tr("Logout"), new LogoutAction()); 55 62 private final JLabel loginLabel = new JLabel(); 56 63 private final JPanel loginPanel = new JPanel(); … … 63 70 @Override 64 71 public void addGui(PreferenceTabbedPane gui) { 65 JPanel panel = new JPanel(); 66 this.reverseButtons.setSelected(Main.pref.getBoolean("mapillary.reverse-buttons")); 67 this.displayHour.setSelected(Main.pref.getBoolean("mapillary.display-hour", true)); 68 this.format24.setSelected(Main.pref.getBoolean("mapillary.format-24")); 69 this.moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture", true)); 70 71 panel.setLayout(new GridBagLayout()); 72 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 73 74 panel.add(this.reverseButtons, GBC.eol()); 72 JPanel container = new JPanel(new BorderLayout()); 73 74 loginPanel.setLayout(new BoxLayout(loginPanel, BoxLayout.LINE_AXIS)); 75 loginPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); 76 loginPanel.setBackground(MapillaryColorScheme.TOOLBAR_DARK_GREY); 77 JLabel brandImage = new JLabel(); 78 try (InputStream is = MapillaryPreferenceSetting.class.getResourceAsStream("/images/mapillary-logo-white.png")) { 79 if (is != null) { 80 brandImage.setIcon(new ImageIcon(ImageIO.read(is))); 81 } else { 82 Main.warn("Could not load Mapillary brand image!"); 83 } 84 } catch (IOException e) { 85 Main.warn("While reading Mapillary brand image, an IO-exception occured!"); 86 } 87 loginPanel.add(brandImage, 0); 88 loginPanel.add(Box.createHorizontalGlue(), 1); 89 loginLabel.setForeground(Color.WHITE); 90 loginLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); 91 loginPanel.add(loginLabel, 2); 92 loginPanel.add(loginButton, 3); 93 onLogout(); 94 container.add(loginPanel, BorderLayout.NORTH); 95 96 JPanel mainPanel = new JPanel(); 97 reverseButtons.setSelected(Main.pref.getBoolean("mapillary.reverse-buttons")); 98 displayHour.setSelected(Main.pref.getBoolean("mapillary.display-hour", true)); 99 format24.setSelected(Main.pref.getBoolean("mapillary.format-24")); 100 moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture", true)); 101 102 mainPanel.setLayout(new GridBagLayout()); 103 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 104 75 105 // Sets the value of the ComboBox. 76 106 String downloadMode = Main.pref.get("mapillary.download-mode"); … … 78 108 || MapillaryDownloader.MODES.Semiautomatic.toString().equals(downloadMode) 79 109 || MapillaryDownloader.MODES.Manual.toString().equals(downloadMode)) { 80 this.downloadMode.setSelectedItem(Main.pref.get("mapillary.download-mode"));110 downloadModeComboBox.setSelectedItem(Main.pref.get("mapillary.download-mode")); 81 111 } 82 112 JPanel downloadModePanel = new JPanel(); 83 113 downloadModePanel.add(new JLabel(I18n.tr("Download mode"))); 84 downloadModePanel.add(this.downloadMode); 85 panel.add(downloadModePanel, GBC.eol()); 86 panel.add(displayHour, GBC.eol()); 87 panel.add(format24, GBC.eol()); 88 panel.add(moveTo, GBC.eol()); 89 90 loginPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); 91 loginPanel.add(loginButton, 0); 92 loginPanel.add(loginLabel, 1); 93 onLogout(); 94 panel.add(loginPanel, GBC.eol()); 95 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.BOTH)); 114 downloadModePanel.add(downloadModeComboBox); 115 mainPanel.add(downloadModePanel, GBC.eol()); 116 117 mainPanel.add(reverseButtons, GBC.eol()); 118 mainPanel.add(displayHour, GBC.eol()); 119 mainPanel.add(format24, GBC.eol()); 120 mainPanel.add(moveTo, GBC.eol()); 121 MapillaryColorScheme.styleAsDefaultPanel( 122 mainPanel, downloadModePanel, reverseButtons, displayHour, format24, moveTo 123 ); 124 mainPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.BOTH)); 125 126 container.add(mainPanel, BorderLayout.CENTER); 96 127 97 128 synchronized (gui.getDisplayPreference().getTabPane()) { 98 gui.getDisplayPreference().addSubTab(this, "Mapillary", new JScrollPane( panel));129 gui.getDisplayPreference().addSubTab(this, "Mapillary", new JScrollPane(container)); 99 130 gui.getDisplayPreference().getTabPane().setIconAt(gui.getDisplayPreference().getTabPane().getTabCount()-1, MapillaryPlugin.ICON12); 100 131 } … … 118 149 @Override 119 150 public void onLogin(final String username) { 120 loginPanel.add(logoutButton, 1); 151 loginPanel.remove(loginButton); 152 loginPanel.add(logoutButton, 3); 121 153 loginLabel.setText(I18n.tr("You are logged in as ''{0}''.", username)); 122 login Button.setText(I18n.tr("Re-Login"));123 log outButton.setText(I18n.tr("Logout"));154 loginPanel.revalidate(); 155 loginPanel.repaint(); 124 156 } 125 157 … … 127 159 public void onLogout() { 128 160 loginPanel.remove(logoutButton); 161 loginPanel.add(loginButton, 3); 129 162 loginLabel.setText(I18n.tr("You are currently not logged in.")); 130 loginButton.setText(I18n.tr("Login")); 163 loginPanel.revalidate(); 164 loginPanel.repaint(); 131 165 } 132 166 … … 137 171 138 172 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), false); 139 if (this.downloadMode .getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString()))173 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString())) 140 174 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Automatic.toString()); 141 if (this.downloadMode .getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString()))175 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString())) 142 176 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Semiautomatic.toString()); 143 if (this.downloadMode .getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) {177 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) { 144 178 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Manual.toString()); 145 179 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true);
Note:
See TracChangeset
for help on using the changeset viewer.