Search in sources :

Example 1 with CMWizardDialog

use of com.cubrid.common.ui.spi.dialog.CMWizardDialog 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 2 with CMWizardDialog

use of com.cubrid.common.ui.spi.dialog.CMWizardDialog in project cubrid-manager by CUBRID.

the class AddDatabaseMonitorAction method run.

/**
	 * open add database monitor dialog.
	 * 
	 * @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;
    }
    HostMonitorPart hostMonPart = (HostMonitorPart) objArr[0];
    HostNode hostNode = (HostNode) hostMonPart.getModel();
    Dashboard dashboard = (Dashboard) hostMonPart.getParent().getModel();
    if (hostNode != null && dashboard != null) {
        AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, dashboard.getHostNodeList(), 1);
        CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
        dialog.setPageSize(660, 380);
        int returnCode = dialog.open();
        if (returnCode == IDialogConstants.OK_ID) {
            List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
            HAUtil.mergeHostNode(dashboard, addedHostNodeList);
            HAUtil.calcLocation(dashboard.getHostNodeList());
        }
    }
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) AddHostAndDbWizard(com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 3 with CMWizardDialog

use of com.cubrid.common.ui.spi.dialog.CMWizardDialog in project cubrid-manager by CUBRID.

the class TableEditorPart method createPartitionTabButtons.

/**
	 * Create Partition tab buttons
	 *
	 * @param parent Composite
	 */
private void createPartitionTabButtons(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 5;
        composite.setLayout(gl);
        composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    }
    addPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        addPartitionBtn.setLayoutData(gd);
    }
    addPartitionBtn.setText(Messages.btnAddPartition);
    addPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String tableName = tableNameText.getText();
            if (tableName.trim().length() == 0) {
                CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName);
                return;
            }
            newSchemaInfo.setClassname(tableName);
            Wizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, null);
            CMWizardDialog dialog = new CMWizardDialog(getSite().getShell(), wizard);
            dialog.setPageSize(600, 400);
            if (dialog.open() != IDialogConstants.OK_ID) {
                return;
            }
            partitionTableView.refresh();
            changePartitionTabButtonStatus();
        }
    });
    editPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        editPartitionBtn.setLayoutData(gd);
    }
    editPartitionBtn.setText(Messages.btnEditPartition);
    editPartitionBtn.setEnabled(false);
    editPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editPartition();
        }
    });
    delPartitionBtn = new Button(composite, SWT.PUSH);
    {
        GridData gd = new GridData(SWT.NONE);
        gd.horizontalIndent = 10;
        delPartitionBtn.setLayoutData(gd);
    }
    delPartitionBtn.setText(Messages.btnDelPartition);
    delPartitionBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String confirmMsg = Messages.msgDelPartition;
            if (getPartitonType() == PartitionType.HASH) {
                confirmMsg = Messages.msgDelHashPartition;
            }
            boolean deleteConfirm = CommonUITool.openConfirmBox(getSite().getShell(), confirmMsg);
            if (!deleteConfirm) {
                return;
            }
            if (getPartitonType() == PartitionType.HASH) {
                partitionInfoList.clear();
            } else {
                IStructuredSelection selection = (IStructuredSelection) partitionTableView.getSelection();
                if (selection == null || selection.isEmpty()) {
                    return;
                }
                partitionInfoList.removeAll(selection.toList());
                if (getPartitonType() == PartitionType.RANGE) {
                    CreatePartitionWizard.resetRangePartitionInfoList(partitionInfoList);
                }
            }
            partitionTableView.refresh();
            changePartitionTabButtonStatus();
        }
    });
    final Table partitionTable = partitionTableView.getTable();
    partitionTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changePartitionTabButtonStatus();
        }
    });
    changePartitionTabButtonStatus();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Wizard(org.eclipse.jface.wizard.Wizard) CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 4 with CMWizardDialog

use of com.cubrid.common.ui.spi.dialog.CMWizardDialog in project cubrid-manager by CUBRID.

the class CreateDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (obj != null && obj.length > 0) {
        if (!isSupported(obj[0])) {
            this.setEnabled(false);
            return;
        }
        node = (ICubridNode) obj[0];
        server = node.getServer();
        ISelectionProvider provider = this.getSelectionProvider();
        viewer = (TreeViewer) provider;
    }
    String serverNameKey = node.getServer().getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridServerLoader.DATABASE_FOLDER_ID;
    ICubridNode cubridServer = node.getServer().getChild(serverNameKey);
    CMWizardDialog dialog = new CMWizardDialog(getShell(), new CreateDatabaseWizard(server, viewer, cubridServer));
    dialog.setPageSize(580, 420);
    dialog.open();
}
Also used : CreateDatabaseWizard(com.cubrid.cubridmanager.ui.cubrid.database.control.CreateDatabaseWizard) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 5 with CMWizardDialog

use of com.cubrid.common.ui.spi.dialog.CMWizardDialog in project cubrid-manager by CUBRID.

the class ChangeReplicationSchemaAction method run.

/**
	 * change replication database.
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
        return;
    }
    ICubridNode node = (ICubridNode) obj[0];
    CMWizardDialog dialog = new CMWizardDialog(getShell(), new ChangeReplTablesWizard(node));
    dialog.setPageSize(560, 300);
    dialog.open();
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ChangeReplTablesWizard(com.cubrid.cubridmanager.ui.replication.control.ChangeReplTablesWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Aggregations

CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)14 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)4 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)4 Composite (org.eclipse.swt.widgets.Composite)4 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 Button (org.eclipse.swt.widgets.Button)3 CreatePartitionWizard (com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)2 SetDistributorDbInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog)2 SetSlaveDbInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog)2 SetMasterDbInfoWizard (com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard)2 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)2 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)2 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2