Changeset 6131 in josm
- Timestamp:
- 2013-08-10T14:34:47+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r6084 r6131 28 28 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 29 29 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 30 import org.openstreetmap.josm.gui.Notification; 30 31 import org.openstreetmap.josm.gui.help.HelpUtil; 31 32 import org.openstreetmap.josm.tools.ImageProvider; … … 45 46 46 47 protected void alertSelectAtLeastOneWay() { 47 HelpAwareOptionPane.showOptionDialog( 48 Main.parent, 49 tr("Please select at least one way to simplify."), 50 tr("Warning"), 51 JOptionPane.WARNING_MESSAGE, 52 HelpUtil.ht("/Action/SimplifyWay#SelectAWayToSimplify") 53 ); 48 new Notification( 49 tr("Please select at least one way to simplify.")) 50 .setIcon(JOptionPane.WARNING_MESSAGE) 51 .setDuration(Notification.TIME_SHORT) 52 .setHelpTopic(HelpUtil.ht("/Action/SimplifyWay#SelectAWayToSimplify")) 53 .show(); 54 54 } 55 55 -
trunk/src/org/openstreetmap/josm/gui/Notification.java
r6130 r6131 22 22 * <pre> 23 23 * Notification note = new Notification("Hi there!"); 24 * note.setDuration(4000); // optional25 24 * note.setIcon(JOptionPane.INFORMATION_MESSAGE); // optional 25 * note.setDuration(Notification.TIME_SHORT); // optional 26 26 * note.show(); 27 27 * </pre> … … 52 52 public final static int TIME_VERY_LONG = Main.pref.getInteger("notification-time-very_long-ms", 20000); 53 53 54 private Component content; 55 private int duration; 54 56 private Icon icon; 55 private int duration; 56 private Component content; 57 private String helpTopic; 57 58 58 59 public Notification() { … … 81 82 * Set the notification text. (Convenience method) 82 83 * 83 * @param msg the message String 84 * @param msg the message String. Will be wrapped in <html>, so 85 * you can use <br> and other markup directly. 84 86 * 85 87 * @see #Notification(java.lang.String) … … 97 99 * 98 100 * @param duration the time (in milliseconds) 101 * Preset values {@link #TIME_SHORT}, {@link #TIME_DEFAULT}, {@link #TIME_LONG} 102 * and {@link #TIME_VERY_LONG} can be used. 99 103 * @return the current Object, for convenience 100 104 */ … … 141 145 } 142 146 147 /** 148 * Display a help button at the bottom of the notification window. 149 * @param helpTopic the help topic 150 * @return the current Object, for convenience 151 */ 152 public Notification setHelpTopic(String helpTopic) { 153 this.helpTopic = helpTopic; 154 return this; 155 } 156 143 157 public Component getContent() { 144 158 return content; … … 153 167 } 154 168 169 public String getHelpTopic() { 170 return helpTopic; 171 } 172 155 173 /** 156 174 * Display the notification. -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r6124 r6131 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.BasicStroke; … … 23 25 24 26 import javax.swing.AbstractAction; 27 import javax.swing.Action; 25 28 import javax.swing.BorderFactory; 26 29 import javax.swing.GroupLayout; … … 35 38 36 39 import org.openstreetmap.josm.Main; 40 import org.openstreetmap.josm.gui.help.HelpBrowser; 41 import org.openstreetmap.josm.gui.help.HelpUtil; 37 42 import org.openstreetmap.josm.tools.ImageProvider; 38 43 … … 187 192 } 188 193 189 private void build(Notification note) { 190 JButton close = new JButton(new HideAction()); 191 close.setPreferredSize(new Dimension(50, 50)); 194 private void build(final Notification note) { 195 JButton btnClose = new JButton(new HideAction()); 196 btnClose.setPreferredSize(new Dimension(50, 50)); 197 btnClose.setMargin(new Insets(0, 0, 1, 1)); 198 btnClose.setContentAreaFilled(false); 199 // put it in JToolBar to get a better appearance 192 200 JToolBar tbClose = new JToolBar(); 193 close.setMargin(new Insets(0, 0, 1, 1));194 close.setContentAreaFilled(false);195 196 201 tbClose.setFloatable(false); 197 202 tbClose.setBorderPainted(false); 198 203 tbClose.setOpaque(false); 199 tbClose.add(close); 204 tbClose.add(btnClose); 205 206 JToolBar tbHelp = null; 207 if (note.getHelpTopic() != null) { 208 JButton btnHelp = new JButton(tr("Help")); 209 btnHelp.setIcon(ImageProvider.get("help")); 210 btnHelp.setToolTipText(tr("Show help information")); 211 HelpUtil.setHelpContext(btnHelp, note.getHelpTopic()); 212 btnHelp.addActionListener(new AbstractAction() { 213 @Override 214 public void actionPerformed(ActionEvent e) { 215 SwingUtilities.invokeLater(new Runnable() { 216 @Override 217 public void run() { 218 HelpBrowser.setUrlForHelpTopic(note.getHelpTopic()); 219 } 220 }); 221 } 222 }); 223 btnHelp.setOpaque(false); 224 tbHelp = new JToolBar(); 225 tbHelp.setFloatable(false); 226 tbHelp.setBorderPainted(false); 227 tbHelp.setOpaque(false); 228 tbHelp.add(btnHelp); 229 } 200 230 201 231 setOpaque(false); … … 221 251 hgroup.addComponent(icon); 222 252 } 223 hgroup.addComponent(content).addComponent(tbClose); 253 if (tbHelp != null) { 254 hgroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) 255 .addComponent(content) 256 .addComponent(tbHelp) 257 ); 258 } else { 259 hgroup.addComponent(content); 260 } 261 hgroup.addComponent(tbClose); 224 262 GroupLayout.ParallelGroup vgroup = layout.createParallelGroup(); 225 263 if (icon != null) { 226 264 vgroup.addComponent(icon); 227 265 } 228 vgroup.addComponent(content).addComponent(tbClose); 266 vgroup.addComponent(content); 267 vgroup.addComponent(tbClose); 229 268 layout.setHorizontalGroup(hgroup); 230 layout.setVerticalGroup(vgroup); 269 270 if (tbHelp != null) { 271 layout.setVerticalGroup(layout.createSequentialGroup() 272 .addGroup(vgroup) 273 .addComponent(tbHelp) 274 ); 275 } else { 276 layout.setVerticalGroup(vgroup); 277 } 231 278 232 279 /*
Note:
See TracChangeset
for help on using the changeset viewer.