Search in sources :

Example 1 with DatabaseNode

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

the class SelectDbPage method isDbNodeExist.

/**
	 * 
	 * Check whether this DatabaseNode already exist
	 * 
	 * @param dbNode The DatabaseNode
	 * @return boolean
	 */
private boolean isDbNodeExist(DatabaseNode dbNode) {
    HostNode hostNode = dbNode.getParent();
    for (int i = 0; i < dbNodeList.size(); i++) {
        Map<String, Object> map = dbNodeList.get(i);
        HostNode hostNode1 = (HostNode) map.get("6");
        DatabaseNode dbNode1 = (DatabaseNode) map.get("7");
        if (com.cubrid.common.core.util.StringUtil.isIpEqual(hostNode1.getIp(), hostNode.getIp()) && hostNode.getPort().equals(hostNode1.getPort()) && hostNode.getUserName().equals(hostNode1.getUserName()) && dbNode.getDbName().equals(dbNode1.getDbName())) {
            return true;
        }
    }
    return false;
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Example 2 with DatabaseNode

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

the class ConnectHostJobExecutor method done.

/**
	 * 
	 * Finish the task executor
	 * 
	 * @param status IStatus
	 */
private void done(final IStatus status) {
    if (!hostNode.isConnecting()) {
        hostNode.setConnected(false);
        return;
    }
    if (status == Status.OK_STATUS) {
        hostNode.setPort(String.valueOf(serverInfo.getHostMonPort()));
        hostNode.setPassword(serverInfo.getUserPassword());
        hostNode.setHostStatusInfo(haHostStatusInfo);
        hostNode.setConnected(true);
        if (haHostStatusInfo == null) {
            haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
        }
        for (DatabaseNode dn : hostNode.getDbNodeList()) {
            dn.setHaDatabaseStatus(HAUtil.getHADatabaseStatusInfo(dn.getDbName(), haHostStatusInfo, serverInfo));
        }
        for (BrokerNode brokerNode : hostNode.getBrokerNodeList()) {
            BrokerInfo brokerInfo = HAUtil.getBrokerInfo(serverInfo.getBrokerInfos(), brokerNode.getBrokerName());
            brokerNode.setBrokerInfo(brokerInfo);
        }
    } else {
        hostNode.setConnected(wasConnected);
        if (errorMsg != null) {
            hostNode.setErrorMsg(errorMsg);
        }
    }
    hostNode.setConnecting(false);
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 3 with DatabaseNode

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

the class AddHADatabaseDialog method getDbNodeList.

/**
	 * 
	 * Get added database node list
	 * 
	 * @return The List<DatabaseNode>
	 */
public List<DatabaseNode> getDbNodeList() {
    List<DatabaseNode> nodeList = new ArrayList<DatabaseNode>();
    for (int i = 0; i < dbNodeList.size(); i++) {
        DatabaseNode dbNode = (DatabaseNode) dbNodeList.get(i).get("5");
        nodeList.add(dbNode);
    }
    return nodeList;
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ArrayList(java.util.ArrayList)

Example 4 with DatabaseNode

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

the class ShowHostAction method run.

/**
	 * Create a new figure in dashboard.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    List<HostNode> hosts = new ArrayList<HostNode>();
    EditPart root = null;
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof DatabaseMonitorPart) {
            DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
            DatabaseNode dn = ((DatabaseNode) cmp.getModel());
            if (!hosts.contains(dn.getParent())) {
                hosts.add(dn.getParent());
            }
            root = cmp.getParent();
        } else if (objSelected instanceof BrokerMonitorPart) {
            BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
            BrokerNode bn = ((BrokerNode) cmp.getModel());
            if (!hosts.contains(bn.getParent())) {
                hosts.add(bn.getParent());
            }
            root = cmp.getParent();
        }
    }
    for (HostNode host : hosts) {
        if (host.isVisible() == isChecked()) {
            continue;
        }
        host.setVisible(isChecked());
    }
    if (root != null) {
        root.refresh();
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) ArrayList(java.util.ArrayList) EditPart(org.eclipse.gef.EditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 5 with DatabaseNode

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

the class AddDashboardDialog method createDbTree.

/**
	 * 
	 * Create table area
	 * 
	 * @param parent the parent composite
	 */
private void createDbTree(Composite parent) {
    Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.lblDashboardInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    tipLabel.setLayoutData(gridData);
    dbTv = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    {
        dbTree = dbTv.getTree();
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        gridData.heightHint = 200;
        dbTree.setLayoutData(gridData);
        dbTree.setHeaderVisible(true);
        dbTree.setLinesVisible(true);
        TreeColumn column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colIP);
        column.setWidth(120);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colPort);
        column.setWidth(50);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colServerType);
        column.setWidth(100);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colServerStatus);
        column.setWidth(100);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colName);
        column.setWidth(150);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colStatus);
        column.setWidth(150);
        column = new TreeColumn(dbTree, SWT.CENTER);
        column.setText(Messages.colType);
        column.setWidth(60);
        dbTv.setContentProvider(new DatabaseProvider());
        dbTv.setLabelProvider(new DatabaseProvider());
        dbTv.setInput(hostNodeList);
        dbTree.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
            }
        });
    }
    Composite composite = new Composite(parent, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    composite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    composite.setLayoutData(gridData);
    Button addButton = new Button(composite, SWT.NONE);
    addButton.setText(Messages.btnAdd);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
            HostNode hostNode = null;
            int addType = 0;
            if (selection != null && !selection.isEmpty()) {
                Object obj = selection.getFirstElement();
                if (obj instanceof HostNode) {
                    hostNode = (HostNode) obj;
                    addType = 0;
                } else if (obj instanceof DatabaseNode) {
                    hostNode = ((DatabaseNode) obj).getParent();
                    addType = 1;
                } else if (obj instanceof BrokerNode) {
                    hostNode = ((BrokerNode) obj).getParent();
                    addType = 2;
                }
            }
            AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, hostNodeList, addType);
            CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
            dialog.setPageSize(660, 380);
            if (IDialogConstants.OK_ID == dialog.open()) {
                List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
                HAUtil.mergeHostNode(hostNodeList, addedHostNodeList);
                dbTv.refresh();
            }
            deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
            verify();
        }
    });
    deleteButton = new Button(composite, SWT.NONE);
    deleteButton.setText(Messages.btnDelete);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
            if (selection != null && !selection.isEmpty()) {
                Object[] objs = selection.toArray();
                for (int i = 0; i < objs.length; i++) {
                    Object obj = objs[i];
                    if (obj instanceof HostNode) {
                        hostNodeList.remove((HostNode) obj);
                    } else if (obj instanceof DatabaseNode) {
                        ((DatabaseNode) obj).getParent().getCopyedHaNodeList().remove((DatabaseNode) obj);
                    } else if (obj instanceof BrokerNode) {
                        ((BrokerNode) obj).getParent().getCopyedHaNodeList().remove((BrokerNode) obj);
                    }
                }
                dbTv.refresh();
            }
            deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
            verify();
        }
    });
    deleteButton.setEnabled(false);
}
Also used : DatabaseProvider(com.cubrid.cubridmanager.ui.mondashboard.control.DatabaseProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AddHostAndDbWizard(com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

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