use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class RestoreDatabaseDialog method showBackupVolumeInfo.
/**
*
* Show backup volume information
*
* @param level the level
* @param path the path
*/
private void showBackupVolumeInfo(String level, String path) {
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadBackupVolInfo, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(getShell(), msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (task instanceof GetBackupVolInfoTask) {
GetBackupVolInfoTask getBackupVolInfoTask = (GetBackupVolInfoTask) task;
final String backupVolInfo = getBackupVolInfoTask.getDbBackupVolInfo();
if (backupVolInfo != null && backupVolInfo.length() > 0) {
display.syncExec(new Runnable() {
public void run() {
BackupDbVolumeInfoDialog backupDbResultInfoDialog = new BackupDbVolumeInfoDialog(getShell());
backupDbResultInfoDialog.setResultInfoStr(backupVolInfo);
backupDbResultInfoDialog.open();
}
});
}
}
}
return true;
}
};
String databaseName = databaseNameText.getText();
GetBackupVolInfoTask getBackupVolInfoTask = new GetBackupVolInfoTask(database.getServer().getServerInfo());
getBackupVolInfoTask.setDbName(databaseName);
getBackupVolInfoTask.setLevel(level);
getBackupVolInfoTask.setPath(path);
taskExcutor.addTask(getBackupVolInfoTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class HostDialog method connect.
/**
*
* Execute task and connect the host
*
* @param buttonId the button id
*/
private void connect(final int buttonId) {
boolean isTest = (HostDialog.TEST_CONNECT_ID == buttonId) ? true : false;
TaskExecutor taskExcutor = new ConnectHostExecutor(getShell(), serverInfo, true, isTest);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
if (HostDialog.TEST_CONNECT_ID == buttonId) {
if (taskExcutor.isSuccess()) {
CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, Messages.msgTestConnSuccess);
}
} else {
if (taskExcutor.isSuccess()) {
QueryOptions.setAutoCommit(serverInfo, btnAutoCommit.getSelection());
// if (serverInfo.isCheckCertStatus()
// && CertStatus.DEFAULT.equals(serverInfo.getCertStatus())) {
// GenCertDialog dialog = new GenCertDialog(
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
// serverInfo);
// dialog.open();
// }
setReturnCode(buttonId);
close();
} else {
serverInfo = null;
if (passwordText != null && !passwordText.isDisposed()) {
passwordText.selectAll();
passwordText.setFocus();
}
}
}
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class ChangePasswordDialog method changePassword.
/**
*
* Execute task and change password
*
* @param buttonId the button id
*/
private void changePassword(final int buttonId) {
final String password = newPasswordText.getText();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = getShell().getDisplay();
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.changePwdTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(getShell(), msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
serverInfo.setUserPassword(password);
if (serverInfo.getLoginedUserInfo() != null) {
serverInfo.getLoginedUserInfo().setPassword(password);
}
CMHostNodePersistManager.getInstance().saveServers();
}
if (!monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
if (CommonUITool.openConfirmBox(Messages.msgChangePassSuccess)) {
setReturnCode(buttonId);
} else {
setReturnCode(IDialogConstants.CANCEL_ID);
}
close();
}
});
}
return true;
}
};
ChangeCMUserPasswordTask changePasswordTask = new ChangeCMUserPasswordTask(serverInfo);
changePasswordTask.setUserName(serverInfo.getUserName());
changePasswordTask.setPassword(password);
taskExcutor.addTask(changePasswordTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class SetHostInfoPage method createControl.
/**
* Create the control for this page
*
* @param parent Composite
*/
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gridData);
Group cmServerInfoGroup = new Group(composite, SWT.NONE);
cmServerInfoGroup.setText(Messages.grpHostInfo);
gridData = new GridData(GridData.FILL_HORIZONTAL);
cmServerInfoGroup.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
cmServerInfoGroup.setLayout(layout);
Label nickNameLable = new Label(cmServerInfoGroup, SWT.LEFT);
nickNameLable.setText(Messages.lblNickName);
nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
nickNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
ipLabel.setText(Messages.lblIPAddress);
ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
ipText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
ipText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
ipText.addModifyListener(this);
Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
portNameLabel.setText(Messages.lblPort);
portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
portText.setTextLimit(5);
portText.setText("8001");
portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
portText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
portText.selectAll();
portText.setFocus();
}
});
portText.addModifyListener(this);
Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
userNameLabel.setText(Messages.lblUserName);
userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
userNameText.setText("admin");
userNameText.setEnabled(false);
userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
passwordLabel.setText(Messages.lblPassword);
passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
passwordText.addModifyListener(this);
passwordText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
passwordText.selectAll();
passwordText.setFocus();
}
});
Composite btnComposite = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
btnComposite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
btnComposite.setLayoutData(gridData);
connectHostButton = new Button(btnComposite, SWT.NONE);
connectHostButton.setText(Messages.btnConnect);
connectHostButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String address = ipText.getText();
String port = portText.getText();
String userName = userNameText.getText();
String password = passwordText.getText();
String nickName = nickNameText.getText();
if (nickName.trim().length() == 0) {
nickNameText.setText(address + ":" + port);
}
ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(address, Integer.parseInt(port), userName);
if (serverInfo == null) {
serverInfo = new ServerInfo();
serverInfo.setServerName(address);
serverInfo.setHostAddress(address);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
}
heartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
heartbeatNodeInfoTask.setAllDb(false);
heartbeatNodeInfoTask.setDbList(new ArrayList<String>());
TaskExecutor executor = null;
if (serverInfo.isConnected()) {
if (CompatibleUtil.isSupportHA(serverInfo)) {
executor = new CommonTaskExec(null);
executor.addTask(heartbeatNodeInfoTask);
}
} else {
executor = new ConnectHostExecutor(getShell(), serverInfo, true);
executor.addTask(heartbeatNodeInfoTask);
}
if (executor != null) {
new ExecTaskWithProgress(executor).exec(true, true);
}
changeBtnStatus();
}
});
connectHostButton.setEnabled(false);
init();
nickNameText.setFocus();
setTitle(Messages.titileHostInfoPage);
setMessage(Messages.msgHostInfoPage);
setControl(composite);
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class SelectDbPage method createControl.
/**
* Create the control for this page
*
* @param parent Composite
*/
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gridData);
Group dbInfoGroup = new Group(composite, SWT.NONE);
dbInfoGroup.setText(Messages.grpSelectDb);
gridData = new GridData(GridData.FILL_HORIZONTAL);
dbInfoGroup.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
dbInfoGroup.setLayout(layout);
Label dbNameLabel = new Label(dbInfoGroup, SWT.LEFT);
dbNameLabel.setText(Messages.lblDbName);
dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbNameCombo = new Combo(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
dbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
dbNameCombo.addModifyListener(this);
Label nickNameLable = new Label(dbInfoGroup, SWT.LEFT);
nickNameLable.setText(Messages.lblNickName);
nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
nickNameText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label dbaPasswordLabel = new Label(dbInfoGroup, SWT.LEFT);
dbaPasswordLabel.setText(Messages.lblDbaPassword);
dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbaPasswordText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Composite btnComposite = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
btnComposite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
btnComposite.setLayoutData(gridData);
addButton = new Button(btnComposite, SWT.NONE);
addButton.setText(Messages.btnAddDb);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String dbName = dbNameCombo.getText();
String dbaPassword = dbaPasswordText.getText();
String nickName = nickNameText.getText();
if (nickName.trim().length() == 0) {
nickName = dbName;
}
//check whether this database already be added
if (isExist(dbName, hostNode)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDbExist, dbName));
return;
}
DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
TaskExecutor executor = new CommonTaskExec(null);
VerifyDbUserPasswordTask verifyDbUserPasswordTask = null;
if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
String password = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (!dbaPassword.equals(password)) {
CommonUITool.openErrorBox(Messages.errDbaPassowrd);
return;
}
} else {
verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
verifyDbUserPasswordTask.setDbName(dbName);
verifyDbUserPasswordTask.setDbUser("dba");
verifyDbUserPasswordTask.setDbPassword(dbaPassword);
executor.addTask(verifyDbUserPasswordTask);
}
GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
getHeartbeatNodeInfoTask.setAllDb(false);
List<String> dbList = new ArrayList<String>();
dbList.add(dbName);
getHeartbeatNodeInfoTask.setDbList(dbList);
executor.addTask(getHeartbeatNodeInfoTask);
new ExecTaskWithProgress(executor).exec(true, true);
if (!executor.isSuccess()) {
if (verifyDbUserPasswordTask != null && !verifyDbUserPasswordTask.isSuccess()) {
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
}
return;
}
List<HAHostStatusInfo> haHostStatusInfoList = getHeartbeatNodeInfoTask.getHAHostStatusList();
HADatabaseStatusInfo haDbStatusInfo = getHeartbeatNodeInfoTask.getDatabaseStatusInfo(dbName);
HAHostStatusInfo haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
//if this database is HA Mode,will get it's active database or standby database
List<DatabaseNode> haDbNodeList = getHADatabaseList(haDbStatusInfo, haHostStatusInfoList, true);
if (haHostStatusInfo == null) {
haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
if (haDbStatusInfo != null) {
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
}
}
if (haDbStatusInfo == null) {
haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbName, haHostStatusInfo, serverInfo);
}
DatabaseNode dbNode = new DatabaseNode();
hostNode.setHostStatusInfo(haHostStatusInfo);
dbNode.setParent(hostNode);
dbNode.setDbName(dbName);
dbNode.setDbUser("dba");
dbNode.setDbPassword(dbaPassword);
dbNode.setName(nickName);
dbNode.setHaDatabaseStatus(haDbStatusInfo);
dbNode.setConnected(true);
if (haDbNodeList == null) {
haDbNodeList = new ArrayList<DatabaseNode>();
}
if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
haDbNodeList.add(0, dbNode);
} else {
haDbNodeList.add(dbNode);
}
addDbNodeToTable(haDbNodeList, haHostStatusInfoList);
}
});
haModeBtn = new Button(dbInfoGroup, SWT.LEFT | SWT.CHECK);
haModeBtn.setText(Messages.btnHAMode);
haModeBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
haModeBtn.setEnabled(false);
createTable(composite);
dbNameCombo.setFocus();
setTitle(Messages.titleSelectDbPage);
setMessage(Messages.msgSelectDbPage);
setControl(composite);
}
Aggregations