use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class StopSlaveDbAction method run.
/**
* Stop database and refresh navigator
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
final ISchemaNode schemaNode = (ISchemaNode) obj[0];
ReplicationInfo replInfo = (ReplicationInfo) schemaNode.getAdapter(ReplicationInfo.class);
Set<CubridDatabase> databaseSet = new HashSet<CubridDatabase>();
for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
CubridDatabase database = StartSlaveDbAction.getDatabaseByName(schemaNode.getParent(), replInfo.getSlaveList().get(j).getSlaveDbName());
databaseSet.add(database);
}
StringBuffer dbNamesBuffer = new StringBuffer("");
Iterator<SlaveInfo> it = replInfo.getSlaveList().iterator();
while (it.hasNext()) {
dbNamesBuffer.append(it.next().getSlaveDbName()).append(",");
}
String dbNames = dbNamesBuffer.toString().substring(0, dbNamesBuffer.toString().length() - 1);
boolean isStop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmStopDatabase, dbNames));
if (!isStop) {
return;
}
final Object[] dbObjectArr = new Object[databaseSet.size()];
databaseSet.toArray(dbObjectArr);
ISelectionProvider provider = getSelectionProvider();
final Shell shell = getShell();
if (provider instanceof TreeViewer && dbObjectArr.length > 0) {
final TreeViewer viewer = (TreeViewer) provider;
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
final CubridDatabase database = node.getDatabase();
ITask task = taskList.get(i);
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.STANDALONE);
display.syncExec(new Runnable() {
public void run() {
viewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (int i = 0; i < dbObjectArr.length; i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
CubridDatabase database = node.getDatabase();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).exec();
if (taskExcutor.isSuccess()) {
for (int i = 0; i < dbObjectArr.length; i++) {
CubridDatabase database = (CubridDatabase) dbObjectArr[i];
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_STOP));
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class StartSlaveDbAction method run.
/**
* Start database and refresh navigator
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
setEnabled(false);
return;
}
final ISchemaNode schemaNode = (ISchemaNode) obj[0];
ReplicationInfo replInfo = (ReplicationInfo) schemaNode.getAdapter(ReplicationInfo.class);
Set<CubridDatabase> databaseSet = new HashSet<CubridDatabase>();
for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
CubridDatabase database = getDatabaseByName(schemaNode.getParent(), replInfo.getSlaveList().get(j).getSlaveDbName());
databaseSet.add(database);
}
final Object[] dbObjectArr = new Object[databaseSet.size()];
databaseSet.toArray(dbObjectArr);
ISelectionProvider provider = getSelectionProvider();
final Shell shell = getShell();
if (provider instanceof TreeViewer && dbObjectArr.length > 0) {
final TreeViewer viewer = (TreeViewer) provider;
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
final CubridDatabase database = node.getDatabase();
ITask task = taskList.get(i);
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.CS);
display.syncExec(new Runnable() {
public void run() {
viewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (int i = 0; i < dbObjectArr.length; i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
CubridDatabase database = node.getDatabase();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).exec();
if (taskExcutor.isSuccess()) {
for (int i = 0; i < dbObjectArr.length; i++) {
CubridDatabase database = (CubridDatabase) dbObjectArr[i];
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_START));
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class SetReplicationParamDialog method createBasicGroup.
/**
* Creates basic group
*
* @param parent Composite
*/
private void createBasicGroup(Composite parent) {
final Group group = new Group(parent, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
group.setText(Messages.repparm0grpReplicationInfo);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 5;
group.setLayout(gridLayout);
Label slaveDbNameLabel = new Label(group, SWT.NONE);
slaveDbNameLabel.setText(Messages.repparm0lblSlaveDbName);
slaveDbNameLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
slaveDbNameCombo = new Combo(group, SWT.NONE | SWT.READ_ONLY);
slaveDbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Button connectButton = new Button(group, SWT.RIGHT);
connectButton.setText(Messages.repparm0btnConnect);
connectButton.setLayoutData(new GridData());
connectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
task.setSlaveDbName(slaveDbNameCombo.getText());
task.setDistDbName(database.getLabel());
task.setDistDbDbaPasswd(database.getPassword());
task.setRunningMode(database.getRunningType() == DbRunningType.CS);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ReplicationParamInfo paramInfo = task.getReplicationParams();
Map<String, String> paramMap = paramInfo.getParamMap();
paramEditor.setReplicationParamMap(paramMap);
}
}
});
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class SetReplicationParamDialog method initial.
/**
*
* initial the page content
*
*/
private void initial() {
setReplInfo((ReplicationInfo) database.getAdapter(ReplicationInfo.class));
for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
slaveDbNameCombo.add(replInfo.getSlaveList().get(j).getSlaveDbName());
}
slaveDbNameCombo.setText(replInfo.getSlaveList().get(0).getSlaveDbName());
GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
task.setSlaveDbName(slaveDbNameCombo.getText());
task.setDistDbName(database.getLabel());
task.setDistDbDbaPasswd(database.getPassword());
task.setRunningMode(database.getRunningType() == DbRunningType.CS);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ReplicationParamInfo paramInfo = task.getReplicationParams();
Map<String, String> paramMap = paramInfo.getParamMap();
paramEditor.setReplicationParamMap(paramMap);
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class ChangeTablesPage method pageChanged.
/**
* @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
* @param event PageChangedEvent
*/
public void pageChanged(PageChangedEvent event) {
IWizardPage page = (IWizardPage) event.getSelectedPage();
if (page.getName().equals(PAGENAME)) {
SetDatabaseInfoPage selectDatabasePage = (SetDatabaseInfoPage) getWizard().getPage(SetDatabaseInfoPage.PAGENAME);
String ip = selectDatabasePage.getIp();
String port = selectDatabasePage.getPort();
String userName = selectDatabasePage.getUserName();
String password = selectDatabasePage.getPassword();
String dbName = selectDatabasePage.getMasterDbName();
String dbaPassword = selectDatabasePage.getMasterDbaPassword();
GetAllClassesTaskExecutor taskExcutor = new GetAllClassesTaskExecutor(getShell(), ip, port, userName, password, dbName, dbaPassword);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
if (taskExcutor.isSuccess()) {
DBClasses dbClasses = taskExcutor.getDBClasses();
selectTableComp.fillTableViewer(dbClasses);
initialize();
setErrorMessage(null);
} else {
setErrorMessage(Messages.errPreviousPage);
}
}
}
Aggregations