Search in sources :

Example 51 with ICubridNode

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

the class AddDashboardDialog method verify.

/**
	 * 
	 * Verify data
	 * 
	 */
private void verify() {
    String dashboardName = dashboardNameText.getText();
    if (dashboardName.trim().length() == 0) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        setErrorMessage(Messages.errDashboardName);
        return;
    }
    List<ICubridNode> dashboardList = MonitorDashboardPersistManager.getInstance().getAllMonitorDashboards();
    for (int i = 0; i < dashboardList.size(); i++) {
        ICubridNode node = dashboardList.get(i);
        if (dashboardName.equals(node.getLabel()) && (dashboard == null || !dashboard.getName().equals(dashboardName))) {
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            setErrorMessage(Messages.errDashboardNameExist);
            return;
        }
    }
    /*TOOLS-3672 Avoid to dashboard node and statistic node have the same name*/
    List<MonitorStatistic> monitorList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(null);
    for (MonitorStatistic monitorStatistic : monitorList) {
        if (dashboardName.equals(monitorStatistic.getId())) {
            if (dashboardName.equals(monitorStatistic.getLabel())) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
                setErrorMessage(Messages.errDashboardNameExist);
                return;
            }
        }
    }
    if (hostNodeList.isEmpty()) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        setErrorMessage(Messages.errHostAndDbList);
        return;
    }
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    setErrorMessage(null);
}
Also used : MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 52 with ICubridNode

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

the class StartRetargetAction method run.

/**
	 * start database or broker
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        return;
    }
    ICubridNode node = (ICubridNode) obj[0];
    if (NodeType.SERVER.equals(node.getType())) {
        StartServiceAction startServiceAction = (StartServiceAction) ActionManager.getInstance().getAction(StartServiceAction.ID);
        startServiceAction.run();
    }
    if (node instanceof ISchemaNode) {
        StartDatabaseAction startDatabaseAction = (StartDatabaseAction) ActionManager.getInstance().getAction(StartDatabaseAction.ID);
        startDatabaseAction.run();
    }
    if (node instanceof CubridBroker) {
        StartBrokerAction startBrokerAction = (StartBrokerAction) ActionManager.getInstance().getAction(StartBrokerAction.ID);
        startBrokerAction.run();
    }
    if (node instanceof CubridBrokerFolder) {
        StartBrokerEnvAction startBrokerEnvAction = (StartBrokerEnvAction) ActionManager.getInstance().getAction(StartBrokerEnvAction.ID);
        startBrokerEnvAction.run();
    }
}
Also used : StartBrokerEnvAction(com.cubrid.cubridmanager.ui.broker.action.StartBrokerEnvAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) StartBrokerAction(com.cubrid.cubridmanager.ui.broker.action.StartBrokerAction) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) StartDatabaseAction(com.cubrid.cubridmanager.ui.cubrid.database.action.StartDatabaseAction) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Example 53 with ICubridNode

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

the class StartServiceAction method isSupported.

/**
	 * 
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj the Object
	 * @return <code>true</code> if support this object;<code>false</code>
	 *         otherwise
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        CubridServer server = node.getServer();
        if (server == null) {
            return false;
        }
        ServerInfo serverInfo = server.getServerInfo();
        ServerType serverType = serverInfo == null ? null : serverInfo.getServerType();
        if (serverType == null || serverType == ServerType.BROKER) {
            return false;
        }
        if (server != null && server.isConnected() && serverInfo != null && serverInfo.getLoginedUserInfo() != null && serverInfo.getLoginedUserInfo().isAdmin()) {
            return true;
        }
    }
    return false;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 54 with ICubridNode

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

the class StopRetargetAction method run.

/**
	 * stop database or broker
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        return;
    }
    ICubridNode node = (ICubridNode) obj[0];
    if (NodeType.SERVER.equals(node.getType())) {
        StopServiceAction stopServiceAction = (StopServiceAction) ActionManager.getInstance().getAction(StopServiceAction.ID);
        stopServiceAction.run();
    }
    if (node instanceof ISchemaNode) {
        StopDatabaseAction stopDatabaseAction = (StopDatabaseAction) ActionManager.getInstance().getAction(StopDatabaseAction.ID);
        stopDatabaseAction.run();
    }
    if (node instanceof CubridBroker) {
        StopBrokerAction stopBrokerAction = (StopBrokerAction) ActionManager.getInstance().getAction(StopBrokerAction.ID);
        stopBrokerAction.run();
    }
    if (node instanceof CubridBrokerFolder) {
        StopBrokerEnvAction stopBrokerEnvAction = (StopBrokerEnvAction) ActionManager.getInstance().getAction(StopBrokerEnvAction.ID);
        stopBrokerEnvAction.run();
    }
}
Also used : StopBrokerEnvAction(com.cubrid.cubridmanager.ui.broker.action.StopBrokerEnvAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) StopDatabaseAction(com.cubrid.cubridmanager.ui.cubrid.database.action.StopDatabaseAction) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder) StopBrokerAction(com.cubrid.cubridmanager.ui.broker.action.StopBrokerAction)

Example 55 with ICubridNode

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

the class BrokerEnvStatusView method nodeChanged.

/**
	 * Response to cubrid node changes
	 *
	 * @param event the event
	 */
public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode eventNode = event.getCubridNode();
    if (eventNode == null || this.cubridNode == null) {
        return;
    }
    //if it is not in the same host,return
    if (!eventNode.getServer().getId().equals(this.cubridNode.getServer().getId())) {
        return;
    }
    //if changed node is not broker folder or server,return
    String type = eventNode.getType();
    if (!CubridNodeType.BROKER_FOLDER.equals(type) && !CubridNodeType.SERVER.equals(type)) {
        return;
    }
    synchronized (this) {
        if (type == NodeType.SERVER) {
            String id = eventNode.getId();
            CubridBrokerFolder currentNode = (CubridBrokerFolder) eventNode.getChild(id);
            this.cubridNode = currentNode;
        } else {
            this.cubridNode = eventNode;
        }
        if (this.cubridNode == null || !((CubridBrokerFolder) eventNode).isRunning()) {
            setRunflag(false);
            this.setTitleImage(CubridManagerUIPlugin.getImage("icons/navigator/broker_group.png"));
            return;
        } else {
            setRunflag(true);
            this.setTitleImage(CubridManagerUIPlugin.getImage("icons/navigator/broker_service_started.png"));
        }
        refresh(true, false);
    }
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22