use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.
the class AddBrokerMonitorAction method run.
/**
* open add broker monitor dialog.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
HostMonitorPart hostMonPart = (HostMonitorPart) objArr[0];
HostNode hostNode = (HostNode) hostMonPart.getModel();
Dashboard dashboard = (Dashboard) hostMonPart.getParent().getModel();
if (hostNode != null && dashboard != null) {
AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, dashboard.getHostNodeList(), 2);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(dashboard, addedHostNodeList);
HAUtil.calcLocation(dashboard.getHostNodeList());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.
the class AddHostMonitorAction method run.
/**
* Open add host monitor dialog.
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
DashboardPart dp = (DashboardPart) objArr[0];
Dashboard dashboard = (Dashboard) dp.getModel();
if (dashboard != null) {
AddHostAndDbWizard wizard = new AddHostAndDbWizard(null, dashboard.getHostNodeList(), 0);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(dashboard, addedHostNodeList);
HAUtil.calcLocation(dashboard.getHostNodeList());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.
the class EditMonitorDashboardAction method run.
/**
* Open the selected monitoring dash board
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) objArr[0];
Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
if (dashboard == null) {
return;
}
AddDashboardDialog dialog = new AddDashboardDialog(getShell());
dialog.setDashboard(dashboard);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
node.setId(dashboard.getName());
node.setLabel(dashboard.getName());
MonitorDashboardPersistManager.getInstance().saveDashboard();
ISelectionProvider provider = getSelectionProvider();
if (provider instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) provider;
treeViewer.refresh(node, true);
}
IEditorPart part = LayoutUtil.getEditorPart(node, node.getEditorId());
if (part instanceof MonitorDashboardEditor) {
((MonitorDashboardEditor) part).changePartName(dashboard.getName());
}
} else {
for (int i = 0; i < dashboard.getHostNodeList().size(); i++) {
HostNode hostNode = dashboard.getHostNodeList().get(i);
hostNode.getCopyedHaNodeList().clear();
hostNode.getCopyedHaNodeList().addAll(hostNode.getDbNodeList());
hostNode.getCopyedHaNodeList().addAll(hostNode.getBrokerNodeList());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.
the class AddMonitorDashboardAction method run.
/**
* Open the dialog
*/
public void run() {
AddDashboardDialog dialog = new AddDashboardDialog(getShell());
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
Dashboard dashboard = dialog.getDashboard();
DefaultCubridNode dashboardNode = new DefaultCubridNode(dashboard.getName(), dashboard.getName(), "icons/navigator/status_item.png");
dashboardNode.setType(CubridNodeType.MONITOR_DASHBOARD);
dashboardNode.setEditorId(MonitorDashboardEditor.ID);
dashboardNode.setModelObj(dashboard);
MonitorDashboardPersistManager.getInstance().addMonitorDashboard(dashboardNode);
ISelectionProvider provider = getSelectionProvider();
if (provider instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) provider;
/*TOOLS-3665 Refresh the input of TreeViewer*/
treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(dashboardNode, CubridNodeChangedEventType.NODE_ADD));
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(dashboardNode);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.
the class MonitorDashboardPersistManager method saveDashboard.
/**
*
* Save dash boards
*
*/
public void saveDashboard() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("dashboards");
Iterator<ICubridNode> iterator = monitorDashboardList.iterator();
while (iterator.hasNext()) {
ICubridNode node = (ICubridNode) iterator.next();
if (node instanceof MonitorStatistic) {
continue;
}
Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
IXMLMemento dashboardChild = memento.createChild("dashboard");
dashboardChild.putString("name", node.getName());
Iterator<HostNode> nodeIte = dashboard.getHostNodeList().iterator();
while (nodeIte.hasNext()) {
//save host node
HostNode hostNode = nodeIte.next();
IXMLMemento hostNodeChild = dashboardChild.createChild("host");
hostNodeChild.putString("aliasname", hostNode.getName());
hostNodeChild.putString("ip", hostNode.getIp());
hostNodeChild.putString("port", hostNode.getPort());
hostNodeChild.putString("username", hostNode.getUserName());
hostNodeChild.putString("password", CipherUtils.encrypt(hostNode.getPassword()));
hostNodeChild.putString("location", hostNode.getLocation().x + "," + hostNode.getLocation().y);
hostNodeChild.putString("visible", hostNode.isVisible() ? "true" : "false");
//save the database node list
List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
Iterator<DatabaseNode> dbNodeIte = dbNodeList.iterator();
while (dbNodeIte.hasNext()) {
DatabaseNode dbNode = (DatabaseNode) dbNodeIte.next();
IXMLMemento databaseNodeChild = hostNodeChild.createChild("database");
databaseNodeChild.putString("aliasname", dbNode.getName());
databaseNodeChild.putString("dbname", dbNode.getDbName());
databaseNodeChild.putString("username", dbNode.getDbUser());
databaseNodeChild.putString("password", CipherUtils.encrypt(dbNode.getDbPassword()));
databaseNodeChild.putString("location", dbNode.getLocation().x + "," + dbNode.getLocation().y);
}
//save broker node list
List<BrokerNode> brokerNodeList = hostNode.getBrokerNodeList();
Iterator<BrokerNode> brokerNodeIte = brokerNodeList.iterator();
while (brokerNodeIte.hasNext()) {
BrokerNode brokerNode = (BrokerNode) brokerNodeIte.next();
IXMLMemento brokerNodeChild = hostNodeChild.createChild("broker");
brokerNodeChild.putString("aliasname", brokerNode.getName());
brokerNodeChild.putString("brokername", brokerNode.getBrokerName());
brokerNodeChild.putString("location", brokerNode.getLocation().x + "," + brokerNode.getLocation().y);
//save the client IP list
ClientNode ipListNode = dashboard.getClientNodeByBroker(brokerNode);
Point point = null;
String clientIpName = null;
if (ipListNode == null) {
brokerNodeChild.putString("show_ip_list", "false");
point = brokerNode.getClientsLocation();
} else {
brokerNodeChild.putString("show_ip_list", ipListNode.isVisible() ? "true" : "false");
point = ipListNode.getLocation();
clientIpName = ipListNode.getName();
}
if (point != null) {
brokerNodeChild.putString("client_ip_location", point.x + "," + point.y);
}
if (clientIpName != null) {
brokerNodeChild.putString("client_ip_name", clientIpName);
}
//save the database list
BrokerDBListNode dbListNode = dashboard.getBrokerDBListNodeByBroker(brokerNode);
String clientDbName = null;
if (dbListNode == null) {
brokerNodeChild.putString("show_db_list", "false");
point = brokerNode.getDatabasesLocation();
} else {
brokerNodeChild.putString("show_db_list", dbListNode.isVisible() ? "true" : "false");
point = dbListNode.getLocation();
clientDbName = dbListNode.getName();
}
if (point != null) {
brokerNodeChild.putString("client_db_location", point.x + "," + point.y);
}
if (clientDbName != null) {
brokerNodeChild.putString("client_db_name", clientDbName);
}
}
}
}
PersistUtils.saveXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_DASHBOARD_XML_CONTENT, memento);
}
}
Aggregations