Changeset 9526 in josm
- Timestamp:
- 2016-01-18T19:35:32+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r9059 r9526 5 5 6 6 import java.awt.BorderLayout; 7 import java.awt.Component; 7 8 import java.awt.Container; 8 9 import java.awt.Dimension; … … 70 71 /** the unique instance of the cache manager */ 71 72 private static volatile ChangesetCacheManager instance; 73 private JTabbedPane pnlChangesetDetailTabs; 72 74 73 75 /** … … 164 166 protected JPanel buildChangesetDetailPanel() { 165 167 JPanel pnl = new JPanel(new BorderLayout()); 166 JTabbedPane tp = new JTabbedPane(); 168 JTabbedPane tp = new JTabbedPane(); 169 pnlChangesetDetailTabs = tp; 167 170 168 171 // -- add the details panel … … 647 650 648 651 /** 652 * Selects the given component in the detail tabbed panel 653 * @param clazz the class of the component to select 654 */ 655 public void setSelectedComponentInDetailPanel(Class<? extends JComponent> clazz) { 656 for (Component component : pnlChangesetDetailTabs.getComponents()) { 657 if (component.getClass().equals(clazz)) { 658 pnlChangesetDetailTabs.setSelectedComponent(component); 659 break; 660 } 661 } 662 } 663 664 /** 649 665 * Runs the given changeset download task. 650 666 * @param task The changeset download task to run -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r9468 r9526 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.BorderLayout; … … 31 32 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 32 33 import org.openstreetmap.josm.gui.dialogs.ChangesetDialog; 34 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager; 35 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetDiscussionPanel; 33 36 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 37 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 51 54 private UrlLabel lblUser; 52 55 private UrlLabel lblChangeset; 53 private final OpenChangesetDialogAction changesetDialogAction = new OpenChangesetDialogAction(); 56 private final JButton lblChangesetComments = new JButton(ImageProvider.get("dialogs/notes/note_comment")); 57 private final OpenChangesetDialogAction changesetCommentsDialogAction = new OpenChangesetDialogAction(ChangesetDiscussionPanel.class); 58 private final OpenChangesetDialogAction changesetDialogAction = new OpenChangesetDialogAction(null); 54 59 private final JButton changesetButton = new JButton(changesetDialogAction); 55 60 private JPanel pnlChangesetSource; … … 100 105 pnlUserAndChangeset.add(changesetButton); 101 106 lblChangeset = new UrlLabel("", 2); 102 pnlUserAndChangeset.add(lblChangeset); 107 final JPanel pnlChangesetInfo = new JPanel(new BorderLayout()); 108 pnlChangesetInfo.add(lblChangeset, BorderLayout.CENTER); 109 lblChangesetComments.setAction(changesetCommentsDialogAction); 110 lblChangesetComments.setMargin(new Insets(0, 0, 0, 0)); 111 lblChangesetComments.setIcon(new ImageProvider("dialogs/notes/note_comment").setMaxSize(12).get()); 112 pnlChangesetInfo.add(lblChangesetComments, BorderLayout.EAST); 113 pnlUserAndChangeset.add(pnlChangesetInfo); 103 114 104 115 texChangesetComment = buildTextArea(tr("Changeset comment")); … … 193 204 } 194 205 206 /** 207 * Updates the content of this panel based on the changeset information given by {@code primitive}. 208 * @param primitive the primitive to extract the changeset information from 209 * @param isLatest whether this relates to a not yet commited changeset 210 */ 195 211 public void update(final OsmPrimitive primitive, final boolean isLatest) { 196 212 update(Changeset.fromPrimitive(primitive), isLatest, primitive.getTimestamp(), primitive.getVersion()); 197 213 } 198 214 215 /** 216 * Updates the content of this panel based on the changeset information given by {@code cs}. 217 * @param cs the changeset information 218 * @param isLatest whether this relates to a not yet commited changeset 219 * @param timestamp the timestamp 220 * @param version the version of the primitive 221 */ 199 222 public void update(final Changeset cs, final boolean isLatest, final Date timestamp, final long version) { 200 223 lblInfo.setText(getInfoText(timestamp, version, isLatest)); … … 205 228 lblChangeset.setUrl(url); 206 229 lblChangeset.setDescription(Long.toString(cs.getId())); 230 changesetCommentsDialogAction.setId(cs.getId()); 231 lblChangesetComments.setVisible(cs.getCommentsCount() > 0); 232 lblChangesetComments.setText(String.valueOf(cs.getCommentsCount())); 233 lblChangesetComments.setToolTipText(trn("This changeset has {0} comment", "This changeset has {0} comments", 234 cs.getCommentsCount(), cs.getCommentsCount())); 207 235 changesetDialogAction.setId(cs.getId()); 208 236 changesetButton.setEnabled(true); … … 229 257 lblChangeset.setDescription(tr("none")); 230 258 lblChangeset.setUrl(null); 259 lblChangesetComments.setVisible(false); 231 260 changesetDialogAction.setId(null); 232 261 changesetButton.setEnabled(false); … … 251 280 252 281 static class OpenChangesetDialogAction extends AbstractAction { 282 private final Class<? extends JComponent> componentToSelect; 253 283 private Integer id; 254 284 255 OpenChangesetDialogAction( ) {285 OpenChangesetDialogAction(Class<? extends JComponent> componentToSelect) { 256 286 super(tr("Changeset"), new ImageProvider("dialogs/changeset", "changesetmanager").resetMaxSize(new Dimension(16, 16)).get()); 257 287 putValue(SHORT_DESCRIPTION, tr("Opens the Changeset Manager window for the selected changesets")); 258 } 259 260 public void setId(Integer id) { 288 this.componentToSelect = componentToSelect; 289 } 290 291 void setId(Integer id) { 261 292 this.id = id; 262 293 } … … 265 296 public void actionPerformed(ActionEvent e) { 266 297 ChangesetDialog.LaunchChangesetManager.displayChangesets(Collections.singleton(id)); 298 if (componentToSelect != null) { 299 ChangesetCacheManager.getInstance().setSelectedComponentInDetailPanel(componentToSelect); 300 } 267 301 } 268 302 }
Note:
See TracChangeset
for help on using the changeset viewer.