Search in sources :

Example 31 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class OpenCopyLogDBLogAction method run.

/**
	 * open apply database log
	 * 
	 * @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;
    }
    DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) objArr[0];
    DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
    HostNode hostNode = dbNode.getParent();
    ServerInfo serverInfo = hostNode.getServerInfo();
    CubridServer server = new CubridServer(serverInfo.getHostAddress(), serverInfo.getHostAddress(), null, null);
    server.setServerInfo(serverInfo);
    LogInfo logInfo = new LogInfo();
    String logPath = serverInfo.getEnvInfo().getRootDir() + serverInfo.getPathSeparator() + "log" + serverInfo.getPathSeparator();
    String fileName = dbNode.getDbName() + "@" + hostNode.getHostStatusInfo().getMasterHostStatusInfo().getHostName() + "_copylogdb.err";
    logInfo.setPath(logPath + fileName);
    DefaultCubridNode dbLogInfoNode = new DefaultCubridNode(dbNode.getDbName() + ICubridNodeLoader.NODE_SEPARATOR + "copy_database_log", logInfo.getName(), "icons/navigator/log_item.png");
    dbLogInfoNode.setType(CubridNodeType.LOGS_COPY_DATABASE_LOG);
    dbLogInfoNode.setModelObj(logInfo);
    dbLogInfoNode.setEditorId(LogEditorPart.ID);
    dbLogInfoNode.setContainer(false);
    dbLogInfoNode.setServer(server);
    LogViewAction action = (LogViewAction) ActionManager.getInstance().getAction(LogViewAction.ID);
    action.setCubridNode(dbLogInfoNode);
    action.run();
}
Also used : LogViewAction(com.cubrid.cubridmanager.ui.logs.action.LogViewAction) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 32 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class OpenDatabaseLogAction method isSupported.

/**
	 * only support database monitor and database must be connected.
	 * 
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java.lang.Object)
	 * @param obj Object must be DatabaseMonitorPart
	 * @return is supported.
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof DatabaseMonitorPart) {
        DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) obj;
        DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
        HostNode hostNode = dbNode.getParent();
        if (hostNode != null && hostNode.getServerInfo() != null && hostNode.getServerInfo().isConnected()) {
            return true;
        }
    }
    return false;
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 33 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class OpenDatabaseLogAction method run.

/**
	 * open database log
	 * 
	 * @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;
    }
    DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) objArr[0];
    DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
    String dbName = dbNode.getDbName();
    HostNode hostNode = dbNode.getParent();
    ServerInfo serverInfo = hostNode.getServerInfo();
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    DatabaseLogListDialog dialog = new DatabaseLogListDialog(shell, dbName, serverInfo);
    dialog.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseLogListDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.DatabaseLogListDialog) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 34 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class DeleteDatabaseMonitorAction method run.

/**
	 * delete database monitor from dashboard.
	 */
public void run() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    DatabaseMonitorPart dmp = (DatabaseMonitorPart) selection.getFirstElement();
    //EditPart dashboardPart = dmp.getParent();
    DatabaseNode dn = (DatabaseNode) dmp.getModel();
    boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteDatabase, dn.getName()));
    if (!isDelete) {
        return;
    }
    dn.getParent().removeDbNode(dn);
//dashboardPart.refresh();
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 35 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode 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);
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) ClientNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode) BrokerDBListNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic)

Aggregations

DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)36 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)14 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)11 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)5 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Point (org.eclipse.draw2d.geometry.Point)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 RowLayout (org.eclipse.swt.layout.RowLayout)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)3