Changeset 2158 in josm for trunk/src/org
- Timestamp:
- 2009-09-19T10:37:43+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2148 r2158 6 6 7 7 import java.awt.BorderLayout; 8 import java.awt.Component;9 8 import java.awt.Dimension; 10 9 import java.awt.FlowLayout; … … 15 14 import java.awt.event.ItemEvent; 16 15 import java.awt.event.ItemListener; 16 import java.awt.event.KeyEvent; 17 17 import java.awt.event.WindowAdapter; 18 18 import java.awt.event.WindowEvent; 19 import java.text.SimpleDateFormat;20 19 import java.util.ArrayList; 21 20 import java.util.Collection; … … 29 28 import javax.swing.ButtonGroup; 30 29 import javax.swing.DefaultComboBoxModel; 31 import javax.swing.I mageIcon;30 import javax.swing.InputMap; 32 31 import javax.swing.JButton; 33 32 import javax.swing.JCheckBox; 34 33 import javax.swing.JComboBox; 34 import javax.swing.JComponent; 35 35 import javax.swing.JDialog; 36 36 import javax.swing.JLabel; … … 41 41 import javax.swing.JScrollPane; 42 42 import javax.swing.JTabbedPane; 43 import javax.swing.ListCellRenderer; 44 import javax.swing.UIManager; 43 import javax.swing.KeyStroke; 45 44 import javax.swing.event.ChangeEvent; 46 45 import javax.swing.event.ChangeListener; … … 106 105 /** the tabbed pane used below of the list of primitives */ 107 106 private JTabbedPane southTabbedPane; 107 /** the upload button */ 108 private JButton btnUpload; 108 109 109 110 private ChangesetSelectionPanel pnlChangesetSelection; … … 124 125 } 125 126 126 127 /** 128 * builds the content panel for the upload dialog 129 * 130 * @return the content panel 131 */ 127 132 protected JPanel buildContentPanel() { 128 133 JPanel pnl = new JPanel(); … … 160 165 } 161 166 167 /** 168 * builds the panel with the OK and CANCEL buttons 169 * 170 * @return 171 */ 162 172 protected JPanel buildActionPanel() { 163 173 JPanel pnl = new JPanel(); … … 166 176 167 177 // -- upload button 168 pnl.add(new SideButton(new UploadAction())); 178 UploadAction uploadAction = new UploadAction(); 179 pnl.add(btnUpload = new SideButton(uploadAction)); 180 btnUpload.setFocusable(true); 181 InputMap inputMap = btnUpload.getInputMap(); 182 inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "doUpload"); 183 btnUpload.getActionMap().put("doUpload", uploadAction); 169 184 170 185 // -- cancel button 171 pnl.add(new SideButton(new CancelAction())); 172 186 CancelAction cancelAction = new CancelAction(); 187 pnl.add(new SideButton(cancelAction)); 188 getRootPane().registerKeyboardAction( 189 cancelAction, 190 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), 191 JComponent.WHEN_IN_FOCUSED_WINDOW 192 ); 173 193 return pnl; 174 194 } … … 178 198 */ 179 199 protected void build() { 200 setTitle(tr("Upload")); 180 201 getContentPane().setLayout(new BorderLayout()); 181 202 getContentPane().add(buildContentPanel(), BorderLayout.CENTER); … … 312 333 } 313 334 335 /** 336 * Replies true if the changeset is to be closed after the 337 * next upload 338 * 339 * @return true if the changeset is to be closed after the 340 * next upload; false, otherwise 341 */ 314 342 public boolean isDoCloseAfterUpload() { 315 343 return pnlChangesetSelection.isCloseAfterUpload(); … … 326 354 } 327 355 356 /** 357 * Replies the current value for the upload comment 358 * 359 * @return the current value for the upload comment 360 */ 328 361 protected String getUploadComment() { 329 362 switch(southTabbedPane.getSelectedIndex()) { 330 case 0:331 return pnlChangesetSelection.getUploadComment();332 case 1:333 TagModel tm = tagEditorPanel.getModel().get("comment");334 return tm == null? "" : tm.getValue();363 case 0: 364 return pnlChangesetSelection.getUploadComment(); 365 case 1: 366 TagModel tm = tagEditorPanel.getModel().get("comment"); 367 return tm == null? "" : tm.getValue(); 335 368 } 336 369 return ""; 337 370 } 338 371 372 /** 373 * Replies true, if the dialog was canceled 374 * 375 * @return true, if the dialog was canceled 376 */ 339 377 public boolean isCanceled() { 340 378 return canceled; 341 379 } 342 380 381 /** 382 * Sets whether the dialog was canceld 383 * 384 * @param canceled true, if the dialog is canceled 385 */ 343 386 protected void setCanceled(boolean canceled) { 344 387 this.canceled = canceled; … … 589 632 } 590 633 ); 634 cmt.getEditor().addActionListener( 635 new ActionListener() { 636 public void actionPerformed(ActionEvent e) { 637 btnUpload.requestFocusInWindow(); 638 } 639 } 640 ); 591 641 pnl.add(cmt, GBC.eol().fill(GBC.HORIZONTAL)); 592 642 return pnl; … … 702 752 } 703 753 754 public void prepareDialogForNextUpload(Changeset cs) { 755 if (cs == null || cs.getId() == 0) { 756 rbUseNew.setSelected(true); 757 cbCloseAfterUpload.setSelected(true); 758 } if (cs.getId() == 0) { 759 rbUseNew.setSelected(true); 760 cbCloseAfterUpload.setSelected(true); 761 } else if (cs.isOpen()) { 762 rbExisting.setSelected(true); 763 cbCloseAfterUpload.setSelected(false); 764 } else { 765 rbUseNew.setSelected(true); 766 cbCloseAfterUpload.setSelected(true); 767 } 768 } 769 704 770 /** 705 771 * Replies the current upload comment … … 762 828 tagEditorPanel.getModel().add("created_by", getDefaultCreatedBy()); 763 829 tagEditorPanel.getModel().appendNewTag(); 764 rbUseNew.setSelected(true);765 830 } else if (cs.getId() == 0) { 766 831 if (cs.get("created_by") == null) { … … 769 834 tagEditorPanel.getModel().initFromPrimitive(cs); 770 835 tagEditorPanel.getModel().appendNewTag(); 771 rbUseNew.setSelected(true);772 836 } else if (cs.getId() > 0 && cs.isOpen()){ 773 837 if (cs.get("created_by") == null) { … … 790 854 } 791 855 } 856 prepareDialogForNextUpload(cs); 792 857 } 793 858
Note:
See TracChangeset
for help on using the changeset viewer.