Mercurial > hg > release > thermostat-0.13
changeset 229:de4e1186ebe0
Move logic for showing the agent preferences into MainWindowControllerImpl
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-April/000818.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 13 Apr 2012 12:27:20 -0400 |
parents | b2659f4f8bf0 |
children | 9e23a7bfdbef |
files | client/src/main/java/com/redhat/thermostat/client/Configuration.java client/src/main/java/com/redhat/thermostat/client/MainView.java client/src/main/java/com/redhat/thermostat/client/MainWindowControllerImpl.java client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java |
diffstat | 4 files changed, 17 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/main/java/com/redhat/thermostat/client/Configuration.java Fri Apr 13 11:38:21 2012 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright 2012 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; - -import javax.swing.SwingUtilities; - -import com.redhat.thermostat.client.ui.AgentConfigurationController; -import com.redhat.thermostat.client.ui.AgentConfigurationModel; -import com.redhat.thermostat.client.ui.AgentConfigurationView; -import com.redhat.thermostat.common.appctx.ApplicationContext; - -public class Configuration { - - public void showAgentConfiguration() { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - AgentConfigurationView view = ApplicationContext.getInstance().getViewFactory().getView(AgentConfigurationView.class); - AgentConfigurationSource agentPrefs = new AgentConfigurationSource(); - AgentConfigurationModel model = new AgentConfigurationModel(agentPrefs); - AgentConfigurationController controller = new AgentConfigurationController(model, view); - controller.showView(); - } - }); - } - - public static void main(String[] args) { - new Configuration().showAgentConfiguration(); - } - -}
--- a/client/src/main/java/com/redhat/thermostat/client/MainView.java Fri Apr 13 11:38:21 2012 -0400 +++ b/client/src/main/java/com/redhat/thermostat/client/MainView.java Fri Apr 13 12:27:20 2012 -0400 @@ -43,8 +43,9 @@ enum Action { HOST_VM_TREE_FILTER, + SHOW_AGENT_CONFIG, SHOW_CLIENT_CONFIG, - SHUTDOWN + SHUTDOWN, } void addActionListener(ActionListener<Action> capture);
--- a/client/src/main/java/com/redhat/thermostat/client/MainWindowControllerImpl.java Fri Apr 13 11:38:21 2012 -0400 +++ b/client/src/main/java/com/redhat/thermostat/client/MainWindowControllerImpl.java Fri Apr 13 12:27:20 2012 -0400 @@ -40,6 +40,9 @@ import java.util.concurrent.TimeUnit; import com.redhat.thermostat.client.config.ClientPreferences; +import com.redhat.thermostat.client.ui.AgentConfigurationController; +import com.redhat.thermostat.client.ui.AgentConfigurationModel; +import com.redhat.thermostat.client.ui.AgentConfigurationView; import com.redhat.thermostat.client.ui.ClientConfigurationController; import com.redhat.thermostat.client.ui.ClientConfigurationView; import com.redhat.thermostat.common.ActionEvent; @@ -136,6 +139,9 @@ String filter = view.getHostVmTreeFilter(); setHostVmTreeFilter(filter); break; + case SHOW_AGENT_CONFIG: + showAgentConfiguration(); + break; case SHOW_CLIENT_CONFIG: showConfigureClientPreferences(); break; @@ -154,6 +160,14 @@ view.showMainWindow(); } + private void showAgentConfiguration() { + AgentConfigurationSource agentPrefs = new AgentConfigurationSource(); + AgentConfigurationModel model = new AgentConfigurationModel(agentPrefs); + AgentConfigurationView view = ApplicationContext.getInstance().getViewFactory().getView(AgentConfigurationView.class); + AgentConfigurationController controller = new AgentConfigurationController(model, view); + controller.showView(); + } + private void showConfigureClientPreferences() { ClientPreferences prefs = new ClientPreferences(); ClientConfigurationView view = ApplicationContext.getInstance().getViewFactory().getView(ClientConfigurationView.class);
--- a/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java Fri Apr 13 11:38:21 2012 -0400 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java Fri Apr 13 12:27:20 2012 -0400 @@ -85,9 +85,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; -import com.redhat.thermostat.client.AgentConfigurationSource; import com.redhat.thermostat.client.ApplicationInfo; -import com.redhat.thermostat.client.Configuration; import com.redhat.thermostat.client.HostsVMsLoader; import com.redhat.thermostat.client.MainView; import com.redhat.thermostat.client.UiFacadeFactory; @@ -302,7 +300,7 @@ configureAgentMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { - new Configuration().showAgentConfiguration(); + fireViewAction(Action.SHOW_AGENT_CONFIG); } }); editMenu.add(configureAgentMenuItem);