Search in sources :

Example 36 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class ShowHostSystemMonitorHistoryAction method run.

/**
	 * Override the run method in order to complete adding a monitor template
	 *
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode parent = (ICubridNode) obj[0];
    String hostSysMonHistoryId = parent.getId() + NODE_SEPARATOR + HOST_SYSMON_HISTORY_ID;
    ICubridNode hostSysMonHistoryNode = new DefaultCubridNode(hostSysMonHistoryId, Messages.msgBrokerHistoryStatusName, "icons/navigator/status_item.png");
    hostSysMonHistoryNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
    hostSysMonHistoryNode.setViewId(HostSystemMonitorHistoryViewPart.ID);
    hostSysMonHistoryNode.setContainer(false);
    LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(hostSysMonHistoryNode);
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 37 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class DatabaseLogListDialog method openLogEditor.

/**
	 * 
	 * Open the log editor and show the selected log
	 * 
	 */
@SuppressWarnings("unchecked")
protected void openLogEditor() {
    StructuredSelection selection = (StructuredSelection) dbLogTableViewer.getSelection();
    if (selection == null || selection.isEmpty()) {
        return;
    }
    Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
    LogInfo logInfo = (LogInfo) map.get("1");
    CubridServer server = new CubridServer(serverInfo.getHostAddress(), serverInfo.getHostAddress(), null, null);
    server.setServerInfo(serverInfo);
    DefaultCubridNode dbLogInfoNode = new DefaultCubridNode(dbName + ICubridNodeLoader.NODE_SEPARATOR + "database_log", logInfo.getName(), "icons/navigator/log_item.png");
    dbLogInfoNode.setType(CubridNodeType.LOGS_SERVER_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();
    super.buttonPressed(IDialogConstants.OK_ID);
}
Also used : LogViewAction(com.cubrid.cubridmanager.ui.logs.action.LogViewAction) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 38 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode 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 39 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode 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);
        }
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) AddDashboardDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 40 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class MonitorDashboardPersistManager method loadMonitorDashboard.

/**
	 * 
	 * Load monitor dash board
	 * 
	 */
protected void loadMonitorDashboard() {
    synchronized (this) {
        IXMLMemento memento = PersistUtils.getXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_DASHBOARD_XML_CONTENT);
        if (memento != null) {
            IXMLMemento[] children = memento.getChildren("dashboard");
            for (int i = 0; i < children.length; i++) {
                Dashboard dashboard = new Dashboard();
                String dashBoardName = children[i].getString("name");
                dashboard.setName(dashBoardName);
                IXMLMemento[] hostChildren = children[i].getChildren("host");
                for (int j = 0; hostChildren != null && j < hostChildren.length; j++) {
                    //load the host node
                    String aliasName = hostChildren[j].getString("aliasname");
                    String userName = hostChildren[j].getString("username");
                    String password = hostChildren[j].getString("password");
                    String ip = hostChildren[j].getString("ip");
                    String port = hostChildren[j].getString("port");
                    String location = hostChildren[j].getString("location");
                    String visible = hostChildren[j].getString("visible");
                    HostNode hostNode = new HostNode();
                    if (aliasName == null || aliasName.trim().length() == 0) {
                        aliasName = ip + ":" + port;
                    }
                    hostNode.setName(aliasName);
                    hostNode.setIp(ip);
                    hostNode.setPort(port);
                    hostNode.setUserName(userName);
                    hostNode.setPassword(CipherUtils.decrypt(password));
                    if (location != null && location.trim().length() > 0) {
                        String[] locations = location.split(",");
                        hostNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
                    }
                    if ("true".equals(visible)) {
                        hostNode.setVisible(true);
                    } else {
                        hostNode.setVisible(false);
                    }
                    dashboard.addNode(hostNode);
                    //load the database node list
                    IXMLMemento[] databaseChildren = hostChildren[j].getChildren("database");
                    for (int k = 0; databaseChildren != null && k < databaseChildren.length; k++) {
                        aliasName = databaseChildren[k].getString("aliasname");
                        String dbName = databaseChildren[k].getString("dbname");
                        String dbUserName = databaseChildren[k].getString("username");
                        String dbPassword = databaseChildren[k].getString("password");
                        String dbLocation = databaseChildren[k].getString("location");
                        if (aliasName == null || aliasName.trim().length() == 0) {
                            aliasName = dbName;
                        }
                        DatabaseNode databaseNode = new DatabaseNode();
                        databaseNode.setName(aliasName);
                        databaseNode.setDbUser(dbUserName);
                        databaseNode.setDbPassword(CipherUtils.decrypt(dbPassword));
                        databaseNode.setDbName(dbName);
                        databaseNode.setParent(hostNode);
                        hostNode.addDbNode(databaseNode);
                        if (dbLocation != null && dbLocation.trim().length() > 0) {
                            String[] locations = dbLocation.split(",");
                            databaseNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
                        }
                    }
                    //load the broker node list
                    IXMLMemento[] brokerChildren = hostChildren[j].getChildren("broker");
                    for (int k = 0; brokerChildren != null && k < brokerChildren.length; k++) {
                        aliasName = brokerChildren[k].getString("aliasname");
                        String brokerName = brokerChildren[k].getString("brokername");
                        String brokerLocation = brokerChildren[k].getString("location");
                        if (aliasName == null || aliasName.trim().length() == 0) {
                            aliasName = brokerName;
                        }
                        BrokerNode brokerNode = new BrokerNode();
                        brokerNode.setName(aliasName);
                        brokerNode.setBrokerName(brokerName);
                        brokerNode.setParent(hostNode);
                        hostNode.addBrokerNode(brokerNode);
                        //load the client IP list
                        String clientIpName = brokerChildren[k].getString("client_ip_name");
                        String clientIpLocation = brokerChildren[k].getString("client_ip_location");
                        String showIpList = brokerChildren[k].getString("show_ip_list");
                        if (brokerLocation != null && brokerLocation.trim().length() > 0) {
                            String[] locations = brokerLocation.split(",");
                            brokerNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
                        }
                        String[] locations = clientIpLocation == null ? new String[] { "0", "0" } : clientIpLocation.split(",");
                        ClientNode ipListNode = new ClientNode();
                        ipListNode.setBrokerNode(brokerNode);
                        ipListNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
                        if (clientIpName != null && clientIpName.trim().length() > 0) {
                            ipListNode.setName(clientIpName);
                        }
                        if ("true".equals(showIpList)) {
                            ipListNode.setVisible(true);
                        } else {
                            ipListNode.setVisible(false);
                        }
                        dashboard.addClientNode(ipListNode);
                        //load the client database list
                        String clientDbName = brokerChildren[k].getString("client_db_name");
                        String clientDbLocation = brokerChildren[k].getString("client_db_location");
                        String showDbList = brokerChildren[k].getString("show_db_list");
                        locations = clientDbLocation == null ? new String[] { "0", "0" } : clientDbLocation.split(",");
                        BrokerDBListNode dbListNode = new BrokerDBListNode();
                        dbListNode.setBrokerNode(brokerNode);
                        dbListNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
                        if (clientDbName != null && clientDbName.trim().length() > 0) {
                            dbListNode.setName(clientDbName);
                        }
                        if ("true".equals(showDbList)) {
                            dbListNode.setVisible(true);
                        } else {
                            dbListNode.setVisible(false);
                        }
                        dashboard.addBrokerDBListNode(dbListNode);
                    }
                }
                DefaultCubridNode dashboardNode = new DefaultCubridNode(dashBoardName, dashBoardName, "icons/navigator/status_item.png");
                dashboardNode.setType(CubridNodeType.MONITOR_DASHBOARD);
                dashboardNode.setEditorId(MonitorDashboardEditor.ID);
                dashboardNode.setModelObj(dashboard);
                monitorDashboardList.add(dashboardNode);
            }
        }
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) 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) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)

Aggregations

DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)41 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)17 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)12 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)12 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)12 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 IEditorPart (org.eclipse.ui.IEditorPart)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 DelAllLogTask (com.cubrid.cubridmanager.core.logs.task.DelAllLogTask)5 ArrayList (java.util.ArrayList)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)4 BrokerLogInfos (com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos)4 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2