Ticket #17040: 17040-pref-dlg-v2.patch
File 17040-pref-dlg-v2.patch, 5.1 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/gui/GettingStarted.java
5 5 6 6 import java.awt.BorderLayout; 7 7 import java.awt.EventQueue; 8 import java.awt.Graphics;9 8 import java.io.IOException; 10 9 import java.net.URL; 11 10 import java.nio.charset.StandardCharsets; … … 15 14 import javax.swing.JComponent; 16 15 import javax.swing.JPanel; 17 16 import javax.swing.JScrollPane; 18 import javax.swing.Timer;19 17 import javax.swing.border.EmptyBorder; 20 18 import javax.swing.event.HyperlinkEvent; 21 19 import javax.swing.event.HyperlinkListener; … … 22 20 23 21 import org.openstreetmap.josm.actions.DownloadPrimitiveAction; 24 22 import org.openstreetmap.josm.data.Version; 25 import org.openstreetmap.josm.gui.animation.AnimationExtensionManager;26 23 import org.openstreetmap.josm.gui.datatransfer.OpenTransferHandler; 27 24 import org.openstreetmap.josm.gui.dialogs.MenuItemSearchDialog; 28 25 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; … … 48 45 private final LinkGeneral lg; 49 46 private String content = ""; 50 47 private boolean contentInitialized; 51 private final Timer timer = new Timer(50, e -> repaint());52 48 53 49 private static final String STYLE = "<style type=\"text/css\">\n" 54 50 + "body {font-family: sans-serif; font-weight: bold; }\n" … … 147 143 setTransferHandler(new OpenTransferHandler()); 148 144 } 149 145 150 @Override151 public void addNotify() {152 timer.start();153 super.addNotify();154 }155 156 @Override157 public void removeNotify() {158 timer.stop();159 super.removeNotify();160 }161 162 @Override163 public void paint(Graphics g) {164 super.paint(g);165 if (isShowing()) {166 AnimationExtensionManager.getExtension().adjustForSize(getWidth(), getHeight());167 AnimationExtensionManager.getExtension().animate();168 AnimationExtensionManager.getExtension().paint(g);169 }170 }171 172 146 private void getMOTD() { 173 147 // Asynchronously get MOTD to speed-up JOSM startup 174 148 Thread t = new Thread((Runnable) () -> { -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
11 11 import java.awt.GridBagLayout; 12 12 import java.awt.Insets; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.WindowAdapter;15 import java.awt.event.WindowEvent;16 14 17 15 import javax.swing.AbstractAction; 18 16 import javax.swing.BorderFactory; … … 42 40 43 41 private final PreferenceTabbedPane tpPreferences = new PreferenceTabbedPane(); 44 42 private final ContextSensitiveHelpAction helpAction = new ContextSensitiveHelpAction(); 45 private final WindowEventHandler windowEventHandler = new WindowEventHandler(); 46 private boolean canceled; 43 public boolean okPressed; 47 44 48 45 /** 49 46 * Constructs a new {@code PreferenceDialog}. … … 56 53 // set the maximum width to the current screen. If the dialog is opened on a 57 54 // smaller screen than before, this will reset the stored preference. 58 55 this.setMaximumSize(GuiHelper.getScreenSize()); 56 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 59 57 } 60 58 61 59 protected JPanel buildActionPanel() { … … 84 82 tpPreferences.buildGui(); 85 83 tpPreferences.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 86 84 c.add(buildActionPanel(), BorderLayout.SOUTH); 87 addWindowListener(windowEventHandler);88 85 89 86 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 90 87 setHelpContext(HelpUtil.ht("/Action/Preferences")); … … 110 107 } 111 108 112 109 /** 113 * Determines if preferences changes have been cancel ed.114 * @return {@code true} if preferences changes have been cancel ed110 * Determines if preferences changes have been cancelled. 111 * @return {@code true} if preferences changes have been cancelled 115 112 */ 116 113 public boolean isCanceled() { 117 return canceled;114 return !okPressed; 118 115 } 119 116 120 protected void setCanceled(boolean canceled) {121 this.canceled = canceled;122 }123 124 117 @Override 125 118 public void setVisible(boolean visible) { 126 119 if (visible) { … … 175 168 } 176 169 177 170 public void cancel() { 178 setCanceled(true);179 171 dispose(); 180 172 } 181 173 … … 200 192 } 201 193 202 194 tpPreferences.savePreferences(); 203 setCanceled(false);195 okPressed = true; 204 196 dispose(); 205 197 } 206 198 } 207 199 208 class WindowEventHandler extends WindowAdapter {209 @Override210 public void windowClosing(WindowEvent arg0) {211 new CancelAction().cancel();212 }213 }214 215 @Override216 public void dispose() {217 removeWindowListener(windowEventHandler);218 super.dispose();219 }220 200 }