Search in sources :

Example 11 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode 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)

Example 12 with HostNode

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

the class DeleteDatabaseMonitorCommand method execute.

/**
	 * remove current database node from dashboard
	 */
public void execute() {
    if (null == nodeToDelete || null == nodeToDelete.getParent()) {
        return;
    }
    boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteDatabase, nodeToDelete.getName()));
    if (!isDelete) {
        return;
    }
    HostNode parent = nodeToDelete.getParent();
    parent.removeDbNode(nodeToDelete);
    dashboard.refresh();
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Example 13 with HostNode

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

the class BrokerDataProvider method setDefaultValue.

/**
	 * 
	 * Set default value
	 * 
	 */
private void setDefaultValue() {
    isExecGetBrokerTask = false;
    errorMsg = "";
    if (brokerNodeList == null || brokerNodeList.isEmpty()) {
        return;
    }
    BrokerNode brokerNode = null;
    for (BrokerNode node : brokerNodeList) {
        if (node.getParent().isConnected()) {
            brokerNode = node;
            break;
        }
    }
    if (brokerNode == null) {
        return;
    }
    HostNode hostNode = brokerNode.getParent();
    if (hostNode != null && hostNode.isConnected()) {
        List<DataUpdateListener> listenerList = generator.getListeners();
        for (DataUpdateListener listener : listenerList) {
            if (listener instanceof BrokerMonitorPartHelper || listener instanceof BrokerDashboardViewPart) {
                isExecGetBrokerTask = true;
                break;
            }
        }
        serverInfo = hostNode.getServerInfo();
    }
    StringBuffer strBuff = new StringBuffer();
    for (BrokerNode node : brokerNodeList) {
        strBuff.append(node.getBrokerName());
        strBuff.append(",");
    }
    strBuff = strBuff.deleteCharAt(strBuff.length() - 1);
    allBrokersStr = strBuff.toString();
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) BrokerDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.BrokerDashboardViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) BrokerMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.BrokerMonitorPartHelper)

Example 14 with HostNode

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

the class DataGeneratorPool method isHasConnection.

/**
	 * 
	 * Return whether has connection
	 * 
	 * @param ip String
	 * @param port String
	 * @param userName String
	 * @return boolean
	 */
public boolean isHasConnection(String ip, String port, String userName) {
    Iterator<DataGenerator> it = map.values().iterator();
    while (it.hasNext()) {
        DataGenerator generator = it.next();
        List<DataUpdateListener> listenerList = generator.getListeners();
        for (DataUpdateListener listener : listenerList) {
            HostNode hostNode = null;
            if (listener.getModel() instanceof HostNode) {
                hostNode = (HostNode) listener.getModel();
            } else if (listener.getModel() instanceof DatabaseNode) {
                hostNode = ((DatabaseNode) listener.getModel()).getParent();
            } else if (listener.getModel() instanceof BrokerNode) {
                hostNode = ((BrokerNode) listener.getModel()).getParent();
            }
            if (hostNode != null && hostNode.isConnected() && ip.equals(hostNode.getIp()) && port.equals(hostNode.getPort()) && userName.equals(hostNode.getUserName())) {
                return true;
            }
        }
    }
    return false;
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Example 15 with HostNode

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

the class BrokerMonitorPart method setMode2View.

/**
	 * Set model's value to view.
	 * 
	 * @param figure BrokerMonitorFigure
	 * @param broker BrokerNode
	 */
private void setMode2View(BrokerMonitorFigure figure, BrokerNode broker) {
    HostNode hostNode = broker.getParent();
    figure.setTitle(broker.getName());
    figure.setHostName(hostNode.getName());
    String brokerStatus = BrokerMonitorFigure.STATUS_UNKNOWN;
    String accessMode = OnOffType.OFF.getText();
    BrokerInfo brokerInfo = broker.getBrokerInfo();
    if (brokerInfo != null) {
        brokerStatus = brokerInfo.getState();
        accessMode = brokerInfo.getAccess_mode();
    }
    figure.setStatus(true, hostNode.isConnected(), brokerStatus, accessMode, broker.getErrorMsg(), broker.hasNewErrorMsg());
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)57 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)12 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)10 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)9 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 ArrayList (java.util.ArrayList)6 Point (org.eclipse.draw2d.geometry.Point)6 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)4 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)4 DataProvider (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider)4 IViewPart (org.eclipse.ui.IViewPart)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 PartInitException (org.eclipse.ui.PartInitException)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)3 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)3