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();
}
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();
}
}
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();
}
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();
}
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;
}
Aggregations