Changeset 9685 in josm
- Timestamp:
- 2016-01-30T01:43:42+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadDialog.java
r8840 r9685 13 13 * @since 7358 14 14 */ 15 public abstract class AbstractUploadDialog extends JDialog {15 public abstract class AbstractUploadDialog extends JDialog implements IUploadDialog { 16 16 17 17 private boolean canceled; … … 181 181 } 182 182 183 /** 184 * Returns true if the dialog was canceled 185 * 186 * @return true if the dialog was canceled 187 */ 183 @Override 188 184 public final boolean isCanceled() { 189 185 return canceled; … … 199 195 } 200 196 201 /** 202 * Remembers the user input in the preference settings 203 */ 197 @Override 204 198 public void rememberUserInput() { 205 199 // Override if needed -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r9484 r9685 95 95 } 96 96 97 /** 98 * Returns the default list of sources. 99 * @return the default list of sources 100 */ 97 101 public static List<String> getDefaultSources() { 98 102 return Arrays.asList("knowledge", "survey", "Bing"); … … 140 144 141 145 @Override 142 public void keyReleased(KeyEvent e) {} 146 public void keyReleased(KeyEvent e) { 147 // Do nothing 148 } 143 149 144 150 @Override 145 public void keyPressed(KeyEvent e) {} 151 public void keyPressed(KeyEvent e) { 152 // Do nothing 153 } 146 154 } 147 155 ); … … 169 177 } 170 178 179 /** 180 * Initializes editing of upload comment. 181 */ 171 182 public void initEditingOfUploadComment() { 172 183 hcbUploadComment.getEditor().selectAll(); 173 184 hcbUploadComment.requestFocusInWindow(); 185 } 186 187 /** 188 * Initializes editing of upload source. 189 */ 190 public void initEditingOfUploadSource() { 191 hcbUploadSource.getEditor().selectAll(); 192 hcbUploadSource.requestFocusInWindow(); 174 193 } 175 194 -
trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
r9530 r9685 3 3 4 4 import java.awt.BorderLayout; 5 import java.util.HashMap;6 5 import java.util.Map; 7 6 import java.util.Observable; … … 14 13 import org.openstreetmap.josm.Main; 15 14 import org.openstreetmap.josm.data.osm.Changeset; 16 import org.openstreetmap.josm.data.osm.DataSet;17 15 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 18 16 import org.openstreetmap.josm.gui.tagging.TagModel; … … 96 94 97 95 /** 98 * @return an empty map99 * @deprecated No longer supported, returns an empty map100 */101 @Deprecated102 public Map<String, String> getDefaultTags() {103 return new HashMap<>();104 }105 106 /**107 * @param tags ignored108 * @deprecated No longer supported, does nothing; use {@link UploadDialog#setChangesetTags(DataSet)} instead!109 */110 @Deprecated111 public void setDefaultTags(Map<String, String> tags) {112 // Deprecated113 }114 115 /**116 96 * Initializes the panel for user input 117 97 */ -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r9543 r9685 10 10 import java.awt.Dimension; 11 11 import java.awt.FlowLayout; 12 import java.awt.GraphicsEnvironment; 12 13 import java.awt.GridBagLayout; 13 14 import java.awt.event.ActionEvent; … … 177 178 178 179 // -- upload button 179 btnUpload = new SideButton(new UploadAction( ));180 btnUpload = new SideButton(new UploadAction(this)); 180 181 pnl.add(btnUpload); 181 182 btnUpload.setFocusable(true); … … 183 184 184 185 // -- cancel button 185 CancelAction cancelAction = new CancelAction( );186 CancelAction cancelAction = new CancelAction(this); 186 187 pnl.add(new SideButton(cancelAction)); 187 188 getRootPane().registerKeyboardAction( … … 370 371 } 371 372 372 /** 373 * @deprecated No longer supported, does nothing; 374 * @return empty map 375 */ 376 @Deprecated 377 public Map<String, String> getDefaultChangesetTags() { 378 return pnlTagSettings.getDefaultTags(); 379 } 380 381 /** 382 * @param tags ignored 383 * @deprecated No longer supported, does nothing; use {@link #setChangesetTags(DataSet)} instead! 384 */ 385 @Deprecated 386 public void setDefaultChangesetTags(Map<String, String> tags) { 387 // Deprecated 388 } 389 390 /** 391 * Replies the {@link UploadStrategySpecification} the user entered in the dialog. 392 * 393 * @return the {@link UploadStrategySpecification} the user entered in the dialog. 394 */ 373 @Override 395 374 public UploadStrategySpecification getUploadStrategySpecification() { 396 375 UploadStrategySpecification spec = pnlUploadStrategySelectionPanel.getUploadStrategySpecification(); … … 399 378 } 400 379 401 /** 402 * Returns the current value for the upload comment 403 * 404 * @return the current value for the upload comment 405 */ 406 protected String getUploadComment() { 380 @Override 381 public String getUploadComment() { 407 382 return changesetCommentModel.getComment(); 408 383 } 409 384 410 /** 411 * Returns the current value for the changeset source 412 * 413 * @return the current value for the changeset source 414 */ 415 protected String getUploadSource() { 385 @Override 386 public String getUploadSource() { 416 387 return changesetSourceModel.getComment(); 417 388 } … … 449 420 450 421 /** 451 * Handles an upload 452 * 453 */ 454 class UploadAction extends AbstractAction { 455 UploadAction() { 422 * Handles an upload. 423 */ 424 static class UploadAction extends AbstractAction { 425 426 private final transient IUploadDialog dialog; 427 428 UploadAction(IUploadDialog dialog) { 429 this.dialog = dialog; 456 430 putValue(NAME, tr("Upload Changes")); 457 431 putValue(SMALL_ICON, ImageProvider.get("upload")); … … 493 467 494 468 protected boolean warnUploadTag(final String title, final String message, final String togglePref) { 495 ExtendedDialog dlg = new ExtendedDialog(UploadDialog.this, 496 title, 497 new String[] {tr("Revise"), tr("Cancel"), tr("Continue as is")}); 498 dlg.setContent("<html>" + message + "</html>"); 499 dlg.setButtonIcons(new Icon[] { 469 String[] buttonTexts = new String[] {tr("Revise"), tr("Cancel"), tr("Continue as is")}; 470 Icon[] buttonIcons = new Icon[] { 500 471 new ImageProvider("ok").setMaxSize(ImageSizes.LARGEICON).get(), 501 472 new ImageProvider("cancel").setMaxSize(ImageSizes.LARGEICON).get(), 502 473 new ImageProvider("upload").setMaxSize(ImageSizes.LARGEICON).addOverlay( 503 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)).get()} );504 dlg.setToolTipTexts(new String[] {474 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)).get()}; 475 String[] tooltips = new String[] { 505 476 tr("Return to the previous dialog to enter a more descriptive comment"), 506 477 tr("Cancel and return to the previous dialog"), 507 tr("Ignore this hint and upload anyway")}); 478 tr("Ignore this hint and upload anyway")}; 479 480 if (GraphicsEnvironment.isHeadless()) { 481 return false; 482 } 483 484 ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts); 485 dlg.setContent("<html>" + message + "</html>"); 486 dlg.setButtonIcons(buttonIcons); 487 dlg.setToolTipTexts(tooltips); 508 488 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 509 489 dlg.toggleEnable(togglePref); … … 514 494 protected void warnIllegalChunkSize() { 515 495 HelpAwareOptionPane.showOptionDialog( 516 UploadDialog.this,496 (Component) dialog, 517 497 tr("Please enter a valid chunk size first"), 518 498 tr("Illegal chunk size"), … … 524 504 @Override 525 505 public void actionPerformed(ActionEvent e) { 526 if ((getUploadComment().trim().length() < 10 && warnUploadComment()) /* abort for missing comment */ 527 || (getUploadSource().trim().isEmpty() && warnUploadSource()) /* abort for missing changeset source */ 528 ) { 529 tpConfigPanels.setSelectedIndex(0); 530 pnlBasicUploadSettings.initEditingOfUploadComment(); 506 if (dialog.getUploadComment().trim().length() < 10 && warnUploadComment()) { 507 // abort for missing comment 508 dialog.handleMissingComment(); 509 return; 510 } 511 if (dialog.getUploadSource().trim().isEmpty() && warnUploadSource()) { 512 // abort for missing changeset source 513 dialog.handleMissingSource(); 531 514 return; 532 515 } … … 535 518 * though, accept if key and value are empty (cf. xor). */ 536 519 List<String> emptyChangesetTags = new ArrayList<>(); 537 for (final Entry<String, String> i : pnlTagSettings.getTags(true).entrySet()) {520 for (final Entry<String, String> i : dialog.getTags(true).entrySet()) { 538 521 final boolean isKeyEmpty = i.getKey() == null || i.getKey().trim().isEmpty(); 539 522 final boolean isValueEmpty = i.getValue() == null || i.getValue().trim().isEmpty(); … … 553 536 JOptionPane.WARNING_MESSAGE 554 537 )) { 555 tpConfigPanels.setSelectedIndex(0); 556 pnlBasicUploadSettings.initEditingOfUploadComment(); 538 dialog.handleMissingComment(); 557 539 return; 558 540 } 559 541 560 UploadStrategySpecification strategy = getUploadStrategySpecification();542 UploadStrategySpecification strategy = dialog.getUploadStrategySpecification(); 561 543 if (strategy.getStrategy().equals(UploadStrategy.CHUNKED_DATASET_STRATEGY) 562 544 && strategy.getChunkSize() == UploadStrategySpecification.UNSPECIFIED_CHUNK_SIZE) { 563 545 warnIllegalChunkSize(); 564 tpConfigPanels.setSelectedIndex(0);546 dialog.handleIllegalChunkSize(); 565 547 return; 566 548 } 567 setCanceled(false); 568 setVisible(false); 569 } 570 } 571 572 /** 573 * Action for canceling the dialog 574 * 575 */ 576 class CancelAction extends AbstractAction { 577 CancelAction() { 549 if (dialog instanceof AbstractUploadDialog) { 550 ((AbstractUploadDialog) dialog).setCanceled(false); 551 ((AbstractUploadDialog) dialog).setVisible(false); 552 } 553 } 554 } 555 556 /** 557 * Action for canceling the dialog. 558 */ 559 static class CancelAction extends AbstractAction { 560 561 private final transient IUploadDialog dialog; 562 563 CancelAction(IUploadDialog dialog) { 564 this.dialog = dialog; 578 565 putValue(NAME, tr("Cancel")); 579 566 putValue(SMALL_ICON, ImageProvider.get("cancel")); … … 583 570 @Override 584 571 public void actionPerformed(ActionEvent e) { 585 setCanceled(true); 586 setVisible(false); 572 if (dialog instanceof AbstractUploadDialog) { 573 ((AbstractUploadDialog) dialog).setCanceled(true); 574 ((AbstractUploadDialog) dialog).setVisible(false); 575 } 587 576 } 588 577 } … … 665 654 return getLastChangesetTagFromHistory(BasicUploadSettingsPanel.SOURCE_HISTORY_KEY, BasicUploadSettingsPanel.getDefaultSources()); 666 655 } 656 657 @Override 658 public Map<String, String> getTags(boolean keepEmpty) { 659 return pnlTagSettings.getTags(keepEmpty); 660 } 661 662 @Override 663 public void handleMissingComment() { 664 tpConfigPanels.setSelectedIndex(0); 665 pnlBasicUploadSettings.initEditingOfUploadComment(); 666 } 667 668 @Override 669 public void handleMissingSource() { 670 tpConfigPanels.setSelectedIndex(0); 671 pnlBasicUploadSettings.initEditingOfUploadSource(); 672 } 673 674 @Override 675 public void handleIllegalChunkSize() { 676 tpConfigPanels.setSelectedIndex(0); 677 } 667 678 }
Note:
See TracChangeset
for help on using the changeset viewer.