«Содержание Введение 1 Системы мониторинга 1.1 Введение 1.2 Понятие систем мониторинга 1.3 Подсистемы мониторинга 1.3.1 Сбор данных 1.3.2 Хранение данных 1.3.3 Анализ данных 1.3.4 Отчетность 1.3.5 Оповещения 1.3.6 ...»
import com.googlecode.listener.*;
import com.googlecode.snoopycp.Defaults;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.core.Domain;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
public class Coordinator { public static Logger logger = Logger.getLogger(Coordinator.class);
private Domain domain;
private MainFrame view;
public Coordinator(Domain _domain, MainFrame view) { this.domain = _domain;
this.view.setActionsOnPopup(this.packActions());
domain.addObserver(view);
view.setCoordinator(this);
public Domain domain() { return this.domain;
private Map packActions() { Map actions = new HashMap();
actions.put("NodeProperties", new NodePropertiesAL(view, domain));
actions.put("ForceStart", new NodeForceStartAL(view, domain));
actions.put("Shutdown", new NodeShutdownAL(view, domain));
actions.put("ModuleProperties", new ModulePropertiesAL(view, domain));
actions.put("HostResults", new HostResultsAL(view, this, logger));
actions.put("ModuleResults", new ModuleResultsAL(view, this, logger));
public void launch() { Defaults.APP_VER);
view.setLocationRelativeTo(null);
view.setVisible(true);
synchronized (this) { } catch (InterruptedException ex) { logger.error(ex.getMessage());
public void terminate() { synchronized (this) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.controller.Coordinator;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.DataBaseHostTableModel;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.ui.Results;
import java.sql.Connection;
import java.sql.Statement;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import org.apache.log4j.Logger;
/** * @author Leo public class HostResultsAL implements ActionListener { private Coordinator coordinator; // Controller private Connection conn = null; // connection to database private Statement stmt;
private Logger logger; // Logger which prints to console public HostResultsAL(MainFrame view, Coordinator _coordinator, Logger _logger) { // Initialisation of data this.coordinator = _coordinator;
this.domain = coordinator.domain();
@Override public void actionPerformed(ActionEvent e) { // Get last selected node in the Tree DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
Node node = (Node) lastSelectNode.getUserObject();
String[][] results = this.getHostResults(node.name); // get data from database view.addInternalFrame(new Results(new DataBaseHostTableModel(results), node.name));
JOptionPane.showMessageDialog(view, "Cannot connect to database");
public String[][] getHostResults(String hostname) { String sql = "select Module.name, Result.`result`, Result.datestamp from `Result`, `Host`, `Module` where Host.`name`='" + hostname + "' and Host.idHost=Result.idHost and Module.idModule=Result.idModule";
domain.configurer(domain.enviroment().get(hostname)).configuration().get("connectionstring ");
logger.debug("Connect to datebase: " + url);
String[][] results = null;
Class.forName("com.mysql.jdbc.Driver").newInstance(); // load driver logger.debug("Database connection established");
stmt = conn.createStatement();
if (stmt.execute(sql)) { // execute sql script logger.debug("SQL statement wasn`t execute");
} catch (InstantiationException ex) { logger.error("Instantiation");
} catch (IllegalAccessException ex) { logger.error("IllegalAccess");
} catch (ClassNotFoundException ex) { logger.error("ClassNotFound");
} catch (SQLException e) { logger.error("Cannot connect to database server");
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.ui.ModulePropertyInternalFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.tree.DefaultMutableTreeNode;
public class ModulePropertiesAL implements ActionListener { private MainFrame view;
public ModulePropertiesAL(MainFrame view, Domain _domain) { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
// get object with information about node Node node = (Node) lastSelectNode.getUserObject();
domain.hoster(node.identity).context();
map.put("IP", domain.cache(node.identity).get("primary").split(" ")[2]);
view.addInternalFrame(new ModulePropertyInternalFrame(domain, node.identity, node.muid));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.controller.Coordinator;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.DataBaseModuleTableModel;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.ui.Results;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Set;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import org.apache.log4j.Logger;
/** * @author Leo public class ModuleResultsAL implements ActionListener { private Coordinator coordinator; // Controller private Connection conn = null; // connection to database private Statement stmt;
private ResultSet rs; // Results of sql script executing private Logger logger; // Logger which prints to console public ModuleResultsAL(MainFrame view, Coordinator _coordinator, Logger _logger) { this.coordinator = _coordinator;
this.logger = _logger;
@Override public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
// get object with information about node Node node = (Node) lastSelectNode.getUserObject();
logger.debug(node.identity + " " + node.muid);
// get list of hosts registred in panel Set hosts = coordinator.domain().hosts();
String hostname = null;
for (String host : hosts) { // for all hosts if (coordinator.domain().enviroment().get(host).equals(node.identity)) { // get data from database String[][] results = this.getModuleResults(hostname, node.name);
view.addInternalFrame(new Results(new DataBaseModuleTableModel(results), node.name));
JOptionPane.showMessageDialog(view, "Cannot connect to database");
public String[][] getModuleResults(String hostname, String moduleName) { String sql = "select Result.`result`, Result.datestamp from `Result`, `Host`, `Module` where Host.`name`='" + hostname + "' and Host.idHost=Result.idHost and Module.idModule=Result.idModule and Module.`name`='" + moduleName + "'";
domain.configurer(domain.enviroment().get(hostname)).configuration().get("connectionstring ");
logger.debug("Connect to datebase: " + url);
String[][] results = null; // results Class.forName("com.mysql.jdbc.Driver").newInstance(); // load driver logger.debug("Database connection established"); // all is good stmt = conn.createStatement();
} catch (InstantiationException ex) { logger.error("Instantiation");
} catch (IllegalAccessException ex) { logger.error("IllegalAccess");
} catch (ClassNotFoundException ex) { logger.error("ClassNotFound");
logger.error("Cannot connect to database server");
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.tree.DefaultMutableTreeNode;
public class NodeForceStartAL implements ActionListener { private MainFrame view;
public NodeForceStartAL(MainFrame view, Domain _domain) { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
// get object with information about node Node node = (Node) lastSelectNode.getUserObject();
// command module to "start" with parameters this.domain.moduler(node.identity).force(node.muid, this.view.showInputDialog().split(";"));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.ui.NodePropertiesInternalFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.tree.DefaultMutableTreeNode;
public class NodePropertiesAL implements ActionListener { private MainFrame view;
public NodePropertiesAL(MainFrame view, Domain _domain) { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
// get object with information about node Node node = (Node) lastSelectNode.getUserObject();
domain.hoster(node.identity).context();
map.put("IP", domain.cache(node.identity).get("primary").split(" ")[2]);
// display properties in new window view.addInternalFrame(new NodePropertiesInternalFrame(map, node.name, this.domain.configurer(node.identity)));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.listener;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.Node;
import com.googlecode.snoopycp.ui.MainFrame;
import com.googlecode.snoopycp.util.Identities;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.tree.DefaultMutableTreeNode;
public class NodeShutdownAL implements ActionListener { private MainFrame view;
public NodeShutdownAL(MainFrame view, Domain _domain) { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode lastSelectNode = (DefaultMutableTreeNode) view.getTree().getLastSelectedPathComponent();
// get object with information about node Node node = (Node) lastSelectNode.getUserObject();
// command "shutdown" to selected node domain.controller(node.identity).shutdown();
for (String host : domain.hosts()) { // search in all hosts if (Identities.equals(domain.enviroment().get(host), node.identity)) { domain.removeHost(host); // remove host from domain after shutdown // Domain is changed, notify to somebody domain.notifyObserver();
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import javax.swing.table.AbstractTableModel;
/** * @author Leo public class DataBaseHostTableModel extends AbstractTableModel { String[] names = {"Module name", "Result", "Date"};
String[][] results;
public DataBaseHostTableModel(String[][] _result) { this.results = _result;
@Override public String getColumnName(int column) { return names[column];
@Override public int getRowCount() { return results[0].length;
@Override public int getColumnCount() { return names.length;
@Override public Object getValueAt(int rowIndex, int columnIndex) { return results[columnIndex][rowIndex];
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import javax.swing.table.AbstractTableModel;
public class DataBaseModuleTableModel extends AbstractTableModel { String[] names = {"Result", "Date"};
String[][] results;
public DataBaseModuleTableModel(String[][] _results) { this.results = _results;
@Override public String getColumnName(int column) { return names[column];
@Override public int getRowCount() { return results[0].length;
@Override public int getColumnCount() { return names.length;
@Override public Object getValueAt(int rowIndex, int columnIndex) { return results[columnIndex][rowIndex];
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.util.Identities;
import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.Graph;
import java.util.Map;
public class GraphModel { private Domain domain;
private Graph graph;
public GraphModel(Domain domain) { this.domain = domain;
graph = new DirectedSparseGraph();
public void update() { for (String host : domain.hosts()) { Ice.Identity identity = domain.enviroment().get(host);
for (String child : ctx.get("childs").split(";")) { Ice.Identity childIdentity = Identities.stringToIdentity(child);
if (childIdentity.equals(domain.enviroment().get(childhost))) Identities.toString(Identities.xor(identity, childIdentity));
public Graph graph() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import Ice.Identity;
import java.util.Map;
public class Node { public final Ice.Identity identity;
public final String name;
public String muid;
public Map moduleStatuses;
public enum Type { public enum OsType { WIN, LIN, MAC, UNIX, UNKNOWN public Type nodeType;
public OsType os;
public Node(Identity _identity, String _name, Type _type, OsType _os) { this.identity = _identity;
this.nodeType = _type;
public Node(Identity _identity, String _name, String _muid, Type _type, Map _moduleStatuses) { this(_identity, _name, _type, null);
moduleStatuses = _moduleStatuses;
@Override public String toString() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import com.googlecode.snoopycp.core.Domain;
import javax.swing.table.AbstractTableModel;
import org.apache.log4j.Logger;
public class ParamTableModel extends AbstractTableModel { Domain domain;
Ice.Identity ident;
Logger logger;
String muid;
public ParamTableModel(Domain _domain, Ice.Identity _ident, Logger _logger, String _muid) { @Override public String getColumnName(int column) { @Override public int getRowCount() { domain.scheduler(ident).ice_ping();
String[] strs = domain.scheduler(ident).paramtable().get(muid).split(";");
} catch (Ice.ConnectionRefusedException ex) { logger.warn("Cann`t fetch timetable from " + domain.enviroment().get(ident));
@Override public int getColumnCount() { @Override public Object getValueAt(int rowIndex, int columnIndex) { domain.scheduler(ident).ice_ping();
String[] params = domain.scheduler(ident).paramtable().get(muid).split(";");
return params[rowIndex];
} catch (Ice.ConnectionRefusedException ex) { logger.warn("Cann`t fetch timetable from " + domain.enviroment().get(ident));
return "Cann`t fetch timetable from " + domain.enviroment().get(ident);
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.util.Identities;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.swing.table.AbstractTableModel;
public class TableModel extends AbstractTableModel implements javax.swing.table.TableModel public static final String[] COLUMNS = {"Property", "Value"};
private Domain domain;
private List keys;
private List values;
private int size;
public TableModel(Domain domain) { this.domain = domain;
this.keys = new ArrayList();
this.values = new ArrayList();
@Override public int getColumnCount() { return COLUMNS.length;
@Override public boolean isCellEditable(int rowIndex, int columnIndex) { @Override public String getColumnName(int column) { return COLUMNS[column];
public int getRowCount() { public Object getValueAt(int rowIndex, int columnIndex) { return keys.get(rowIndex);
return values.get(rowIndex);
public void update(Ice.Identity identity) { values.clear();
//System.out.println("asdfasdf");
System.out.println(Identities.toString(identity));
System.out.println("adsfasdf");
domain.hoster(identity).ice_ping();
Map data = domain.hoster(identity).context();
System.out.println("TableModel.update: " + ex.getMessage());
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import com.googlecode.snoopycp.core.Domain;
import org.apache.log4j.Logger;
import javax.swing.table.AbstractTableModel;
public class TimeTableModel extends AbstractTableModel { Domain domain;
Ice.Identity ident;
Logger logger;
String muid;
public TimeTableModel(Domain _domain, Ice.Identity _ident, Logger _logger, String _muid) { @Override public String getColumnName(int column) { return "Intervals";
@Override public int getRowCount() { // FIXME if dead and window of property is opened domain.scheduler(ident).ice_ping();
String[] strs = domain.scheduler(ident).timetable().get(muid).split(";");
} catch (Ice.ConnectionRefusedException ex) { logger.warn("Cann`t fetch timetable from " + domain.enviroment().get(ident));
@Override public int getColumnCount() { @Override public Object getValueAt(int rowIndex, int columnIndex) { domain.scheduler(ident).ice_ping();
String[] schedule = domain.scheduler(ident).timetable().get(muid).split(";");
return schedule[rowIndex] + " ms";
} catch (Ice.ConnectionRefusedException ex) { logger.warn("Cann`t fetch timetable from " + domain.enviroment().get(ident));
return "Cann`t fetch timetable from " + domain.enviroment().get(ident);
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.model;
import com.googlecode.snoopycp.Defaults;
import com.googlecode.snoopycp.core.Domain;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.swing.ImageIcon;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
public class TreeModel extends DefaultTreeModel implements javax.swing.tree.TreeModel { private Domain domain; // container of all private JPopupMenu popupNode;
private JPopupMenu popupModule;
private JPopupMenu popupDomen;
private JMenuItem menuItem; // template for all popup menu private Ice.Identity currentId; // Identity of current selected node private TreePath selectedPath;
private DefaultMutableTreeNode selectedNode;
private Node userObj; // User object initilation of node private Map actions;
public TreeModel(Domain domain) { super(new DefaultMutableTreeNode(domain.name())); // call constructor of superclass this.domain = domain;
//initPopup(); // build popup menu and bind actions public void update(JTree _tree) { DefaultMutableTreeNode domainRoot = (DefaultMutableTreeNode) root;
domainRoot.removeAllChildren(); // Clean tree Set hosts = domain.hosts(); // get all host from cache Node.OsType os = Node.OsType.UNKNOWN;
DefaultMutableTreeNode node;
Ice.Identity identity = domain.enviroment().get(host);
osName = domain.osPull().get(identity);
} else if (osName.indexOf("lin") != -1 || osName.indexOf("Lin") != -1) { node = new DefaultMutableTreeNode(new Node(identity, host, Node.Type.NODE, os), true);
HashMap fullKeys = (HashMap) domain.moduleName(identity);
Node.Type.MODULE, domain.moduleStatus(identity)), false));
node = new DefaultMutableTreeNode(new Node(identity, host + " [died]", Node.Type.NODE, os), true);
domainRoot.add(node); // add node in tree public Enumeration getExpandedNodes(JTree _tree) { Enumeration selPaths = null;
if (_tree.getSelectionPath() != null) { TreePath path = _tree.getSelectionPath().getParentPath().getParentPath();
selPaths = _tree.getExpandedDescendants(path);
public void setExpandedNodes (JTree _tree, Enumeration _paths) { while (_paths.hasMoreElements()) { _tree.expandPath(_paths.nextElement());
private JPopupMenu getPopupMenu(Node.Type _type) { JPopupMenu popup = popupDomen;
* Bind popup menu on _tree on mouse right click * @param _tree tree for popup menu binding public void setPopupMenu(JTree _tree, Map _actions) { final JTree tree = _tree;
actions = _actions;
initPopup();
tree.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX(), e.getY());
selectedPath = tree.getPathForLocation(e.getX(), e.getY());
e.getY());
tree.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent ke) { public void keyPressed(KeyEvent ke) { Object obj = tree.getLastSelectedPathComponent();
public void keyReleased(KeyEvent ke) { Object obj = tree.getLastSelectedPathComponent();
selectedNode = (DefaultMutableTreeNode) obj;
final Object tmp = selectedNode.getUserObject();
getPopupMenu(popupType).setVisible(false);
private void initPopup() { // Init popup menu for Module popupModule = new JPopupMenu();
menuItem = new JMenuItem("Force start", getImageIcon("work.png"));
menuItem.addActionListener(actions.get("ForceStart"));
popupModule.add(menuItem);
menuItem = new JMenuItem("Results", getImageIcon("database.png"));
menuItem.addActionListener(actions.get("ModuleResults"));
popupModule.add(menuItem);
menuItem = new JMenuItem("Properties", getImageIcon("property.png"));
menuItem.addActionListener(actions.get("ModuleProperties"));
popupModule.add(menuItem);
popupModule.setOpaque(true);
popupModule.setLightWeightPopupEnabled(true);
// Init popup menu for Node popupNode = new JPopupMenu();
menuItem = new JMenuItem("Shutdown", getImageIcon("slash.png"));
menuItem.addActionListener(actions.get("Shutdown"));
popupNode.add(menuItem);
menuItem = new JMenuItem("Results", getImageIcon("database.png"));
menuItem.addActionListener(actions.get("HostResults"));
popupNode.add(menuItem);
menuItem = new JMenuItem("Properties", getImageIcon("property.png"));
menuItem.addActionListener(actions.get("NodeProperties"));
popupNode.add(menuItem);
// Init popup menu for Domen (Not showing) popupDomen = new JPopupMenu();
menuItem = new JMenuItem("Bla-bla");
menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { popupDomen.add(menuItem);
menuItem = new JMenuItem("Force");
menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { popupDomen.add(menuItem);
private ImageIcon getImageIcon(String _iconName) { return new ImageIcon(getClass().getResource(Defaults.PATH_TO_SHARE + _iconName));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.Defaults;
import javax.swing.ImageIcon;
public class AboutDialog extends javax.swing.JDialog { /** Creates new form AboutDialog */ public AboutDialog(java.awt.Frame parent, boolean modal) { super(parent, modal);
initComponents();
this.setTitle(Defaults.APP_NAME);
this.jTextArea1.setEditable(false);
this.setLocationRelativeTo(parent);
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { jLabel1 = new javax.swing.JLabel();
btnCloseAbout = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/about_logo_ 0x224.jpg"))); // NOI18N btnCloseAbout.setText("Close About");
btnCloseAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCloseAboutActionPerformed(evt);
jTextArea1.setColumns(20);
jTextArea1.setFont(new java.awt.Font("DejaVu Sans", 0, 14)); // NOI18N jTextArea1.setRows(5);
system\n http://snoopy.googlecode.com");
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE).addComponent(btnCloseAbout) private void btnCloseAboutActionPerformed(java.awt.event.ActionEvent evt) { this.dispose();
// Variables declaration - do not modify private javax.swing.JButton btnCloseAbout;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.core.Domain;
import javax.swing.DefaultListModel;
import javax.swing.JInternalFrame;
public class ChooseModuleInternalFrame extends javax.swing.JInternalFrame { private Domain domain;
private DefaultListModel listAvaliableModel = new DefaultListModel();
private DefaultListModel listDeploiedModel = new DefaultListModel();
private NotepadInternalFrame notepad;
/** Creates new form ChooseModuleInternalFrame */ public ChooseModuleInternalFrame(Domain _domain, JInternalFrame _frame) { initComponents();
this.setClosable(true);
this.setTitle("Choose modules to deploy");
notepad = (NotepadInternalFrame) _frame;
this.btnOkChooseModule.setEnabled(false);
private void initList() { this.listAvaliable.setModel(listAvaliableModel);
this.listDeploied.setModel(listDeploiedModel);
for (Object host : domain.hosts().toArray()) { this.listAvaliableModel.addElement(host.toString());
this.listDeploiedModel.clear();
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane();
listAvaliable = new javax.swing.JList();
jScrollPane2 = new javax.swing.JScrollPane();
listDeploied = new javax.swing.JList();
btnMoveOne = new javax.swing.JButton();
btnMoveAll = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
btnOkChooseModule = new javax.swing.JButton();
btnRemain = new javax.swing.JButton();
btnRemainAll = new javax.swing.JButton();
jCheckBox1 = new javax.swing.JCheckBox();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jTextField2 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jScrollPane1.setViewportView(listAvaliable);
jScrollPane2.setViewportView(listDeploied);
btnMoveOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/control.png") )); // NOI18N btnMoveOne.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMoveOneActionPerformed(evt);
btnMoveAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/controldouble.png"))); // NOI18N btnMoveAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMoveAllActionPerformed(evt);
jLabel1.setText("Avaliable");
jLabel2.setText("Deploied");
btnOkChooseModule.setText("Deploy");
btnOkChooseModule.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnOkChooseModuleActionPerformed(evt);
btnRemain.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/controlpng"))); // NOI18N btnRemain.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRemainActionPerformed(evt);
btnRemainAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/controldouble-180.png"))); // NOI18N btnRemainAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRemainAllActionPerformed(evt);
jCheckBox1.setText("Activate module after deploying");
jLabel3.setText("Schedule");
jButton1.setText("Cancel");
jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);
jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt);
jLabel4.setText("Parameters");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE).addComponent(btnRemain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)))) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)))).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) private void btnMoveOneActionPerformed(java.awt.event.ActionEvent evt) { if (!this.listAvaliable.isSelectionEmpty()) { int[] indexes = this.listAvaliable.getSelectedIndices();
this.listDeploiedModel.addElement(this.listAvaliableModel.getElementAt(index).toString());
this.listAvaliableModel.removeElementAt(index);
this.btnOkChooseModule.setEnabled(true);
private void btnMoveAllActionPerformed(java.awt.event.ActionEvent evt) { if (!this.listAvaliableModel.isEmpty()) { this.listDeploiedModel.clear();
for (Object host : domain.hosts().toArray()) { this.listDeploiedModel.addElement(host.toString());
this.listAvaliableModel.clear();
this.btnOkChooseModule.setEnabled(true);
private void btnRemainAllActionPerformed(java.awt.event.ActionEvent evt) { if (!this.listDeploiedModel.isEmpty()) { this.listAvaliableModel.clear();
for (Object host : domain.hosts().toArray()) { this.listAvaliableModel.addElement(host.toString());
this.listDeploiedModel.clear();
this.btnOkChooseModule.setEnabled(false);
private void btnRemainActionPerformed(java.awt.event.ActionEvent evt) { if (!this.listDeploied.isSelectionEmpty()) { int[] indexes = this.listDeploied.getSelectedIndices();
this.listAvaliableModel.addElement(this.listDeploiedModel.getElementAt(index).toString());
this.listDeploiedModel.removeElementAt(index);
if(this.listDeploiedModel.isEmpty()) { this.btnOkChooseModule.setEnabled(false);
private void btnOkChooseModuleActionPerformed(java.awt.event.ActionEvent evt) { notepad.deploy( this.listDeploiedModel.toArray(), this.jCheckBox1.isSelected(), this.jTextField2.getText());
this.dispose();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { this.dispose();
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
// Variables declaration - do not modify private javax.swing.JButton btnMoveAll;
private javax.swing.JButton btnMoveOne;
private javax.swing.JButton btnOkChooseModule;
private javax.swing.JButton btnRemain;
private javax.swing.JButton btnRemainAll;
private javax.swing.JButton jButton1;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JList listAvaliable;
private javax.swing.JList listDeploied;
// End of variables declaration /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.Defaults;
import com.googlecode.snoopycp.model.Node;
import java.awt.Component;
import java.util.HashMap;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.tree.DefaultMutableTreeNode;
public class IconTreeCellRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { String stringValue = tree.convertValueToText(value, sel, expanded, leaf, row, hasFocus);
this.hasFocus = hasFocus;
setForeground(getTextSelectionColor());
setForeground(getTextNonSelectionColor());
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getUserObject() instanceof String) { setIcon(getImageIcon("globe-network.png"));
Node userObj = (Node) node.getUserObject();
switch (userObj.nodeType) { setIcon(getImageIcon("network.png"));
if (map.get(userObj.muid).equalsIgnoreCase("on")) { //JOptionPane.showMessageDialog(null, "No module status for " + userObj.name);
setIcon(getImageIcon("status-offline.png"));
setIcon(getImageIcon("logo_qst.jpg"));
setComponentOrientation(tree.getComponentOrientation());
private ImageIcon getImageIcon(String _iconName) { return new ImageIcon(getClass().getResource(Defaults.PATH_TO_SHARE + _iconName));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.controller.Coordinator;
import com.googlecode.snoopycp.controller.DomainController;
import com.googlecode.snoopycp.model.GraphModel;
import com.googlecode.snoopycp.model.TreeModel;
import edu.uci.ics.jung.algorithms.layout.FRLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.tree.TreePath;
import org.apache.log4j.Logger;
public class MainFrame extends javax.swing.JFrame implements Observer { public static Logger logger = Logger.getLogger(MainFrame.class);
private DomainController controller;
private TreeModel treeModel;
private GraphModel graphModel;
private VisualizationViewer visualizationViewer;
private Layout layout;
private netMapIFrame nmif = new netMapIFrame();
private Coordinator coordinator;
/** Creates new form MainFrame */ public MainFrame() { initComponents();
this.setLocationRelativeTo(null);
public MainFrame(DomainController _controller) { this.controller = _controller;
this.treeModel = controller.createTreeModel();
this.graphModel = controller.createGraphModel();
this.tree.setModel(treeModel);
this.tree.setCellRenderer(new IconTreeCellRenderer());
this.layout = new FRLayout(graphModel.graph(), new Dimension(200, 200));
this.visualizationViewer = new VisualizationViewer(layout);
this.visualizationViewer.getRenderContext().setVertexLabelTransformer(controller.createLab elTransformer());
this.visualizationViewer.getRenderContext().setVertexFillPaintTransformer(controller.creat eFillTransformer());
visualizationViewer.setPreferredSize(new Dimension(50, 100));
visualizationViewer.setBackground(Color.WHITE);
nmif.add(visualizationViewer);
update(null, null);
public void addInternalFrame(JInternalFrame _frame) { this.jdp.add(_frame);
_frame.setLocation(centralPosition(_frame));
_frame.setVisible(true);
public void setCoordinator(Coordinator _coordinator) { coordinator = _coordinator;
public void setActionsOnPopup(Map _actions) { treeModel.setPopupMenu(this.tree, _actions);
public javax.swing.JTree getTree() { return this.tree;
public String showInputDialog() { return JOptionPane.showInputDialog(this, "Enter parameters for module:");
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { jToolBar = new javax.swing.JToolBar();
btnNotepad = new javax.swing.JButton();
btnNetMap = new javax.swing.JButton();
btnRefresh = new javax.swing.JButton();
jsp = new javax.swing.JSplitPane();
jdp = new javax.swing.JDesktopPane();
jscp = new javax.swing.JScrollPane();
tree = new javax.swing.JTree();
jMenuBar = new javax.swing.JMenuBar();
menuFile = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
menuItemExit = new javax.swing.JMenuItem();
menuNetwork = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
menuHelp = new javax.swing.JMenu();
menuItemAbout = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jToolBar.setRollover(true);
btnNotepad.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/script-plus.png"))); // NOI18N btnNotepad.setFocusable(false);
btnNotepad.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnNotepad.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnNotepad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNotepadActionPerformed(evt);
jToolBar.add(btnNotepad);
btnNetMap.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/node-selectchild.png"))); // NOI18N btnNetMap.setFocusable(false);
btnNetMap.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnNetMap.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnNetMap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNetMapActionPerformed(evt);
jToolBar.add(btnNetMap);
btnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/refresh.png") )); // NOI18N btnRefresh.setFocusable(false);
btnRefresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnRefresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnRefresh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRefreshActionPerformed(evt);
jToolBar.add(btnRefresh);
jsp.setDividerLocation(180);
jsp.setRightComponent(jdp);
jscp.setViewportView(tree);
jsp.setLeftComponent(jscp);
menuFile.setText("File");
jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/script-plus.png"))); // NOI18N jMenuItem3.setText("Notepad");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt);
menuFile.add(jMenuItem3);
menuItemExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/dooropen.png"))); // NOI18N menuItemExit.setText("Exit");
menuItemExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuItemExitActionPerformed(evt);
menuFile.add(menuItemExit);
jMenuBar.add(menuFile);
menuNetwork.setText("Network");
jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/node-selectchild.png"))); // NOI18N jMenuItem1.setText("view full map");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt);
menuNetwork.add(jMenuItem1);
jMenuBar.add(menuNetwork);
menuHelp.setText("Help");
menuItemAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/googlecode/snoopycp/share/home.png")));
// NOI18N menuItemAbout.setText("About");
menuItemAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuItemAboutActionPerformed(evt);
menuHelp.add(menuItemAbout);
jMenuBar.add(menuHelp);
setJMenuBar(jMenuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 849, Short.MAX_VALUE).addComponent(jsp, javax.swing.GroupLayout.DEFAULT_SIZE, 849, Short.MAX_VALUE) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jsp, javax.swing.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)) private void menuItemAboutActionPerformed(java.awt.event.ActionEvent evt) { AboutDialog ad = new AboutDialog(this, true);
ad.setVisible(true);
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // FIXME need call from Coordinator if (!nmif.isShowing()) { nmif.setClosable(true);
nmif.setResizable(true);
nmif.setLocation(centralPosition(nmif));
private void menuItemExitActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0);
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) { this.addInternalFrame(new NotepadInternalFrame(coordinator.domain()));
private void btnNotepadActionPerformed(java.awt.event.ActionEvent evt) { this.jMenuItem3ActionPerformed(evt);
private void btnNetMapActionPerformed(java.awt.event.ActionEvent evt) { this.jMenuItem1ActionPerformed(evt);
private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) { this.update(null, null);
* @param args the command line arguments // Variables declaration - do not modify private javax.swing.JButton btnNetMap;
private javax.swing.JButton btnNotepad;
private javax.swing.JButton btnRefresh;
private javax.swing.JMenuBar jMenuBar;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JToolBar jToolBar;
private javax.swing.JDesktopPane jdp;
private javax.swing.JScrollPane jscp;
private javax.swing.JSplitPane jsp;
private javax.swing.JMenu menuFile;
private javax.swing.JMenu menuHelp;
private javax.swing.JMenuItem menuItemAbout;
private javax.swing.JMenuItem menuItemExit;
private javax.swing.JMenu menuNetwork;
private javax.swing.JTree tree;
// End of variables declaration @Override public void update(Observable o, Object o1) { logger.debug("update ui");
// TODO Save expand status before update and restore it after //Enumeration paths = treeModel.getExpandedNodes(tree);
Enumeration selPaths = null;
if (tree.getSelectionPath() != null) { path = tree.getSelectionPath().getParentPath();
// selPaths = tree.getExpandedDescendants(path);
treeModel.update(this.tree);
tree.updateUI();
//treeModel.setExpandedNodes(tree, paths);
graphModel.update();
visualizationViewer.updateUI();
nmif.updatePanel();
this.setPreferredSize(this.getSize());
public Point centralPosition(JInternalFrame _frame) { int x = (this.jdp.getSize().width / 2) - (_frame.getSize().width / 2);
int y = (this.jdp.getSize().height / 2) - (_frame.getSize().height / 2);
* To change this template, choose Tools | Templates * and open the template in the editor.
* ModulePropertyInternalFrame.java * Created on 18.05.2011, 17:19: package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.core.Domain;
import com.googlecode.snoopycp.model.ParamTableModel;
import com.googlecode.snoopycp.model.TimeTableModel;
import org.apache.log4j.Logger;
public class ModulePropertyInternalFrame extends javax.swing.JInternalFrame { /** Creates new form ModulePropertyInternalFrame */ Logger.getLogger(ModulePropertyInternalFrame.class);
Domain domain;
Ice.Identity ident;
String muid;
public ModulePropertyInternalFrame(Domain _domain, Ice.Identity _ident, String _muid) initComponents();
this.jTable2.setModel(new TimeTableModel(_domain, _ident, logger, _muid));
this.jTable1.setModel(new ParamTableModel(_domain, _ident, logger, _muid));
this.setClosable(true);
this.setTitle(domain.moduleName(_ident).get(muid) + "properties");
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { btnON = new javax.swing.JToggleButton();
btnOFF = new javax.swing.JToggleButton();
jLabel1 = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jScrollPane1 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
btnON.setText("ON");
btnON.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnOFF.setText("OFF");
btnOFF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
jLabel1.setText("Module status");
jTable2.setModel(new javax.swing.table.DefaultTableModel( jScrollPane1.setViewportView(jTable2);
jTabbedPane1.addTab("Schedule", jScrollPane1);
jTable1.setModel(new javax.swing.table.DefaultTableModel( jScrollPane2.setViewportView(jTable1);
jTabbedPane1.addTab("Parameters", jScrollPane2);
jButton1.setText("Close properties");
jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE).addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addContainerGap(26, Short.MAX_VALUE)) private void btnOFFActionPerformed(java.awt.event.ActionEvent evt) { if (this.btnON.isSelected()) { this.btnOFF.setSelected(true);
this.btnON.setSelected(false);
this.domain.scheduler(ident).toogle(muid);
domain.updateModules(ident);
private void btnONActionPerformed(java.awt.event.ActionEvent evt) { if (this.btnOFF.isSelected()) { this.btnON.setSelected(true);
this.btnOFF.setSelected(false);
this.domain.scheduler(ident).toogle(muid);
domain.updateModules(ident);
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { this.dispose();
// Variables declaration - do not modify private javax.swing.JToggleButton btnOFF;
private javax.swing.JToggleButton btnON;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTable jTable2;
// End of variables declaration private void initStatus() { String status = this.domain.scheduler(ident).statetable().get(muid);
if (status.equalsIgnoreCase("ON")) { this.btnON.setSelected(true);
this.btnOFF.setSelected(false);
this.btnON.setSelected(false);
this.btnOFF.setSelected(true);
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopyd.driver.IConfigurerPrx;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JOptionPane;
public class NodePropertiesInternalFrame extends javax.swing.JInternalFrame { IConfigurerPrx config;
/** Creates new form NodeInfoInternalFrame */ // FIXME change way of transfer IConfigurerPrx public NodePropertiesInternalFrame(Map _info, String _nodeName, IConfigurerPrx _config) { initComponents();
this.setClosable(true);
this.setTitle(_nodeName + " - properties");
initInfo(_info);
public NodePropertiesInternalFrame(Map _info) { initComponents();
this.setClosable(true);
this.setTitle("Properties");
initInfo(_info);
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { btnCloseProperties = new javax.swing.JButton();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
textAddressString = new javax.swing.JTextField();
btnDataSourceConfirm = new javax.swing.JButton();
jlExamplDataSourceStrting = new javax.swing.JLabel();
btnViewCurrent = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
textPort = new javax.swing.JTextField();
textBasename = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
textUsername = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
textPassword = new javax.swing.JPasswordField();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jlCPU = new javax.swing.JLabel();
jlVendor = new javax.swing.JLabel();
jlCores = new javax.swing.JLabel();
jlFrequency = new javax.swing.JLabel();
jlRAM = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jlHostname = new javax.swing.JLabel();
jlIP = new javax.swing.JLabel();
jlGateway = new javax.swing.JLabel();
jlPrimDNS = new javax.swing.JLabel();
setTitle("Properties");
btnCloseProperties.setText("Close properties");
btnCloseProperties.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClosePropertiesActionPerformed(evt);
});
jLabel7.setText("Data source:");
btnDataSourceConfirm.setText("Confirm");
btnDataSourceConfirm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDataSourceConfirmActionPerformed(evt);
});
jlExamplDataSourceStrting.setText("Basename");
btnViewCurrent.setText("View current");
btnViewCurrent.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnViewCurrentActionPerformed(evt);
jLabel8.setText("Address");
jLabel9.setText(":");
jLabel10.setText("Username");
jLabel11.setText("Password");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 112, Short.MAX_VALUE).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))))) jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(textPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jlExamplDataSourceStrting).addComponent(textBasename, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(textUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(textPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(btnDataSourceConfirm) jTabbedPane1.addTab("Configure", jPanel1);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel1.setText("Hardware info");
jLabel2.setText("CPU");
jLabel3.setText("Core");
jLabel4.setText("Frequency");
jLabel5.setText("RAM");
jLabel6.setText("Vendor");
jlCPU.setText("jLabel7");
jlVendor.setText("jLabel8");
jlCores.setText("jLabel9");
jlFrequency.setText("jLabel10");
jlRAM.setText("jLabel11");
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel12.setText("Network");
jLabel13.setText("Internet address");
jLabel14.setText("Default gateway");
jLabel15.setText("Primary DNS");
jLabel16.setText("Hostname");
jlHostname.setText("jLabel17");
jlIP.setText("jLabel18");
jlGateway.setText("jLabel19");
jlPrimDNS.setText("jLabel20");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addContainerGap(10, Short.MAX_VALUE)) jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(jPanel2Layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addContainerGap(41, Short.MAX_VALUE)) jTabbedPane1.addTab("NodeInfo", jPanel2);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap(199, Short.MAX_VALUE).addComponent(btnCloseProperties).addGroup(layout.createSequentialGroup().addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(11, Short.MAX_VALUE)) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnCloseProperties) jTabbedPane1.getAccessibleContext().setAccessibleName("Configure");
jTabbedPane1.getAccessibleContext().setAccessibleDescription("Configure");
private void btnClosePropertiesActionPerformed(java.awt.event.ActionEvent evt) { this.dispose();
private void btnDataSourceConfirmActionPerformed(java.awt.event.ActionEvent evt) { if (!this.textAddressString.getText().equalsIgnoreCase("") && !this.textPort.getText().equalsIgnoreCase("") !this.textUsername.getText().equalsIgnoreCase("")) { //String sourceString = this.textDataSourceString.getText();
String address = this.textAddressString.getText();
String port = this.textPort.getText();
String basename = this.textBasename.getText();
String username = this.textUsername.getText();
String password = new String(this.textPassword.getPassword());
map.put("connectionstring", url);
} catch (Ice.ConnectionRefusedException e) { JOptionPane.showInternalMessageDialog(this, "Node not avalibele more " + e.getMessage());
JOptionPane.showInternalMessageDialog(this, "Some field is empty");
private void btnViewCurrentActionPerformed(java.awt.event.ActionEvent evt) { string = config.configuration().get("connectionstring");
String[] strings = string.split("/");
String[] tmp = strings[3].split("=");
String basename = tmp[0].substring(0, tmp[0].length() - 5);
String user = tmp[1].split("&")[0];
String str = "\naddress: " + address + "\nbasename: " + basename JOptionPane.showInternalMessageDialog(this, str, "Current data source string", JOptionPane.INFORMATION_MESSAGE);
} catch (Ice.ConnectionRefusedException e) { JOptionPane.showInternalMessageDialog(this, "Node not avalibele more " + e.getMessage());
} catch (ArrayIndexOutOfBoundsException e) { JOptionPane.showInternalMessageDialog(this, string, "Current data source string", JOptionPane.INFORMATION_MESSAGE);
// Variables declaration - do not modify private javax.swing.JButton btnCloseProperties;
private javax.swing.JButton btnDataSourceConfirm;
private javax.swing.JButton btnViewCurrent;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel jlCPU;
private javax.swing.JLabel jlCores;
private javax.swing.JLabel jlExamplDataSourceStrting;
private javax.swing.JLabel jlFrequency;
private javax.swing.JLabel jlGateway;
private javax.swing.JLabel jlHostname;
private javax.swing.JLabel jlIP;
private javax.swing.JLabel jlPrimDNS;
private javax.swing.JLabel jlRAM;
private javax.swing.JLabel jlVendor;
private javax.swing.JTextField textAddressString;
private javax.swing.JTextField textBasename;
private javax.swing.JPasswordField textPassword;
private javax.swing.JTextField textPort;
private javax.swing.JTextField textUsername;
// End of variables declaration private void initInfo(Map _info) { this.jlCPU.setText(_info.get("Model"));// FIXME may be very long name this.jlCores.setText(_info.get("TotalCores"));
this.jlVendor.setText(_info.get("Vendor"));
this.jlFrequency.setText(_info.get("Mhz") + " MHz");
this.jlRAM.setText(_info.get("Free").substring(0, 3) + " / " + _info.get("Ram") + " MB");
this.jlHostname.setText(_info.get("HostName"));
this.jlIP.setText(_info.get("IP"));
this.jlGateway.setText(_info.get("DefaultGateway"));
this.jlPrimDNS.setText(_info.get("PrimaryDns"));
/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import com.googlecode.snoopycp.core.Domain;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import org.apache.log4j.Logger;
public class NotepadInternalFrame extends javax.swing.JInternalFrame { private Logger logger = Logger.getLogger(NotepadInternalFrame.class);
private JTextArea editArea;
private JFileChooser fileChooser = new JFileChooser();
//... Create actions for menu items, buttons,...
private Action openAction = new OpenAction();
private Action saveAction = new SaveAction();
private Action exitAction = new ExitAction(this);
private Domain domain;
//============================================================== constructor public NotepadInternalFrame(Domain _domain) { initComponents();
//... Create scrollable text area.
editArea = new JTextArea(15, 80);
editArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
editArea.setFont(new Font("monospaced", Font.PLAIN, 14));
//System.out.println("editArea are configured");
JScrollPane scrollingText = new JScrollPane(editArea);
//System.out.println("editArea added to scrollpane");
//this.jScrollPane1.setViewportView(editArea);
//-- Create a content pane, set layout, add component.
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
content.add(scrollingText, BorderLayout.CENTER);
this.menuItemOpen.setAction(openAction);
this.menuItemSave.setAction(saveAction);
this.menuItemClose.setAction(exitAction);
//... Set window content and menu.
setContentPane(content);
//... Set other window characteristics.
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Notepad");
//setLocationRelativeTo(null);
setClosable(true);
setResizable(true);
setMaximizable(true);
public void deploy(Object[] hosts, boolean _activate, String _schedule, String _params) { Ice.Identity ident = domain.enviroment().get(hos);
String muid = java.util.UUID.randomUUID().toString();
domain.moduler(ident).ice_ping();
domain.moduler(ident).deploy(muid, editArea.getText());
String[] scheduleArray = _schedule.split(";");
int[] delay = new int[scheduleArray.length];
long[] delays = new long[scheduleArray.length];
delay[i] = Integer.parseInt(scheduleArray[i]);
domain.scheduler(ident).ice_ping();
domain.scheduler(ident).schedule(muid, delays, _params.split(";"));
domain.scheduler(ident).toogle(muid);
domain.updateModules(ident);
} catch (Ice.ConnectionRefusedException e) { logger.warn("Problem with deploy on remote node " + hos + e.getMessage());
////////////////////////////////////////////////// inner class OpenAction class OpenAction extends AbstractAction { //============================================= constructor public OpenAction() { putValue(MNEMONIC_KEY, new Integer('O'));
//========================================= actionPerformed public void actionPerformed(ActionEvent e) { int retval = fileChooser.showOpenDialog(NotepadInternalFrame.this);
if (retval == JFileChooser.APPROVE_OPTION) { File f = fileChooser.getSelectedFile();
editArea.read(reader, ""); // Use TextComponent read //////////////////////////////////////////////////// inner class SaveAction class SaveAction extends AbstractAction { //============================================= constructor super("Save...");
putValue(MNEMONIC_KEY, new Integer('S'));
//========================================= actionPerformed @Override public void actionPerformed(ActionEvent e) { int retval = fileChooser.showSaveDialog(NotepadInternalFrame.this);
if (retval == JFileChooser.APPROVE_OPTION) { File f = fileChooser.getSelectedFile();
editArea.write(writer); // Use TextComponent write JOptionPane.showMessageDialog(NotepadInternalFrame.this, ioex);
///////////////////////////////////////////////////// inner class ExitAction class ExitAction extends AbstractAction { JInternalFrame frame;
//============================================= constructor private ExitAction(JInternalFrame aThis) { super("Exit");
putValue(MNEMONIC_KEY, new Integer('X'));
//========================================= actionPerformed @Override public void actionPerformed(ActionEvent e) { frame.dispose();
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane();
menuBar = new javax.swing.JMenuBar();
menuFile = new javax.swing.JMenu();
menuItemOpen = new javax.swing.JMenuItem();
menuItemSave = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
menuItemDeploy = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
menuItemClose = new javax.swing.JMenuItem();
menuFile.setText("File");
menuItemOpen.setText("Open");
menuFile.add(menuItemOpen);
menuItemSave.setText("Save");
menuFile.add(menuItemSave);
menuFile.add(jSeparator2);
menuItemDeploy.setText("Deploy");
menuItemDeploy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuItemDeployActionPerformed(evt);
menuFile.add(menuItemDeploy);
menuFile.add(jSeparator1);
menuItemClose.setText("Exit");
menuFile.add(menuItemClose);
menuBar.add(menuFile);
setJMenuBar(menuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) private void menuItemDeployActionPerformed(java.awt.event.ActionEvent evt) { ChooseModuleInternalFrame cmif = new ChooseModuleInternalFrame(domain, this);
this.getParent().add(cmif);
// Variables declaration - do not modify private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenu menuFile;
private javax.swing.JMenuItem menuItemClose;
private javax.swing.JMenuItem menuItemDeploy;
private javax.swing.JMenuItem menuItemOpen;
private javax.swing.JMenuItem menuItemSave;
// End of variables declaration /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import javax.swing.table.AbstractTableModel;
public class Results extends javax.swing.JInternalFrame { /** Creates new form Results */ public Results(AbstractTableModel _tm, String _name) { initComponents();
this.jTable1.setModel(_tm);
this.setTitle(_name + " results");
this.setClosable(true);
this.setResizable(true);
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
@SuppressWarnings("unchecked") private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
btnClose = new javax.swing.JButton();
jTable1.setModel(new javax.swing.table.DefaultTableModel( jScrollPane1.setViewportView(jTable1);
btnClose.setText("Close results");
btnClose.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCloseActionPerformed(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(302, Short.MAX_VALUE) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) { this.dispose();
// Variables declaration - do not modify private javax.swing.JButton btnClose;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
package com.googlecode.snoopycp.ui;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import java.awt.GridLayout;
public class netMapIFrame extends javax.swing.JInternalFrame { /** Creates new form netMapIFrame */ public netMapIFrame() { initComponents();
this.setClosable(true);
this.setResizable(true);
this.setMaximizable(true);
this.setTitle("Network Map");
this.graphPanel.setLayout(new GridLayout(1, 1));
public void add(VisualizationViewer _add){ this.graphPanel.add(_add);
public void updatePanel() { this.graphPanel.updateUI();
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.