Changeset 9602 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java
r9543 r9602 34 34 * This is non-modal dialog, always showing on top, which displays history information 35 35 * about a given {@link org.openstreetmap.josm.data.osm.OsmPrimitive}. 36 * 36 * @since 1709 37 37 */ 38 38 public class HistoryBrowserDialog extends JDialog implements HistoryDataSetListener { 39 39 40 40 /** the embedded browser */ 41 private HistoryBrowser browser; 42 private CloseAction closeAction; 43 private JLabel titleLabel; 44 45 /** 46 * displays the title for this dialog 41 private final HistoryBrowser browser = new HistoryBrowser(); 42 private final CloseAction closeAction = new CloseAction(); 43 private final JLabel titleLabel = new JLabel("", JLabel.CENTER); 44 45 /** 46 * Constructs a new {@code HistoryBrowserDialog}. 47 * 48 * @param history the history to be displayed 49 */ 50 public HistoryBrowserDialog(History history) { 51 super(JOptionPane.getFrameForComponent(Main.parent), false); 52 build(); 53 setHistory(history); 54 setTitle(buildTitle(history)); 55 pack(); 56 if (getInsets().top > 0) { 57 titleLabel.setVisible(false); 58 } 59 HistoryDataSet.getInstance().addHistoryDataSetListener(this); 60 addWindowListener(new WindowClosingAdapter()); 61 } 62 63 /** 64 * Constructs the title for this dialog 47 65 * 48 66 * @param h the current history 49 */ 50 protected void renderTitle(History h) { 51 String title = ""; 52 switch(h.getEarliest().getType()) { 53 case NODE: title = marktr("History for node {0}"); break; 54 case WAY: title = marktr("History for way {0}"); break; 55 case RELATION: title = marktr("History for relation {0}"); break; 56 } 57 setTitle(tr( 58 title, 59 Long.toString(h.getId()) 60 )); 67 * @return the title for this dialog 68 */ 69 static String buildTitle(History h) { 70 String title; 71 switch (h.getEarliest().getType()) { 72 case NODE: title = marktr("History for node {0}"); 73 break; 74 case WAY: title = marktr("History for way {0}"); 75 break; 76 case RELATION: title = marktr("History for relation {0}"); 77 break; 78 default: title = ""; 79 } 80 return tr(title, Long.toString(h.getId())); 61 81 } 62 82 … … 75 95 setLayout(new BorderLayout()); 76 96 77 titleLabel = new JLabel();78 titleLabel.setHorizontalAlignment(JLabel.CENTER);79 97 add(titleLabel, BorderLayout.NORTH); 80 98 81 browser = new HistoryBrowser();82 99 add(browser, BorderLayout.CENTER); 83 100 … … 88 105 pnl.add(btn); 89 106 90 btn = new SideButton(closeAction = new CloseAction());107 btn = new SideButton(closeAction); 91 108 final String closeHistoryBrowserDialogKey = "CloseHistoryBrowserDialog"; 92 109 KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); … … 105 122 106 123 /** 107 * Constructs a new {@code HistoryBrowserDialog}.108 *109 * @param history the history to be displayed110 */111 public HistoryBrowserDialog(History history) {112 super(JOptionPane.getFrameForComponent(Main.parent), false);113 build();114 setHistory(history);115 renderTitle(history);116 pack();117 if (getInsets().top > 0) {118 titleLabel.setVisible(false);119 }120 HistoryDataSet.getInstance().addHistoryDataSetListener(this);121 addWindowListener(new WindowClosingAdapter());122 }123 124 /**125 124 * Sets the current history. 126 125 * @param history current history … … 140 139 /* interface HistoryDataSetListener */ 141 140 /* ---------------------------------------------------------------------------------- */ 141 142 142 @Override 143 143 public void historyUpdated(HistoryDataSet source, PrimitiveId primitiveId) { 144 144 if (primitiveId == null || primitiveId.equals(browser.getHistory().getPrimitiveId())) { 145 browser.populate(source.getHistory(browser.getHistory().getPrimitiveId())); 145 History history = source.getHistory(browser.getHistory().getPrimitiveId()); 146 if (history != null) { 147 browser.populate(history); 148 } 146 149 } 147 150 }
Note:
See TracChangeset
for help on using the changeset viewer.