# HG changeset patch # User Ed Swartz # Date 1262110409 21600 # Node ID 9d4cd10c2b357a5f3b2127982edf1ca81c4a2da5 # Parent d9cf6eb22de008cc4aacf55f9baaedf7a1b11975 Fix bug 10381 diff -r d9cf6eb22de0 -r 9d4cd10c2b35 core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java --- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java Tue Dec 29 11:44:45 2009 -0600 +++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java Tue Dec 29 12:13:29 2009 -0600 @@ -73,25 +73,26 @@ public final static String NEWS_PAGE_TITLE = "Carbide.c++ News Page"; public final static String NEWS_SUMMARY_TITLE = "All News"; private final static String ECLIPSE_NETWORK_PREFERENCES_ID = "org.eclipse.ui.net.NetPreferences"; - private final static String LINK_MARK_ALL_ENTRIES_READ = "about:removeAll"; - private final static String LINK_MARK_ENTRY_READ = "about:removeEntry"; - private final static String LINK_NEWS_PREFERENCES = "about:newsPreferences"; - private final static String LINK_NETWORK_PREFERENCES = "about:networkPreferences"; - private final static String LINK_SHOW_ALL_ENTRIES = "about:showAll"; - private final static String LINK_SHOW_UNREAD_ENTRIES = "about:showUnreadOnly"; - private final static String LINK_UPDATE_FEEDS = "about:updateFeeds"; + private final static String FAKE_URL_PREFIX = "http://localhost/news/"; + private final static String LINK_MARK_ALL_ENTRIES_READ = FAKE_URL_PREFIX + "removeAll"; + private final static String LINK_MARK_ENTRY_READ = FAKE_URL_PREFIX + "removeEntry"; + private final static String LINK_NEWS_PREFERENCES = FAKE_URL_PREFIX + "newsPreferences"; + private final static String LINK_NETWORK_PREFERENCES = FAKE_URL_PREFIX + "networkPreferences"; + private final static String LINK_SHOW_ALL_ENTRIES = FAKE_URL_PREFIX + "showAll"; + private final static String LINK_SHOW_UNREAD_ENTRIES = FAKE_URL_PREFIX + "showUnreadOnly"; + private final static String LINK_UPDATE_FEEDS = FAKE_URL_PREFIX + "updateFeeds"; private final static String DELIMETER = "::"; private final static String HTML_BODY_HEADER = ""; private final static String HTML_BODY_FOOTER = ""; private final static String HTML_CONTROLS_HEADER_START = "
"; private final static String HTML_CONTROLS_HEADER_END = "
"; private final static String HTML_CONTROLS_DIVIDER = " | "; - private final static String HTML_MARK_ALL_ENTRIES_READ_CONTROL = "Mark All Read"; - private final static String HTML_NEWS_PREFERENCES_CONTROL = "Preferences"; - private final static String HTML_NETWORK_PREFERENCES_CONTROL = "Network Connections Preferences"; - private final static String HTML_SHOW_ALL_ENTIES_CONTROL = "All Items"; - private final static String HTML_SHOW_UNREAD_ENTIES_CONTROL = "Unread Items Only"; - private final static String HTML_UPDATE_FEEDS_CONTROL = "Update"; + private final static String HTML_MARK_ALL_ENTRIES_READ_CONTROL = "Mark All Read"; + private final static String HTML_NEWS_PREFERENCES_CONTROL = "Preferences"; + private final static String HTML_NETWORK_PREFERENCES_CONTROL = "Network Connections Preferences"; + private final static String HTML_SHOW_ALL_ENTIES_CONTROL = "All Items"; + private final static String HTML_SHOW_UNREAD_ENTIES_CONTROL = "Unread Items Only"; + private final static String HTML_UPDATE_FEEDS_CONTROL = "Update"; private Pattern MarkEntryReadPattern = Pattern.compile("about:removeEntry::(.*)::(.*)"); private List newsFeeds; private int currentFeed; @@ -273,6 +274,8 @@ } catch (Exception e) { CarbideNewsReaderPlugin.log(e); } + + // note: the non-navigable links do not work on all hosts, hence the mouse listener newsBrowser.addLocationListener(new LocationListener() { public void changing(LocationEvent event) { handleChangingLocation(event); @@ -499,36 +502,40 @@ private void handleChangingLocation(LocationEvent event) { try { String targetLocation = event.location; - if (targetLocation.startsWith("http")) { + if (targetLocation.startsWith(FAKE_URL_PREFIX)) { event.doit = false; - URL url = new URL(event.location); - PlatformUI.getWorkbench().getBrowserSupport().createBrowser(null).openURL(url); - } - else if (targetLocation.startsWith(LINK_MARK_ALL_ENTRIES_READ)) { - handleMarkAllRead(); - } - else if (targetLocation.startsWith(LINK_MARK_ENTRY_READ)) { - Matcher matcher = MarkEntryReadPattern.matcher(targetLocation); - if (matcher.matches()) { - String feedTitle = matcher.group(1).replaceAll("%20", " "); - String entryTitle = matcher.group(2).replaceAll("%20", " "); - handleMarkEntryRead(feedTitle, entryTitle); + if (targetLocation.startsWith(LINK_MARK_ALL_ENTRIES_READ)) { + handleMarkAllRead(); + } + else if (targetLocation.startsWith(LINK_MARK_ENTRY_READ)) { + Matcher matcher = MarkEntryReadPattern.matcher(targetLocation); + if (matcher.matches()) { + String feedTitle = matcher.group(1).replaceAll("%20", " "); + String entryTitle = matcher.group(2).replaceAll("%20", " "); + handleMarkEntryRead(feedTitle, entryTitle); + } + } + else if (targetLocation.startsWith(LINK_NEWS_PREFERENCES)) { + handleOpenNewsPreferencePage(); } - } - else if (targetLocation.startsWith(LINK_NEWS_PREFERENCES)) { - handleOpenNewsPreferencePage(); - } - else if (targetLocation.startsWith(LINK_NETWORK_PREFERENCES)) { - handleOpenNetworkPreferencePage(); - } - else if (targetLocation.startsWith(LINK_SHOW_ALL_ENTRIES)) { - handleShowAll(); - } - else if (targetLocation.startsWith(LINK_SHOW_UNREAD_ENTRIES)) { - handleShowUnreadOnly(); - } - else if (targetLocation.startsWith(LINK_UPDATE_FEEDS)) { - handleUpdateFeeds(); + else if (targetLocation.startsWith(LINK_NETWORK_PREFERENCES)) { + handleOpenNetworkPreferencePage(); + } + else if (targetLocation.startsWith(LINK_SHOW_ALL_ENTRIES)) { + handleShowAll(); + } + else if (targetLocation.startsWith(LINK_SHOW_UNREAD_ENTRIES)) { + handleShowUnreadOnly(); + } + else if (targetLocation.startsWith(LINK_UPDATE_FEEDS)) { + handleUpdateFeeds(); + } + } else { + if (targetLocation.startsWith("http")) { + event.doit = false; + URL url = new URL(event.location); + PlatformUI.getWorkbench().getBrowserSupport().createBrowser(null).openURL(url); + } } } catch (Exception e) { CarbideNewsReaderPlugin.log(e);