Mercurial > hg > release > thermostat-1.0
changeset 1356:b917318b72ce
Show version information on startup
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-November/008866.html
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/views/SummaryView.java Fri Nov 22 12:50:26 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core.views; - -/** - * A {@link View} that displays a summary of everything in thermostat. - */ -public abstract class SummaryView extends BasicView implements UIComponent { - - public abstract void setTotalHosts(String count); - - public abstract void setTotalVms(String count); - -} -
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/views/SummaryViewProvider.java Fri Nov 22 12:50:26 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core.views; - -public interface SummaryViewProvider extends ViewProvider { - - @Override - public SummaryView createView(); - -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/views/VersionAndInfoView.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,48 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.core.views; + +import com.redhat.thermostat.common.ApplicationInfo; + +/** + * A {@link View} that displays a summary of everything in thermostat. + */ +public abstract class VersionAndInfoView extends BasicView implements UIComponent { + + public abstract void initialize(ApplicationInfo appInfo); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/views/VersionAndInfoViewProvider.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,45 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.core.views; + +public interface VersionAndInfoViewProvider extends ViewProvider { + + @Override + public VersionAndInfoView createView(); + +} +
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java Fri Nov 22 12:50:26 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.ui; - -import java.util.concurrent.TimeUnit; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.client.core.views.SummaryView; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; -import com.redhat.thermostat.client.core.views.BasicView.Action; -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.storage.dao.HostInfoDAO; -import com.redhat.thermostat.storage.dao.VmInfoDAO; - -public class SummaryController { - - private final HostInfoDAO hostsDAO; - private final VmInfoDAO vmsDAO; - - private final SummaryView view; - - private final Timer backgroundUpdateTimer; - - public SummaryController(ApplicationService appSvc, HostInfoDAO hostInfoDao, VmInfoDAO vmInfoDao, SummaryViewProvider viewProvider) { - - this.view = viewProvider.createView(); - - view.addActionListener(new ActionListener<Action>() { - @Override - public void actionPerformed(ActionEvent<Action> actionEvent) { - switch (actionEvent.getActionId()) { - case HIDDEN: - stop(); - break; - case VISIBLE: - start(); - break; - default: - break; - } - } - }); - - hostsDAO = hostInfoDao; - vmsDAO = vmInfoDao; - - backgroundUpdateTimer = appSvc.getTimerFactory().createTimer(); - backgroundUpdateTimer.setAction(new Runnable() { - @Override - public void run() { - view.setTotalVms(String.valueOf(vmsDAO.getCount())); - view.setTotalHosts(String.valueOf(hostsDAO.getCount())); - } - }); - backgroundUpdateTimer.setInitialDelay(0); - backgroundUpdateTimer.setDelay(10); - backgroundUpdateTimer.setTimeUnit(TimeUnit.SECONDS); - backgroundUpdateTimer.setSchedulingType(SchedulingType.FIXED_RATE); - } - - private void start() { - backgroundUpdateTimer.start(); - } - - private void stop() { - backgroundUpdateTimer.stop(); - } - - public BasicView getView() { - return view; - } - -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/VersionAndInfoController.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,61 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.ui; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.core.views.VersionAndInfoView; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; +import com.redhat.thermostat.common.ApplicationInfo; + +public class VersionAndInfoController { + + + private final VersionAndInfoView view; + + public VersionAndInfoController(ApplicationInfo appInfo, VersionAndInfoViewProvider viewProvider) { + + this.view = viewProvider.createView(); + view.initialize(appInfo); + + } + + public BasicView getView() { + return view; + } + +} +
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java Fri Nov 22 12:50:26 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.ui; - -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isNotNull; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import com.redhat.thermostat.client.core.views.SummaryView; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.storage.dao.HostInfoDAO; -import com.redhat.thermostat.storage.dao.VmInfoDAO; - -public class SummaryControllerTest { - - private Timer timer; - private Runnable timerAction; - private SummaryView view; - private ActionListener<SummaryView.Action> viewListener; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Before - public void setUp() { - - // Setup timer - timer = mock(Timer.class); - TimerFactory timerFactory = mock(TimerFactory.class); - when(timerFactory.createTimer()).thenReturn(timer); - ArgumentCaptor<Runnable> actionCaptor = ArgumentCaptor.forClass(Runnable.class); - doNothing().when(timer).setAction(actionCaptor.capture()); - ApplicationService appSvc = mock(ApplicationService.class); - when(appSvc.getTimerFactory()).thenReturn(timerFactory); - - // setup dao - HostInfoDAO hDAO = mock(HostInfoDAO.class); - when(hDAO.getCount()).thenReturn(99l); - VmInfoDAO vDAO = mock(VmInfoDAO.class); - when(vDAO.getCount()).thenReturn(42l); - - // Setup view - view = mock(SummaryView.class); - ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); - doNothing().when(view).addActionListener(viewArgumentCaptor.capture()); - - SummaryViewProvider viewProvider = mock(SummaryViewProvider.class); - when(viewProvider.createView()).thenReturn(view); - - @SuppressWarnings("unused") - SummaryController summaryCtrl = new SummaryController(appSvc, hDAO, vDAO, viewProvider); - - timerAction = actionCaptor.getValue(); - viewListener = viewArgumentCaptor.getValue(); - } - - @After - public void tearDown() { - timer = null; - timerAction = null; - view = null; - viewListener = null; - } - - @Test - public void verifyTimerAction() { - verify(timer).setAction(isNotNull(Runnable.class)); - verify(timer).setDelay(10); - verify(timer).setTimeUnit(TimeUnit.SECONDS); - verify(timer).setInitialDelay(0); - verify(timer).setSchedulingType(SchedulingType.FIXED_RATE); - } - - @Test - public void testTimer() { - viewListener.actionPerformed(new ActionEvent<SummaryView.Action>(view, SummaryView.Action.VISIBLE)); - - verify(timer).start(); - - timerAction.run(); - verify(view).setTotalHosts(eq("99")); - verify(view).setTotalVms(eq("42")); - - viewListener.actionPerformed(new ActionEvent<SummaryView.Action>(view, SummaryView.Action.HIDDEN)); - - verify(timer).stop(); - } - -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/VersionAndInfoTest.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,66 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.ui; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Test; + +import com.redhat.thermostat.client.core.views.VersionAndInfoView; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; +import com.redhat.thermostat.common.ApplicationInfo; + +public class VersionAndInfoTest { + + @Test + public void testViewIsInitialized() { + ApplicationInfo appInfo = mock(ApplicationInfo.class); + + VersionAndInfoView view = mock(VersionAndInfoView.class); + + VersionAndInfoViewProvider viewProvider = mock(VersionAndInfoViewProvider.class); + when(viewProvider.createView()).thenReturn(view); + + new VersionAndInfoController(appInfo, viewProvider); + + verify(view).initialize(appInfo); + } + +} +
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/AboutDialog.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/AboutDialog.java Fri Nov 22 13:08:52 2013 -0500 @@ -36,31 +36,18 @@ package com.redhat.thermostat.client.swing.internal; -import java.awt.Cursor; -import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.net.URI; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; -import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JDialog; -import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.SwingConstants; -import javax.swing.SwingWorker; import javax.swing.border.TitledBorder; import com.redhat.thermostat.client.locale.LocaleResources; import com.redhat.thermostat.common.ApplicationInfo; -import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.shared.locale.Translate; public class AboutDialog extends JDialog { @@ -68,42 +55,21 @@ private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); private static final long serialVersionUID = -7611616871710076514L; - private static final Logger logger = LoggingUtils.getLogger(AboutDialog.class); - - private String description; - private String version; - private Icon icon; - private String copyright; - private String license; - private String website; - private String email; - /** * Create the dialog. * @param applicationInfo */ public AboutDialog(ApplicationInfo appInfo) { - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setResizable(false); - description = appInfo.getDescription(); - version = appInfo.getVersion().getVersionNumber(); - copyright = appInfo.getCopyright(); - license = appInfo.getLicenseSummary(); - website = appInfo.getWebsite(); - email = appInfo.getEmail(); - - initComponents(); + initComponents(appInfo); } - private void initComponents() { + private void initComponents(ApplicationInfo appInfo) { setBounds(100, 100, 450, 338); - - UIResources res = UIResources.getInstance(); - icon = new com.redhat.thermostat.client.swing.components.Icon(res.getLogo()); - - JPanel panel = new JPanel(); + + JPanel panel = new AboutPanel(appInfo); panel.setBorder(new TitledBorder("")); JButton closeButton = new JButton(translator.localize(LocaleResources.BUTTON_CLOSE).getContents()); @@ -133,146 +99,10 @@ .addComponent(closeButton) .addGap(9)) ); - - JLabel iconLabel = new JLabel(""); - iconLabel.setHorizontalAlignment(SwingConstants.CENTER); - - iconLabel.setIcon(icon); - - JLabel versionLabel = new JLabel(version); - versionLabel.setFont(res.footerFont()); - versionLabel.setHorizontalAlignment(SwingConstants.CENTER); - - JLabel descriptionLabel = new JLabel(description); - descriptionLabel.setHorizontalAlignment(SwingConstants.CENTER); - descriptionLabel.setFont(res.standardFont()); - - JLabel homePageLabel = new JLabel(website); - homePageLabel.setForeground(res.hyperlinkColor()); - homePageLabel.setHorizontalAlignment(SwingConstants.CENTER); - homePageLabel.setFont(res.footerFont()); - homePageLabel.addMouseListener(new Browse(homePageLabel)); - - JLabel copyrightLabel = new JLabel(copyright); - copyrightLabel.setHorizontalAlignment(SwingConstants.CENTER); - copyrightLabel.setFont(res.footerFont()); - - JLabel licenseString = new JLabel(license); - licenseString.setHorizontalAlignment(SwingConstants.CENTER); - licenseString.setFont(res.footerFont()); - - JLabel emailLabel = new JLabel(email); - emailLabel.setHorizontalAlignment(SwingConstants.CENTER); - emailLabel.setForeground(res.hyperlinkColor()); - emailLabel.setFont(res.footerFont()); - emailLabel.addMouseListener(new Mailer(emailLabel)); - - GroupLayout gl_panel = new GroupLayout(panel); - gl_panel.setHorizontalGroup( - gl_panel.createParallelGroup(Alignment.TRAILING) - .addGroup(gl_panel.createSequentialGroup() - .addContainerGap() - .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) - .addComponent(iconLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(versionLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(descriptionLabel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(copyrightLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(licenseString, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(emailLabel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) - .addComponent(homePageLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)) - .addContainerGap()) - ); - gl_panel.setVerticalGroup( - gl_panel.createParallelGroup(Alignment.LEADING) - .addGroup(gl_panel.createSequentialGroup() - .addContainerGap() - .addComponent(iconLabel) - .addGap(4) - .addComponent(versionLabel, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(descriptionLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(12) - .addComponent(homePageLabel, GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) - .addGap(3) - .addComponent(emailLabel, GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(copyrightLabel, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(licenseString, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) - .addContainerGap()) - ); - panel.setLayout(gl_panel); getContentPane().setLayout(groupLayout); } - private abstract class HyperLinkAction extends MouseAdapter { - - private JLabel hyperLinkLabel; - public HyperLinkAction(JLabel hyperLinkLabel) { - this.hyperLinkLabel = hyperLinkLabel; - } - - @Override - public void mouseEntered(MouseEvent e) { - hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkActiveColor()); - Cursor cursor = new Cursor(Cursor.HAND_CURSOR); - setCursor(cursor); - } - @Override - public void mouseExited(MouseEvent e) { - hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkColor()); - Cursor cursor = new Cursor(Cursor.DEFAULT_CURSOR); - setCursor(cursor); - } - - @Override - public void mouseClicked(MouseEvent e) { - if (Desktop.isDesktopSupported()) { - new SwingWorker<Void, Void>() { - @Override - protected Void doInBackground() throws Exception { - doAction(); - return null; - } - @Override - protected void done() { - hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkColor()); - } - }.execute(); - } - } - - protected abstract void doAction(); - } - private class Mailer extends HyperLinkAction { - public Mailer(JLabel hyperLinkLabel) { - super(hyperLinkLabel); - } - @Override - protected void doAction() { - try { - Desktop.getDesktop().mail(new URI("mailto:" + email)); - } catch (Exception ex) { - logger.log(Level.WARNING, "Cannot send mail to Thermosat mail", ex); - } - } - } - - private class Browse extends HyperLinkAction { - public Browse(JLabel hyperLinkLabel) { - super(hyperLinkLabel); - } - - @Override - protected void doAction() { - try { - Desktop.getDesktop().browse(new URI(website)); - } catch (Exception ex) { - logger.log(Level.WARNING, "Cannot open Thermostat website URL", ex); - } - } - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/AboutPanel.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,224 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.swing.internal; + +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URI; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.GroupLayout; +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.SwingWorker; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; + +import com.redhat.thermostat.common.ApplicationInfo; +import com.redhat.thermostat.common.utils.LoggingUtils; + +public class AboutPanel extends JPanel { + + private static final Logger logger = LoggingUtils.getLogger(AboutPanel.class); + + private String description; + private String version; + private Icon icon; + private String copyright; + private String license; + private String website; + private String email; + + + public AboutPanel(ApplicationInfo appInfo) { + description = appInfo.getDescription(); + version = appInfo.getVersion().getVersionNumber(); + copyright = appInfo.getCopyright(); + license = appInfo.getLicenseSummary(); + website = appInfo.getWebsite(); + email = appInfo.getEmail(); + + UIResources res = UIResources.getInstance(); + icon = new com.redhat.thermostat.client.swing.components.Icon(res.getLogo()); + + JLabel iconLabel = new JLabel(""); + iconLabel.setHorizontalAlignment(SwingConstants.CENTER); + + iconLabel.setIcon(icon); + + JLabel versionLabel = new JLabel(version); + versionLabel.setFont(res.footerFont()); + versionLabel.setHorizontalAlignment(SwingConstants.CENTER); + + JLabel descriptionLabel = new JLabel(description); + descriptionLabel.setHorizontalAlignment(SwingConstants.CENTER); + descriptionLabel.setFont(res.standardFont()); + + JLabel homePageLabel = new JLabel(website); + homePageLabel.setForeground(res.hyperlinkColor()); + homePageLabel.setHorizontalAlignment(SwingConstants.CENTER); + homePageLabel.setFont(res.footerFont()); + homePageLabel.addMouseListener(new Browse(homePageLabel)); + + JLabel copyrightLabel = new JLabel(copyright); + copyrightLabel.setHorizontalAlignment(SwingConstants.CENTER); + copyrightLabel.setFont(res.footerFont()); + + JLabel licenseString = new JLabel(license); + licenseString.setHorizontalAlignment(SwingConstants.CENTER); + licenseString.setFont(res.footerFont()); + + JLabel emailLabel = new JLabel(email); + emailLabel.setHorizontalAlignment(SwingConstants.CENTER); + emailLabel.setForeground(res.hyperlinkColor()); + emailLabel.setFont(res.footerFont()); + emailLabel.addMouseListener(new Mailer(emailLabel)); + + GroupLayout gl_panel = new GroupLayout(this); + gl_panel.setHorizontalGroup( + gl_panel.createParallelGroup(Alignment.TRAILING) + .addGroup(gl_panel.createSequentialGroup() + .addContainerGap() + .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) + .addComponent(iconLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(versionLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(descriptionLabel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(copyrightLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(licenseString, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(emailLabel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .addComponent(homePageLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)) + .addContainerGap()) + ); + gl_panel.setVerticalGroup( + gl_panel.createParallelGroup(Alignment.LEADING) + .addGroup(gl_panel.createSequentialGroup() + .addContainerGap() + .addComponent(iconLabel) + .addGap(4) + .addComponent(versionLabel, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addComponent(descriptionLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(12) + .addComponent(homePageLabel, GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) + .addGap(3) + .addComponent(emailLabel, GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(copyrightLabel, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(licenseString, GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE) + .addContainerGap()) + ); + this.setLayout(gl_panel); + + } + + + private abstract class HyperLinkAction extends MouseAdapter { + + private JLabel hyperLinkLabel; + public HyperLinkAction(JLabel hyperLinkLabel) { + this.hyperLinkLabel = hyperLinkLabel; + } + + @Override + public void mouseEntered(MouseEvent e) { + hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkActiveColor()); + Cursor cursor = new Cursor(Cursor.HAND_CURSOR); + setCursor(cursor); + } + @Override + public void mouseExited(MouseEvent e) { + hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkColor()); + Cursor cursor = new Cursor(Cursor.DEFAULT_CURSOR); + setCursor(cursor); + } + + @Override + public void mouseClicked(MouseEvent e) { + if (Desktop.isDesktopSupported()) { + new SwingWorker<Void, Void>() { + @Override + protected Void doInBackground() throws Exception { + doAction(); + return null; + } + @Override + protected void done() { + hyperLinkLabel.setForeground(UIResources.getInstance().hyperlinkColor()); + } + }.execute(); + } + } + + protected abstract void doAction(); + } + + private class Mailer extends HyperLinkAction { + public Mailer(JLabel hyperLinkLabel) { + super(hyperLinkLabel); + } + + @Override + protected void doAction() { + try { + Desktop.getDesktop().mail(new URI("mailto:" + email)); + } catch (Exception ex) { + logger.log(Level.WARNING, "Cannot send mail to Thermosat mail", ex); + } + } + } + + private class Browse extends HyperLinkAction { + public Browse(JLabel hyperLinkLabel) { + super(hyperLinkLabel); + } + + @Override + protected void doAction() { + try { + Desktop.getDesktop().browse(new URI(website)); + } catch (Exception ex) { + logger.log(Level.WARNING, "Cannot open Thermostat website URL", ex); + } + } + } +}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Fri Nov 22 13:08:52 2013 -0500 @@ -54,7 +54,7 @@ import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.ClientConfigurationView; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.client.swing.internal.osgi.ContextActionServiceTracker; import com.redhat.thermostat.client.swing.internal.osgi.InformationServiceTracker; @@ -72,7 +72,7 @@ import com.redhat.thermostat.client.ui.MainWindowController; import com.redhat.thermostat.client.ui.MenuAction; import com.redhat.thermostat.client.ui.MenuRegistry; -import com.redhat.thermostat.client.ui.SummaryController; +import com.redhat.thermostat.client.ui.VersionAndInfoController; import com.redhat.thermostat.client.ui.VmInformationController; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; @@ -115,7 +115,7 @@ private AgentInfoDAO agentInfoDAO; private BackendInfoDAO backendInfoDAO; - private SummaryViewProvider summaryViewProvider; + private VersionAndInfoViewProvider summaryViewProvider; private HostInformationViewProvider hostInfoViewProvider; private VmInformationViewProvider vmInfoViewProvider; private AgentInformationViewProvider agentInfoViewProvider; @@ -217,7 +217,7 @@ VmInfoDAO.class, AgentInfoDAO.class, BackendInfoDAO.class, - SummaryViewProvider.class, + VersionAndInfoViewProvider.class, HostInformationViewProvider.class, VmInformationViewProvider.class, AgentInformationViewProvider.class, @@ -241,7 +241,7 @@ Objects.requireNonNull(agentInfoDAO); backendInfoDAO = (BackendInfoDAO) services.get(BackendInfoDAO.class.getName()); Objects.requireNonNull(backendInfoDAO); - summaryViewProvider = (SummaryViewProvider) services.get(SummaryViewProvider.class.getName()); + summaryViewProvider = (VersionAndInfoViewProvider) services.get(VersionAndInfoViewProvider.class.getName()); Objects.requireNonNull(summaryViewProvider); hostInfoViewProvider = (HostInformationViewProvider) services.get(HostInformationViewProvider.class.getName()); Objects.requireNonNull(hostInfoViewProvider); @@ -355,6 +355,9 @@ } }); + + updateView(null); + initViewLatch.countDown(); } @@ -451,7 +454,7 @@ private void updateView(Ref ref) { if (ref == null) { - SummaryController controller = createSummaryController(); + VersionAndInfoController controller = createSummaryController(); view.setSubView(controller.getView()); } else if (ref instanceof HostRef) { HostRef hostRef = (HostRef) ref; @@ -494,8 +497,8 @@ } } - private SummaryController createSummaryController() { - return new SummaryController(appSvc, hostInfoDAO, vmInfoDAO, summaryViewProvider); + private VersionAndInfoController createSummaryController() { + return new VersionAndInfoController(appInfo, summaryViewProvider); } private HostInformationController createHostInformationController(HostRef ref) {
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Fri Nov 22 13:08:52 2013 -0500 @@ -44,7 +44,7 @@ import com.redhat.thermostat.client.core.views.AgentInformationViewProvider; import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.client.swing.internal.GUIClientCommand; @@ -81,8 +81,8 @@ context.registerService(VmInformationViewProvider.class.getName(), vmInfoProvider, null); // Summary view - SummaryViewProvider summaryViewProvider = new SwingSummaryViewProvider(); - context.registerService(SummaryViewProvider.class.getName(), summaryViewProvider, null); + VersionAndInfoViewProvider summaryViewProvider = new SwingSummaryViewProvider(); + context.registerService(VersionAndInfoViewProvider.class.getName(), summaryViewProvider, null); // AgentInformation and ClientConfiguraiton view AgentInformationViewProvider agentViewProvider = new SwingAgentInformationViewProvider();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/views/SummaryPanel.java Fri Nov 22 12:50:26 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.swing.internal.views; - -import java.awt.Component; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.GroupLayout; -import javax.swing.GroupLayout.Alignment; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.ListModel; -import javax.swing.SwingUtilities; -import javax.swing.text.JTextComponent; - -import com.redhat.thermostat.client.core.views.SummaryView; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.swing.ComponentVisibleListener; -import com.redhat.thermostat.client.swing.SwingComponent; -import com.redhat.thermostat.client.swing.components.SectionHeader; -import com.redhat.thermostat.client.swing.components.ValueField; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.shared.locale.Translate; - -public class SummaryPanel extends SummaryView implements SwingComponent { - - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - - private JPanel visiblePanel; - - private final JTextComponent totalMonitoredHosts; - private final JTextComponent totalMonitoredVms; - - private final List<String> issuesList; - - public SummaryPanel() { - super(); - visiblePanel = new JPanel(); - JLabel lblHomepanel = new SectionHeader(translator.localize(LocaleResources.HOME_PANEL_SECTION_SUMMARY)); - - JLabel lblTotalHosts = new JLabel(translator.localize(LocaleResources.HOME_PANEL_TOTAL_MACHINES).getContents()); - - totalMonitoredHosts = new ValueField(""); - - JLabel lblTotal = new JLabel(translator.localize(LocaleResources.HOME_PANEL_TOTAL_JVMS).getContents()); - - totalMonitoredVms = new ValueField(""); - - JLabel lblIssues = new SectionHeader(translator.localize(LocaleResources.HOME_PANEL_SECTION_ISSUES)); - - JScrollPane scrollPane = new JScrollPane(); - - GroupLayout groupLayout = new GroupLayout(visiblePanel); - groupLayout.setHorizontalGroup( - groupLayout.createParallelGroup(Alignment.TRAILING) - .addGroup(groupLayout.createSequentialGroup() - .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) - .addGroup(groupLayout.createSequentialGroup() - .addContainerGap() - .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) - .addComponent(lblHomepanel) - .addGroup(groupLayout.createSequentialGroup() - .addGap(12) - .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) - .addComponent(lblTotal) - .addComponent(lblTotalHosts)) - .addGap(18) - .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) - .addComponent(totalMonitoredVms, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(totalMonitoredHosts, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addComponent(lblIssues))) - .addGroup(groupLayout.createSequentialGroup() - .addGap(24) - .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addContainerGap()) - ); - groupLayout.setVerticalGroup( - groupLayout.createParallelGroup(Alignment.LEADING) - .addGroup(groupLayout.createSequentialGroup() - .addContainerGap() - .addComponent(lblHomepanel) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTotalHosts) - .addComponent(totalMonitoredHosts, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTotal) - .addComponent(totalMonitoredVms, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGap(18) - .addComponent(lblIssues) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addContainerGap()) - ); - - issuesList = new ArrayList<>(); - ListModel<Object> issuesListModel = new IssuesListModel(issuesList); - JList<Object> issuesList = new JList<>(); - issuesList.setModel(issuesListModel); - scrollPane.setViewportView(issuesList); - visiblePanel.setLayout(groupLayout); - - visiblePanel.addHierarchyListener(new ComponentVisibleListener() { - @Override - public void componentShown(Component component) { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void componentHidden(Component component) { - notifier.fireAction(Action.HIDDEN); - } - }); - } - - @Override - public void addActionListener(ActionListener<Action> listener) { - notifier.addActionListener(listener); - } - - @Override - public void removeActionListener(ActionListener<Action> listener) { - notifier.removeActionListener(listener); - } - - @Override - public void setTotalHosts(final String count) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - totalMonitoredHosts.setText(count); - } - }); - } - - @Override - public void setTotalVms(final String count) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - totalMonitoredVms.setText(count); - } - }); - } - - @Override - public Component getUiComponent() { - return visiblePanel; - } - - private static class IssuesListModel extends AbstractListModel<Object> { - - private static final long serialVersionUID = 7131506292620902850L; - - private List<? extends Object> delegate; - - private String emptyElement = translator.localize(LocaleResources.HOME_PANEL_NO_ISSUES).getContents(); - - public IssuesListModel(List<? extends Object> actualList) { - this.delegate = actualList; - // TODO observe the delegate for changes - } - - @Override - public int getSize() { - if (delegate.isEmpty()) { - return 1; - } - return delegate.size(); - } - - @Override - public Object getElementAt(int index) { - if (delegate.isEmpty()) { - return emptyElement; - } - return delegate.get(index); - } - } -} -
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/views/SwingSummaryViewProvider.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/views/SwingSummaryViewProvider.java Fri Nov 22 13:08:52 2013 -0500 @@ -36,14 +36,14 @@ package com.redhat.thermostat.client.swing.internal.views; -import com.redhat.thermostat.client.core.views.SummaryView; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; +import com.redhat.thermostat.client.core.views.VersionAndInfoView; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; -public class SwingSummaryViewProvider implements SummaryViewProvider { +public class SwingSummaryViewProvider implements VersionAndInfoViewProvider { @Override - public SummaryView createView() { - return new SummaryPanel(); + public VersionAndInfoView createView() { + return new VersionAndInfoPanel(); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/views/VersionAndInfoPanel.java Fri Nov 22 13:08:52 2013 -0500 @@ -0,0 +1,64 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.swing.internal.views; + +import java.awt.BorderLayout; +import java.awt.Component; + +import javax.swing.JPanel; + +import com.redhat.thermostat.client.core.views.VersionAndInfoView; +import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.internal.AboutPanel; +import com.redhat.thermostat.common.ApplicationInfo; + +public class VersionAndInfoPanel extends VersionAndInfoView implements SwingComponent { + + private JPanel visiblePanel; + + @Override + public void initialize(ApplicationInfo appInfo) { + visiblePanel = new JPanel(new BorderLayout()); + visiblePanel.add(new AboutPanel(appInfo), BorderLayout.PAGE_START); + } + + @Override + public Component getUiComponent() { + return visiblePanel; + } +} +
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Fri Nov 22 13:08:52 2013 -0500 @@ -58,8 +58,8 @@ import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.HostInformationView; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; -import com.redhat.thermostat.client.core.views.SummaryView; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; +import com.redhat.thermostat.client.core.views.VersionAndInfoView; +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.registry.decorator.DecoratorRegistryController; @@ -149,9 +149,9 @@ BackendInfoDAO backendInfoDAO = mock(BackendInfoDAO.class); context.registerService(BackendInfoDAO.class, backendInfoDAO, null); - SummaryViewProvider summaryViewProvider = mock(SummaryViewProvider.class); - context.registerService(SummaryViewProvider.class, summaryViewProvider, null); - SummaryView summaryView = mock(SummaryView.class); + VersionAndInfoViewProvider summaryViewProvider = mock(VersionAndInfoViewProvider.class); + context.registerService(VersionAndInfoViewProvider.class, summaryViewProvider, null); + VersionAndInfoView summaryView = mock(VersionAndInfoView.class); when(summaryViewProvider.createView()).thenReturn(summaryView); HostInformationViewProvider hostInfoViewProvider = mock(HostInformationViewProvider.class);
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Fri Nov 22 12:50:26 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Fri Nov 22 13:08:52 2013 -0500 @@ -44,7 +44,7 @@ import com.redhat.thermostat.client.core.views.AgentInformationViewProvider; import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; -import com.redhat.thermostat.client.core.views.SummaryViewProvider; +import com.redhat.thermostat.client.core.views.VersionAndInfoViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingAgentInformationViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingClientConfigurationViewProvider; @@ -63,7 +63,7 @@ activator.start(ctx); - assertTrue(ctx.isServiceRegistered(SummaryViewProvider.class.getName(), SwingSummaryViewProvider.class)); + assertTrue(ctx.isServiceRegistered(VersionAndInfoViewProvider.class.getName(), SwingSummaryViewProvider.class)); assertTrue(ctx.isServiceRegistered(HostInformationViewProvider.class.getName(), SwingHostInformationViewProvider.class)); assertTrue(ctx.isServiceRegistered(VmInformationViewProvider.class.getName(), SwingVmInformationViewProvider.class)); assertTrue(ctx.isServiceRegistered(AgentInformationViewProvider.class.getName(), SwingAgentInformationViewProvider.class));