Search in sources :

Example 6 with CMWizardDialog

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

the class ChangeSlaveDbAction method run.

/**
	 * change slave database
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    CMWizardDialog dialog = new CMWizardDialog(getShell(), new ChangeSlaveDbWizard(database));
    dialog.setPageSize(400, 350);
    dialog.open();
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ChangeSlaveDbWizard(com.cubrid.cubridmanager.ui.replication.control.ChangeSlaveDbWizard) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 7 with CMWizardDialog

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

the class EditAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IWorkbenchPart workbenchPart = this.getWorkbenchPart();
    if (!(workbenchPart instanceof ReplicationEditor) || !isEnabled()) {
        return;
    }
    ReplicationEditor replEditor = (ReplicationEditor) workbenchPart;
    Shell shell = replEditor.getSite().getShell();
    NodePart nodePart = (NodePart) getSelectedObjects().get(0);
    if (nodePart.getModel() instanceof MasterNode) {
        SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) nodePart.getModel());
        wizard.setEditable(replEditor.isEditable());
        CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
        dialog.setPageSize(560, 300);
        dialog.open();
    } else if (nodePart.getModel() instanceof DistributorNode) {
        SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
        dialog.setDistributor((DistributorNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    } else if (nodePart.getModel() instanceof SlaveNode) {
        SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
        dialog.setSlave((SlaveNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    } else if (nodePart.getModel() instanceof HostNode) {
        SetHostInfoDialog dialog = new SetHostInfoDialog(shell);
        dialog.setHostInfo((HostNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetHostInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog) ReplicationEditor(com.cubrid.cubridmanager.ui.replication.editor.ReplicationEditor) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SetDistributorDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog) NodePart(com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart) SetMasterDbInfoWizard(com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog) SetSlaveDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 8 with CMWizardDialog

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

the class ConnectionUrlImportAction method run.

/**
	 * Import hosts and groups
	 */
public void run() {
    CMWizardDialog dialog = new CMWizardDialog(Display.getCurrent().getActiveShell(), new CreateConnectionByUrlWizard());
    dialog.setPageSize(600, 300);
    dialog.open();
}
Also used : CreateConnectionByUrlWizard(com.cubrid.cubridquery.ui.connection.dialog.CreateConnectionByUrlWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 9 with CMWizardDialog

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

the class TableEditorPart method editPartition.

/**
	 * Show the edit dialog for selected partition.
	 */
private void editPartition() {
    if (WidgetUtil.disposed(partitionTableView)) {
        return;
    }
    PartitionInfo partitionInfo = null;
    if (getPartitonType() == PartitionType.HASH) {
        partitionInfo = partitionInfoList.get(0);
    } else {
        IStructuredSelection selection = (IStructuredSelection) partitionTableView.getSelection();
        if (selection == null || selection.isEmpty()) {
            return;
        }
        partitionInfo = (PartitionInfo) selection.getFirstElement();
    }
    String tableName = tableNameText.getText();
    if (WidgetUtil.disposed(tableNameText) || StringUtil.isEmpty(tableName)) {
        CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName);
        return;
    }
    newSchemaInfo.setClassname(tableName);
    CreatePartitionWizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, partitionInfo);
    CMWizardDialog dialog = new CMWizardDialog(getSite().getShell(), wizard);
    dialog.setPageSize(600, 400);
    if (dialog.open() != IDialogConstants.OK_ID) {
        return;
    }
    newSchemaInfo.setPartitionList(partitionInfoList);
    partitionTableView.refresh();
    changePartitionTabButtonStatus();
}
Also used : CreatePartitionWizard(com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard) PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 10 with CMWizardDialog

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

the class UserManagementTableViewerSorter method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.msgUserManagementList);
    tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    // create CUBRID Manager user information table
    String[] columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    final ServerType serverType = server.getServerInfo().getServerType();
    if (serverType == ServerType.DATABASE) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnMonitorAuth };
    } else if (serverType == ServerType.BROKER) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    }
    tableViewer = CommonUITool.createCommonTableViewer(composite, new UserManagementTableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
    userManageTable = tableViewer.getTable();
    initialTableModel();
    tableViewer.setInput(serverUserInfoTableList);
    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
        userManageTable.getColumn(i).pack();
    }
    userManageTable.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            if (userManageTable.getSelectionCount() > 0) {
                StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
                boolean isHasAdmin = false;
                if (selection != null && !selection.isEmpty()) {
                    Iterator it = selection.iterator();
                    while (it.hasNext()) {
                        Map map = (Map) it.next();
                        if (map.get("0").equals("admin")) {
                            isHasAdmin = true;
                            break;
                        }
                    }
                }
                deleteButton.setEnabled(!isHasAdmin);
            } else {
                deleteButton.setEnabled(false);
            }
            if (userManageTable.getSelectionCount() == 1) {
                editButton.setEnabled(true);
            } else {
                editButton.setEnabled(false);
            }
        }
    });
    // create button
    Composite buttonComp = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    buttonComp.setLayout(rowLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    buttonComp.setLayoutData(gridData);
    Button addButton = new Button(buttonComp, SWT.PUSH);
    addButton.setText(Messages.btnAdd);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            UserManagementWizard userManagementWizard = new UserManagementWizard(server, null, serverUserInfoList);
            CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
            int returnCode = dialog.open();
            if (returnCode == IDialogConstants.OK_ID) {
                ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("0", userInfo.getUserName());
                if (serverType == ServerType.BOTH) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getCasAuth().getText());
                    map.put("3", userInfo.getStatusMonitorAuth().getText());
                    map.put("4", userInfo);
                }
                if (serverType == ServerType.DATABASE) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                } else if (serverType == ServerType.BROKER) {
                    map.put("1", userInfo.getCasAuth().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                }
                serverUserInfoTableList.add(map);
                serverUserInfoList.add(userInfo);
                tableViewer.refresh();
                for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                    userManageTable.getColumn(i).pack();
                }
            }
        }
    });
    editButton = new Button(buttonComp, SWT.PUSH);
    editButton.setText(Messages.btnEdit);
    editButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings({ "rawtypes", "unchecked" })
        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            ServerUserInfo serverUserInfo = null;
            if (selection != null && !selection.isEmpty()) {
                Map map = (Map) selection.getFirstElement();
                if (serverType == ServerType.BOTH) {
                    serverUserInfo = (ServerUserInfo) map.get("4");
                } else {
                    serverUserInfo = (ServerUserInfo) map.get("3");
                }
                UserManagementWizard userManagementWizard = new UserManagementWizard(server, serverUserInfo, serverUserInfoList);
                CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
                int returnCode = dialog.open();
                if (returnCode == IDialogConstants.OK_ID) {
                    ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                    map.put("0", userInfo.getUserName());
                    if (serverType == ServerType.BOTH) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getCasAuth().getText());
                        map.put("3", userInfo.getStatusMonitorAuth().getText());
                        map.put("4", userInfo);
                    }
                    if (serverType == ServerType.DATABASE) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    } else if (serverType == ServerType.BROKER) {
                        map.put("1", userInfo.getCasAuth().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    }
                    tableViewer.refresh();
                    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                        userManageTable.getColumn(i).pack();
                    }
                }
            }
        }
    });
    editButton.setEnabled(userManageTable.getSelectionCount() == 1);
    deleteButton = new Button(buttonComp, SWT.PUSH);
    deleteButton.setText(Messages.btnDelete);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            boolean isDelete = CommonUITool.openConfirmBox(getShell(), Messages.msgDeleteUserConfirm);
            if (!isDelete) {
                return;
            }
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            if (selection != null && !selection.isEmpty()) {
                Map[] userInfoMapArr = new Map[selection.size()];
                Iterator it = selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    Map map = (Map) it.next();
                    userInfoMapArr[i] = map;
                    i++;
                }
                deleteUser(userInfoMapArr);
            }
            tableViewer.refresh();
        }
    });
    deleteButton.setEnabled(userManageTable.getSelectionCount() == 1);
    setTitle(Messages.titleUserManagementDialog);
    setMessage(Messages.msgUserManagementDialog);
    return parentComp;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) UserManagementWizard(com.cubrid.cubridmanager.ui.common.control.UserManagementWizard) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) HashMap(java.util.HashMap) Map(java.util.Map) 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