Mercurial > hg > release > thermostat-1.6
changeset 1742:d7a88a478235
Add a link to the user guide in the help menu
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2015-September/015716.html
PR2604
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Thu Jun 25 15:46:42 2015 -0400 @@ -63,6 +63,7 @@ MENU_VIEW, MENU_VIEW_AGENTS, MENU_HELP, + MENU_HELP_USER_GUIDE, MENU_HELP_ABOUT, SECONDS,
--- a/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Thu Mar 26 15:50:57 2015 +0100 +++ b/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Thu Jun 25 15:46:42 2015 -0400 @@ -21,6 +21,7 @@ MENU_VIEW = View MENU_VIEW_AGENTS = View All Agents... MENU_HELP = Help +MENU_HELP_USER_GUIDE = User Guide MENU_HELP_ABOUT = About SECONDS = Seconds
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Thu Jun 25 15:46:42 2015 -0400 @@ -55,6 +55,7 @@ HIDDEN, SHOW_AGENT_CONFIG, SHOW_CLIENT_CONFIG, + SHOW_USER_GUIDE, SHOW_ABOUT_DIALOG, SHUTDOWN, }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindow.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindow.java Thu Jun 25 15:46:42 2015 -0400 @@ -40,6 +40,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.InputEvent; @@ -264,6 +265,16 @@ helpMenu.getPopupMenu().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); mainMenuBar.add(helpMenu); + JMenuItem helpUserGuideMenu = new JMenuItem(translator.localize(LocaleResources.MENU_HELP_USER_GUIDE).getContents()); + helpUserGuideMenu.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fireViewAction(Action.SHOW_USER_GUIDE); + } + }); + helpUserGuideMenu.setName("showUserGuide"); + helpMenu.add(helpUserGuideMenu); + JMenuItem helpAboutMenu = new JMenuItem(translator.localize(LocaleResources.MENU_HELP_ABOUT).getContents()); helpAboutMenu.addActionListener(new java.awt.event.ActionListener() { @Override
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Thu Jun 25 15:46:42 2015 -0400 @@ -36,6 +36,10 @@ package com.redhat.thermostat.client.swing.internal; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; import java.util.Map; import java.util.Objects; @@ -125,7 +129,9 @@ private InformationServiceTracker infoServiceTracker; private ContextActionServiceTracker contextActionTracker; private MultipleServiceTracker depTracker; - + + private UriOpener uriOpener; + private CountDownLatch shutdown; private CountDownLatch initViewLatch = new CountDownLatch(1); @@ -180,13 +186,14 @@ public MainWindowControllerImpl(BundleContext context, ApplicationService appSvc, CountDownLatch shutdown) { - this(context, appSvc, new MainWindow(), new RegistryFactory(context), shutdown); + this(context, appSvc, new MainWindow(), new RegistryFactory(context), shutdown, new UriOpener()); } MainWindowControllerImpl(final BundleContext context, ApplicationService appSvc, final MainView view, RegistryFactory registryFactory, - final CountDownLatch shutdown) + final CountDownLatch shutdown, + final UriOpener uriOpener) { this.appSvc = appSvc; this.view = view; @@ -211,6 +218,8 @@ this.shutdown = shutdown; + this.uriOpener = uriOpener; + Class<?>[] deps = new Class<?>[] { Keyring.class, CommonPaths.class, @@ -342,6 +351,9 @@ case SHOW_CLIENT_CONFIG: showConfigureClientPreferences(); break; + case SHOW_USER_GUIDE: + showUserGuide(); + break; case SHOW_ABOUT_DIALOG: showAboutDialog(); break; @@ -431,6 +443,16 @@ view.showMainWindow(); } + private void showUserGuide() { + try { + uriOpener.open(new URI(new ApplicationInfo().getUserGuide())); + } catch (IOException e) { + logger.warning("Unable to show URL"); + } catch (URISyntaxException e) { + throw new AssertionError("User Guide URL has syntax errors"); + } + } + private void showAboutDialog() { AboutDialog aboutDialog = new AboutDialog(appInfo); aboutDialog.setModal(true); @@ -513,5 +535,10 @@ return new VmInformationController(vmInfoServices, ref, vmInfoViewProvider); } + static class UriOpener { + public void open(URI uri) throws IOException { + Desktop.getDesktop().browse(uri); + } + } }
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Thu Jun 25 15:46:42 2015 -0400 @@ -38,11 +38,13 @@ import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import java.util.concurrent.CountDownLatch; import org.fest.swing.edt.FailOnThreadViolationRepaintManager; @@ -62,12 +64,12 @@ import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; import com.redhat.thermostat.client.core.views.VmInformationView; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; +import com.redhat.thermostat.client.swing.internal.MainWindowControllerImpl.UriOpener; import com.redhat.thermostat.client.swing.internal.registry.decorator.DecoratorRegistryController; import com.redhat.thermostat.client.swing.internal.vmlist.controller.ContextActionController; import com.redhat.thermostat.client.swing.internal.vmlist.controller.HostTreeController; import com.redhat.thermostat.client.ui.MenuAction; import com.redhat.thermostat.client.ui.MenuRegistry; -import com.redhat.thermostat.client.ui.ReferenceContextAction; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationService; @@ -96,6 +98,8 @@ private Timer mainWindowTimer; + private UriOpener uriOpener; + private HostInfoDAO mockHostsDAO; private VmInfoDAO mockVmsDAO; @@ -125,6 +129,8 @@ @Before public void setUp() throws Exception { context = new StubBundleContext(); + + uriOpener = mock(UriOpener.class); // Setup timers mainWindowTimer = mock(Timer.class); @@ -211,7 +217,7 @@ ArgumentCaptor<ActionListener> grabInfoRegistry = ArgumentCaptor.forClass(ActionListener.class); doNothing().when(vmInfoRegistry).addActionListener(grabInfoRegistry.capture()); - controller = new MainWindowControllerImpl(context, appSvc, view, registryFactory, shutdown); + controller = new MainWindowControllerImpl(context, appSvc, view, registryFactory, shutdown, uriOpener); l = grabListener.getValue(); } @@ -235,13 +241,20 @@ verify(decoratorController, times(1)).start(); verify(decoratorController, times(1)).stop(); } - + @Test public void verifyShowMainWindowActuallyCallsView() { controller.showMainMainWindow(); verify(view).showMainWindow(); } + @Test + public void verifyShowUserGuideEvent() throws Exception { + l.actionPerformed(new ActionEvent<MainView.Action>(view, MainView.Action.SHOW_USER_GUIDE)); + + verify(uriOpener).open(isA(URI.class)); + } + // @Test // @Bug(id="954", // summary="Thermostat GUI client should remember my last panel selected",
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowTest.java Thu Mar 26 15:50:57 2015 +0100 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowTest.java Thu Jun 25 15:46:42 2015 -0400 @@ -169,6 +169,18 @@ @Category(GUITest.class) @Test + public void verifyUserGuideMenuItemTriggersEvent() { + frameFixture.show(); + JMenuItemFixture menuItem = frameFixture.menuItem("showUserGuide"); + menuItem.click(); + frameFixture.close(); + frameFixture.requireNotVisible(); + + verify(l).actionPerformed(new ActionEvent<MainView.Action>(window, MainView.Action.SHOW_USER_GUIDE)); + } + + @Category(GUITest.class) + @Test public void addRemoveMenu() { final LocalizedString PARENT_NAME = new LocalizedString("File"); final LocalizedString MENU_NAME = new LocalizedString("Test2");
--- a/common/core/src/main/java/com/redhat/thermostat/common/ApplicationInfo.java Thu Mar 26 15:50:57 2015 +0100 +++ b/common/core/src/main/java/com/redhat/thermostat/common/ApplicationInfo.java Thu Jun 25 15:46:42 2015 -0400 @@ -107,6 +107,10 @@ return appInfo.getProperty("APP_WEBSITE", MISSING_INFO); } + public String getUserGuide() { + return appInfo.getProperty("APP_USER_GUIDE", MISSING_INFO); + } + public String getBugReportsAddress() { return appInfo.getProperty("BUG_WEBSITE", MISSING_INFO); }
--- a/common/core/src/main/resources/com/redhat/thermostat/app-info.properties Thu Mar 26 15:50:57 2015 +0100 +++ b/common/core/src/main/resources/com/redhat/thermostat/app-info.properties Thu Jun 25 15:46:42 2015 -0400 @@ -4,5 +4,6 @@ APP_WEBSITE = ${thermostat.url} APP_COPYRIGHT = Copyright 2012-2014 Red Hat, Inc. APP_VERSION = ${project.version} +APP_USER_GUIDE = ${thermostat.user.guide} BUG_WEBSITE = ${thermostat.bug.url}
--- a/common/core/src/test/java/com/redhat/thermostat/common/ApplicationInfoTest.java Thu Mar 26 15:50:57 2015 +0100 +++ b/common/core/src/test/java/com/redhat/thermostat/common/ApplicationInfoTest.java Thu Jun 25 15:46:42 2015 -0400 @@ -36,14 +36,17 @@ package com.redhat.thermostat.common; -import com.redhat.thermostat.common.locale.LocaleResources; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.net.URI; import java.util.Locale; + import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import com.redhat.thermostat.common.locale.LocaleResources; public class ApplicationInfoTest { @@ -62,9 +65,27 @@ } @Test + public void testEmail() { + ApplicationInfo appInfo = new ApplicationInfo(); + assertEquals("thermostat@icedtea.classpath.org", appInfo.getEmail()); + } + + @Test + public void testWebsite() { + ApplicationInfo appInfo = new ApplicationInfo(); + assertEquals("http://icedtea.classpath.org/thermostat/", appInfo.getWebsite()); + } + + @Test + public void testUserGuideIsValidURI() throws Exception { + ApplicationInfo appInfo = new ApplicationInfo(); + new URI(appInfo.getUserGuide()); + } + + @Test public void testGetBugReportsAddress() { ApplicationInfo appInfo = new ApplicationInfo(); - assertEquals(appInfo.getBugReportsAddress(), "http://icedtea.classpath.org/bugzilla/enter_bug.cgi?product=Thermostat"); + assertEquals("http://icedtea.classpath.org/bugzilla/enter_bug.cgi?product=Thermostat", appInfo.getBugReportsAddress()); } @After
--- a/pom.xml Thu Mar 26 15:50:57 2015 +0100 +++ b/pom.xml Thu Jun 25 15:46:42 2015 -0400 @@ -129,6 +129,7 @@ <thermostat.email>thermostat@icedtea.classpath.org</thermostat.email> <thermostat.url>http://icedtea.classpath.org/thermostat/</thermostat.url> <thermostat.bug.url>http://icedtea.classpath.org/bugzilla/enter_bug.cgi?product=Thermostat</thermostat.bug.url> + <thermostat.user.guide>http://icedtea.classpath.org/wiki/Thermostat/UserGuide</thermostat.user.guide> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <thermostat.build.directory>target</thermostat.build.directory>