Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r8390 r8510 182 182 p.add(new JScrollPane(help), BorderLayout.CENTER); 183 183 184 addWindowListener(new WindowAdapter() {184 addWindowListener(new WindowAdapter() { 185 185 @Override public void windowClosing(WindowEvent e) { 186 186 setVisible(false); … … 190 190 p.add(buildToolBar(), BorderLayout.NORTH); 191 191 help.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Close"); 192 help.getActionMap().put("Close", new AbstractAction() {192 help.getActionMap().put("Close", new AbstractAction() { 193 193 @Override 194 194 public void actionPerformed(ActionEvent e) { … … 208 208 WindowGeometry.centerInWindow( 209 209 getParent(), 210 new Dimension(600, 400)210 new Dimension(600, 400) 211 211 ) 212 212 ).applySafe(this); … … 215 215 } 216 216 if (Main.main != null && Main.main.menu != null && Main.main.menu.windowMenu != null) { 217 if (windowMenuItem != null && !visible) {217 if (windowMenuItem != null && !visible) { 218 218 Main.main.menu.windowMenu.remove(windowMenuItem); 219 219 windowMenuItem = null; 220 220 } 221 if (windowMenuItem == null && visible) {221 if (windowMenuItem == null && visible) { 222 222 windowMenuItem = MainMenu.add(Main.main.menu.windowMenu, focusAction, MainMenu.WINDOW_MENU_GROUP.VOLATILE); 223 223 } … … 306 306 try { 307 307 content = reader.fetchHelpTopicContent(url, true); 308 } catch (MissingHelpContentException e) {308 } catch (MissingHelpContentException e) { 309 309 url = HelpUtil.getHelpTopicUrl(HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, LocaleType.BASELANGUAGE)); 310 310 try { 311 311 content = reader.fetchHelpTopicContent(url, true); 312 } catch (MissingHelpContentException e1) {312 } catch (MissingHelpContentException e1) { 313 313 url = HelpUtil.getHelpTopicUrl(HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, LocaleType.ENGLISH)); 314 314 try { 315 315 content = reader.fetchHelpTopicContent(url, true); 316 } catch (MissingHelpContentException e2) {316 } catch (MissingHelpContentException e2) { 317 317 this.url = url; 318 318 handleMissingHelpContent(relativeHelpTopic); 319 319 return; 320 } catch (HelpContentReaderException e2) {320 } catch (HelpContentReaderException e2) { 321 321 Main.error(e2); 322 322 handleHelpContentReaderException(relativeHelpTopic, e2); 323 323 return; 324 324 } 325 } catch (HelpContentReaderException e1) {325 } catch (HelpContentReaderException e1) { 326 326 Main.error(e1); 327 327 handleHelpContentReaderException(relativeHelpTopic, e1); 328 328 return; 329 329 } 330 } catch (HelpContentReaderException e) {330 } catch (HelpContentReaderException e) { 331 331 Main.error(e); 332 332 handleHelpContentReaderException(relativeHelpTopic, e); … … 349 349 try { 350 350 content = reader.fetchHelpTopicContent(url, true); 351 } catch (MissingHelpContentException e) {351 } catch (MissingHelpContentException e) { 352 352 this.url = url; 353 353 handleMissingHelpContent(absoluteHelpTopic); 354 354 return; 355 } catch (HelpContentReaderException e) {355 } catch (HelpContentReaderException e) { 356 356 Main.error(e); 357 357 handleHelpContentReaderException(absoluteHelpTopic, e); … … 386 386 history.setCurrentUrl(url); 387 387 this.url = url; 388 } catch (Exception e) {388 } catch (Exception e) { 389 389 Main.warn(e); 390 390 HelpAwareOptionPane.showOptionDialog( … … 439 439 440 440 class EditAction extends AbstractAction { 441 /** 442 * Constructs a new {@code EditAction}. 443 */ 441 444 public EditAction() { 442 445 putValue(SHORT_DESCRIPTION, tr("Edit the current help page")); 443 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));446 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); 444 447 } 445 448 … … 447 450 public void actionPerformed(ActionEvent e) { 448 451 String url = getUrl(); 449 if (url == null)452 if (url == null) 450 453 return; 451 454 if (!url.startsWith(HelpUtil.getWikiBaseHelpUrl())) { … … 484 487 static class BackAction extends AbstractAction implements Observer { 485 488 private transient HelpBrowserHistory history; 489 486 490 public BackAction(HelpBrowserHistory history) { 487 491 this.history = history; … … 496 500 history.back(); 497 501 } 502 498 503 @Override 499 504 public void update(Observable o, Object arg) { … … 504 509 static class ForwardAction extends AbstractAction implements Observer { 505 510 private transient HelpBrowserHistory history; 511 506 512 public ForwardAction(HelpBrowserHistory history) { 507 513 this.history = history; … … 516 522 history.forward(); 517 523 } 524 518 525 @Override 519 526 public void update(Observable o, Object arg) { … … 523 530 524 531 class HomeAction extends AbstractAction { 532 /** 533 * Constructs a new {@code HomeAction}. 534 */ 525 535 public HomeAction() { 526 536 putValue(SHORT_DESCRIPTION, tr("Go to the JOSM help home page")); … … 578 588 Object value = set.getAttribute(Tag.A); 579 589 if (!(value instanceof SimpleAttributeSet)) return null; 580 SimpleAttributeSet atts = (SimpleAttributeSet) value;590 SimpleAttributeSet atts = (SimpleAttributeSet) value; 581 591 value = atts.getAttribute(javax.swing.text.html.HTML.Attribute.HREF); 582 592 if (value == null) return null; 583 String s = (String) value;593 String s = (String) value; 584 594 if (s.matches("#.*")) 585 595 return s.substring(1); … … 592 602 return; 593 603 if (e.getURL() == null || e.getURL().toString().startsWith(url+"#")) { 594 // Probably hyperlink event on a an A-element with a href consisting of 595 // a fragment only, i.e. "#ALocalFragment". 596 // 604 // Probably hyperlink event on a an A-element with a href consisting of a fragment only, i.e. "#ALocalFragment". 597 605 String fragment = getUrlFragment(e); 598 606 if (fragment != null) {
Note:
See TracChangeset
for help on using the changeset viewer.