Changeset 2512 in josm for trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
- Timestamp:
- 2009-11-24T10:45:04+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r2387 r2512 43 43 /** the list of bookmarks */ 44 44 private BookmarkList bookmarks; 45 45 46 46 /** the parent download GUI */ 47 47 private DownloadDialog parent; 48 48 49 49 /** displays information about the current download area */ 50 50 private JMultilineLabel lblCurrentDownloadArea; 51 51 /** the add action */ 52 52 private AddAction actAdd; 53 53 54 54 /** 55 * Creates the panel with the action buttons on the left 56 * 55 * Creates the panel with the action buttons on the left 56 * 57 57 * @return the panel with the action buttons on the left 58 58 */ … … 78 78 return pnl; 79 79 } 80 80 81 81 protected JPanel buildDownloadAreaAddPanel() { 82 82 JPanel pnl = new JPanel(); 83 83 pnl.setLayout(new GridBagLayout()); 84 84 85 85 GridBagConstraints gc = new GridBagConstraints(); 86 86 gc.anchor = GridBagConstraints.NORTHWEST; … … 89 89 gc.weighty = 1.0; 90 90 gc.insets = new Insets(5,5,5,5); 91 91 92 92 pnl.add(lblCurrentDownloadArea = new JMultilineLabel(""), gc); 93 93 94 94 gc.anchor = GridBagConstraints.NORTHEAST; 95 95 gc.fill = GridBagConstraints.HORIZONTAL; … … 100 100 return pnl; 101 101 } 102 102 103 103 public void addGui(final DownloadDialog gui) { 104 104 JPanel dlg = new JPanel(new GridBagLayout()); 105 105 gui.addDownloadAreaSelector(dlg, tr("Bookmarks")); 106 106 GridBagConstraints gc = new GridBagConstraints(); 107 108 107 109 108 bookmarks = new BookmarkList(); 110 109 bookmarks.getSelectionModel().addListSelectionListener(new ListSelectionListener() { … … 117 116 }); 118 117 bookmarks.addMouseListener(new DoubleClickAdapter()); 119 118 120 119 gc.fill = GridBagConstraints.HORIZONTAL; 121 120 gc.weightx = 1.0; 122 gc.weighty = 0.0; 121 gc.weighty = 0.0; 123 122 gc.gridwidth = 2; 124 123 dlg.add(buildDownloadAreaAddPanel(),gc); 125 124 126 125 gc.gridwidth = 1; 127 126 gc.gridx = 0; … … 129 128 gc.fill = GridBagConstraints.VERTICAL; 130 129 gc.weightx = 0.0; 131 gc.weighty = 1.0; 130 gc.weighty = 1.0; 132 131 dlg.add(buildButtonPanel(),gc); 133 132 … … 137 136 gc.fill = GridBagConstraints.BOTH; 138 137 gc.weightx = 1.0; 139 gc.weighty = 1.0; 138 gc.weighty = 1.0; 140 139 gc.gridx = 1; 141 dlg.add(new JScrollPane(bookmarks), gc); 142 140 dlg.add(new JScrollPane(bookmarks), gc); 141 143 142 this.parent = gui; 144 143 } 145 144 146 145 protected void updateDownloadAreaLabel() { 147 146 if (currentArea == null) { … … 154 153 currentArea.getMax().lonToString(CoordinateFormat.DECIMAL_DEGREES) 155 154 ) 156 ); 157 } 158 } 159 155 ); 156 } 157 } 158 160 159 /** 161 * Sets the current download area 162 * 163 * @param area the download area. 160 * Sets the current download area 161 * 162 * @param area the download area. 164 163 */ 165 164 public void setDownloadArea(Bounds area) { … … 170 169 actAdd.setEnabled(area != null); 171 170 } 172 171 173 172 /** 174 173 * The action to add a new bookmark for the current download area. … … 181 180 putValue(SHORT_DESCRIPTION, tr("Add a bookmark for the currently selected download area")); 182 181 } 183 182 184 183 public void actionPerformed(ActionEvent e) { 185 184 if (currentArea == null) { … … 203 202 ((DefaultListModel)bookmarks.getModel()).addElement(b); 204 203 bookmarks.save(); 205 } 206 } 207 } 208 204 } 205 } 206 } 207 209 208 class RemoveAction extends AbstractAction implements ListSelectionListener{ 210 209 public RemoveAction() { … … 214 213 updateEnabledState(); 215 214 } 216 215 217 216 public void actionPerformed(ActionEvent e) { 218 217 Object[] sels = bookmarks.getSelectedValues(); … … 230 229 public void valueChanged(ListSelectionEvent e) { 231 230 updateEnabledState(); 232 } 233 } 234 231 } 232 } 233 235 234 class RenameAction extends AbstractAction implements ListSelectionListener{ 236 235 public RenameAction() { … … 240 239 updateEnabledState(); 241 240 } 242 241 243 242 public void actionPerformed(ActionEvent e) { 244 243 Object[] sels = bookmarks.getSelectedValues(); … … 247 246 } 248 247 Bookmark b = (Bookmark)sels[0]; 249 Object value = 248 Object value = 250 249 JOptionPane.showInputDialog( 251 250 Main.parent,tr("Please enter a name for the bookmarked download area."), … … 257 256 ); 258 257 if (value != null) { 259 b.setName(value.toString()); 258 b.setName(value.toString()); 260 259 bookmarks.save(); 261 260 bookmarks.repaint(); … … 267 266 public void valueChanged(ListSelectionEvent e) { 268 267 updateEnabledState(); 269 } 270 } 271 268 } 269 } 270 272 271 class DoubleClickAdapter extends MouseAdapter { 273 272 @Override 274 273 public void mouseClicked(MouseEvent e) { 275 if (!(SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2)) 274 if (!(SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2)) 276 275 return; 277 276 int idx = bookmarks.locationToIndex(e.getPoint()); … … 279 278 return; 280 279 Bookmark b = (Bookmark)bookmarks.getModel().getElementAt(idx); 281 parent.startDownload(b.getArea()); 282 } 283 } 280 parent.startDownload(b.getArea()); 281 } 282 } 284 283 }
Note:
See TracChangeset
for help on using the changeset viewer.