Changeset 2301 in josm
- Timestamp:
- 2009-10-24T07:30:45+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java
r2070 r2301 55 55 public boolean executeCommand() { 56 56 super.executeCommand(); 57 conflict.getMy().setOsmId( 58 conflict.getMy().getId(), 59 (int)Math.max(conflict.getMy().getVersion(), conflict.getTheir().getVersion()) 60 ); 57 if (!conflict.getMy().isNew()) { 58 conflict.getMy().setOsmId( 59 conflict.getMy().getId(), 60 (int)Math.max(conflict.getMy().getVersion(), conflict.getTheir().getVersion()) 61 ); 62 } 61 63 getLayer().getConflicts().remove(conflict); 62 64 rememberConflict(conflict); -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2285 r2301 24 24 import org.openstreetmap.josm.Main; 25 25 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 26 import org.openstreetmap.josm.gui.help.Help Builder;26 import org.openstreetmap.josm.gui.help.HelpUtil; 27 27 import org.openstreetmap.josm.tools.GBC; 28 28 import org.openstreetmap.josm.tools.ImageProvider; … … 218 218 if (showHelpButton) { 219 219 buttonsPanel.add(new JButton(new HelpAction()), GBC.std().insets(2,2,2,2)); 220 Help Builder.setHelpContext(getRootPane(),helpTopic);220 HelpUtil.setHelpContext(getRootPane(),helpTopic); 221 221 } 222 222 -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r2255 r2301 18 18 19 19 import org.openstreetmap.josm.gui.help.HelpBrowser; 20 import org.openstreetmap.josm.gui.help.HelpBuilder; 20 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 21 import org.openstreetmap.josm.gui.help.HelpUtil; 21 22 import org.openstreetmap.josm.tools.ImageProvider; 22 23 import org.openstreetmap.josm.tools.WindowGeometry; … … 61 62 } 62 63 64 static private List<JButton> createOptionButtons(ButtonSpec[] options, String helpTopic) { 65 List<JButton> buttons = new ArrayList<JButton>(); 66 if (options == null) { 67 buttons.add(new JButton(tr("OK"))); 68 } else { 69 for (ButtonSpec spec: options) { 70 JButton b = new JButton(spec.text); 71 b.setIcon(spec.icon); 72 b.setToolTipText(spec.tooltipText == null? "" : spec.tooltipText); 73 if (helpTopic != null) { 74 HelpUtil.setHelpContext(b, helpTopic); 75 } 76 b.setFocusable(true); 77 buttons.add(b); 78 79 } 80 } 81 return buttons; 82 } 83 84 static private JButton createHelpButton(final String helpTopic) { 85 JButton b = new JButton(tr("Help")); 86 b.setIcon(ImageProvider.get("help")); 87 b.setToolTipText(tr("Show help information")); 88 HelpUtil.setHelpContext(b, helpTopic); 89 b.addActionListener( 90 new ActionListener() { 91 public void actionPerformed(ActionEvent e) { 92 HelpBrowserProxy.getInstance().setUrlForHelpTopic(completeHelpTopic(helpTopic)); 93 } 94 } 95 ); 96 return b; 97 } 98 99 static private String completeHelpTopic(String helpTopic) { 100 if (helpTopic == null) return null; 101 if (! helpTopic.startsWith("/")) { 102 helpTopic = "/" + helpTopic; 103 } 104 return "Help" + helpTopic; 105 } 106 63 107 /** 64 108 * Displays an option dialog which is aware of a help context. If <code>helpTopic</code> isn't null, … … 67 111 * browser. 68 112 * 113 * <code>helpTopic</code> is the trailing part of a JOSM online help URL, i.e. the part after the leading 114 * <code>http://josm.openstreetmap.de/wiki/Help</code>. It should start with a leading '/' and it 115 * may include and anchor after a '#'. 116 * 117 * <strong>Examples</strong> 118 * <ul> 119 * <li>/Dialogs/RelationEditor</li> 120 * <li>/Dialogs/RelationEditor#ConflictInData</li> 121 * </ul> 122 * 69 123 * In addition, the option buttons display JOSM icons, similar to ExtendedDialog. 70 124 * … … 79 133 * @return the index of the selected option or {@link JOptionPane#CLOSED_OPTION} 80 134 */ 81 static public int showOptionDialog(Component parentComponent, Object msg, String title, int messageType, Icon icon, ButtonSpec[] options, Object defaultOption, final String helpTopic) { 82 List<JButton> buttons = new ArrayList<JButton>(); 83 84 if (options == null) { 85 buttons.add(new JButton(tr("OK"))); 86 } else { 87 for (ButtonSpec spec: options) { 88 JButton b = new JButton(spec.text); 89 b.setIcon(spec.icon); 90 b.setToolTipText(spec.tooltipText == null? "" : spec.tooltipText); 91 if (helpTopic != null) { 92 HelpBuilder.setHelpContext(b, helpTopic); 93 } 94 buttons.add(b); 95 96 } 97 } 135 static public int showOptionDialog(Component parentComponent, Object msg, String title, int messageType, Icon icon, final ButtonSpec[] options, final ButtonSpec defaultOption, final String helpTopic) { 136 final List<JButton> buttons = createOptionButtons(options, helpTopic); 98 137 if (helpTopic != null) { 99 JButton b = new JButton(tr("Help")); 100 b.setIcon(ImageProvider.get("help")); 101 b.setToolTipText(tr("Show help information")); 102 HelpBuilder.setHelpContext(b, helpTopic); 103 b.addActionListener( 104 new ActionListener() { 105 public void actionPerformed(ActionEvent e) { 106 HelpBrowser browser = new HelpBrowser(); 107 browser.setUrlForHelpTopic("Help/" + helpTopic); 108 browser.setVisible(true); 109 } 110 } 111 ); 112 buttons.add(b); 138 buttons.add(createHelpButton(helpTopic)); 113 139 } 114 140 … … 145 171 super.windowClosed(e); 146 172 } 173 174 @Override 175 public void windowOpened(WindowEvent e) { 176 if (defaultOption != null && options != null && options.length > 0) { 177 int i; 178 for (i=0; i<options.length;i++) { 179 if (options[i] == defaultOption) { 180 break; 181 } 182 } 183 if (i >= options.length) return; // default option not an option? 184 185 buttons.get(i).requestFocusInWindow(); 186 } 187 } 147 188 } 148 189 ); … … 155 196 WindowGeometry.centerOnScreen(dialog.getSize()).applySafe(dialog); 156 197 if (helpTopic != null) { 157 Help Builder.setHelpContext(dialog.getRootPane(), helpTopic);198 HelpUtil.setHelpContext(dialog.getRootPane(), helpTopic); 158 199 } 159 200 dialog.setVisible(true); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r2255 r2301 46 46 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 47 47 import org.openstreetmap.josm.gui.SideButton; 48 import org.openstreetmap.josm.gui.help.Help Builder;48 import org.openstreetmap.josm.gui.help.HelpUtil; 49 49 import org.openstreetmap.josm.gui.layer.Layer; 50 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer; -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r2274 r2301 30 30 import org.openstreetmap.josm.gui.help.HelpBrowser; 31 31 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 32 import org.openstreetmap.josm.gui.help.Help Builder;32 import org.openstreetmap.josm.gui.help.HelpUtil; 33 33 import org.openstreetmap.josm.tools.ImageProvider; 34 34 … … 150 150 151 151 resolver.addPropertyChangeListener(this); 152 Help Builder.setHelpContext(this.getRootPane(), "Dialog/ConflictDialog");152 HelpUtil.setHelpContext(this.getRootPane(), "Dialog/ConflictDialog"); 153 153 } 154 154 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2240 r2301 21 21 import javax.swing.JPanel; 22 22 import javax.swing.JScrollPane; 23 import javax.swing.KeyStroke; 23 24 import javax.swing.ListSelectionModel; 24 25 import javax.swing.SwingUtilities; … … 115 116 buttonPanel.add(new SideButton(selectAction), GBC.eol()); 116 117 117 118 118 add(buttonPanel, BorderLayout.SOUTH); 119 displaylist.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0), "deleteRelation"); 120 displaylist.getActionMap().put("deleteRelation", deleteAction); 119 121 120 122 // register as layer listener -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r2255 r2301 30 30 import org.openstreetmap.josm.actions.JosmAction; 31 31 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 32 import org.openstreetmap.josm.gui.help.Help Builder;32 import org.openstreetmap.josm.gui.help.HelpUtil; 33 33 import org.openstreetmap.josm.gui.help.Helpful; 34 34 import org.openstreetmap.josm.tools.GBC; … … 381 381 } 382 382 setTitle(titleBar.getTitle()); 383 Help Builder.setHelpContext(getRootPane(), helpTopic());383 HelpUtil.setHelpContext(getRootPane(), helpTopic()); 384 384 } 385 385 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2273 r2301 64 64 import org.openstreetmap.josm.gui.DefaultNameFormatter; 65 65 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 66 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 66 67 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 67 68 import org.openstreetmap.josm.gui.SideButton; 69 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 68 70 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 69 71 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 87 89 88 90 static private final Logger logger = Logger.getLogger(GenericRelationEditor.class.getName()); 89 static private final Dimension DEFAULT_EDITOR_DIMENSION = new Dimension(700, 500);90 91 91 92 /** the tag table and its model */ … … 592 593 ); 593 594 switch(ret) { 594 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return;595 case JOptionPane.CLOSED_OPTION: return;596 case JOptionPane.NO_OPTION: return;597 case JOptionPane.YES_OPTION:598 memberTableModel.removeMembersReferringTo(toCheck);599 break;595 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 596 case JOptionPane.CLOSED_OPTION: return; 597 case JOptionPane.NO_OPTION: return; 598 case JOptionPane.YES_OPTION: 599 memberTableModel.removeMembersReferringTo(toCheck); 600 break; 600 601 } 601 602 } … … 628 629 ); 629 630 switch(ret) { 630 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true;631 case JOptionPane.YES_OPTION: return true;632 case JOptionPane.NO_OPTION: return false;633 case JOptionPane.CLOSED_OPTION: return false;634 case JOptionPane.CANCEL_OPTION: throw new AddAbortException();631 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true; 632 case JOptionPane.YES_OPTION: return true; 633 case JOptionPane.NO_OPTION: return false; 634 case JOptionPane.CLOSED_OPTION: return false; 635 case JOptionPane.CANCEL_OPTION: throw new AddAbortException(); 635 636 } 636 637 // should not happen … … 1046 1047 1047 1048 protected boolean confirmClosingBecauseOfDirtyState() { 1048 String [] options = new String[] { 1049 tr("Yes, create a conflict and close"), 1050 tr("No, continue editing") 1049 ButtonSpec [] options = new ButtonSpec[] { 1050 new ButtonSpec( 1051 tr("Yes, create a conflict and close"), 1052 ImageProvider.get("ok"), 1053 tr("Click to create a conflict and close this relation editor") , 1054 null /* no specific help topic */ 1055 ), 1056 new ButtonSpec( 1057 tr("No, continue editing"), 1058 ImageProvider.get("cancel"), 1059 tr("Click to to return to the relation editor and to resume relation editing") , 1060 null /* no specific help topic */ 1061 ) 1051 1062 }; 1052 int ret = JOptionPane.showOptionDialog( 1063 1064 int ret = HelpAwareOptionPane.showOptionDialog( 1053 1065 Main.parent, 1054 1066 tr("<html>This relation has been changed outside of the editor.<br>" … … 1057 1069 + "Do you want to create a conflict and close the editor?</html>"), 1058 1070 tr("Conflict in data"), 1059 JOptionPane.YES_NO_OPTION,1060 1071 JOptionPane.WARNING_MESSAGE, 1061 1072 null, 1062 1073 options, 1063 options[0] 1074 options[0], // OK is default 1075 "/Dialog/RelationEditor#RelationChangedOutsideOfEditor" 1064 1076 ); 1065 switch(ret) { 1066 case JOptionPane.CANCEL_OPTION: return false; 1067 case JOptionPane.YES_OPTION: return true; 1068 case JOptionPane.NO_OPTION: return false; 1069 } 1070 return false; 1077 return ret == 0; 1071 1078 } 1072 1079 … … 1240 1247 ); 1241 1248 switch(ret) { 1242 case JOptionPane.YES_OPTION: return true;1243 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return true;1244 default:1245 return false;1249 case JOptionPane.YES_OPTION: return true; 1250 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return true; 1251 default: 1252 return false; 1246 1253 } 1247 1254 } -
trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java
r2300 r2301 9 9 import org.openstreetmap.josm.Main; 10 10 11 public class Help Builder{11 public class HelpUtil { 12 12 13 13 /** 14 * Makes a component aware of context sensitive help 14 * Makes a component aware of context sensitive help. 15 15 * 16 16 * @param component the component … … 22 22 component.putClientProperty("help", topic); 23 23 } 24 24 25 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2289 r2301 53 53 import org.openstreetmap.josm.gui.SideButton; 54 54 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 55 import org.openstreetmap.josm.gui.help.Help Builder;55 import org.openstreetmap.josm.gui.help.HelpUtil; 56 56 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 57 57 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; … … 194 194 195 195 pnl.add(new SideButton(new ContextSensitiveHelpAction("/Help/Dialogs/UploadDialog"))); 196 Help Builder.setHelpContext(getRootPane(),"/Help/Dialogs/UploadDialog");196 HelpUtil.setHelpContext(getRootPane(),"/Help/Dialogs/UploadDialog"); 197 197 return pnl; 198 198 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2274 r2301 66 66 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 67 67 import org.openstreetmap.josm.gui.help.HelpBrowser; 68 import org.openstreetmap.josm.gui.help.Help Builder;68 import org.openstreetmap.josm.gui.help.HelpUtil; 69 69 import org.openstreetmap.josm.tools.DateUtils; 70 70 import org.openstreetmap.josm.tools.GBC; … … 383 383 dialog.setContentPane(pane); 384 384 dialog.pack(); 385 Help Builder.setHelpContext(dialog.getRootPane(), "Concepts/Conflict");385 HelpUtil.setHelpContext(dialog.getRootPane(), "Concepts/Conflict"); 386 386 WindowGeometry.centerOnScreen(dialog.getSize()).applySafe(dialog); 387 387 dialog.setVisible(true);
Note:
See TracChangeset
for help on using the changeset viewer.