use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class ERSchemaEditor method syncComments.
/**
* sync table comments to db tables.
*
* @return void
*/
public void syncComments() {
DatabaseInfo info = database.getDatabaseInfo();
if (info == null) {
CommonUITool.openErrorBox(Messages.errNoDatabase);
return;
}
if (!info.isLogined()) {
CommonUITool.openErrorBox(Messages.msgDBNotLogin);
return;
}
ServerInfo serverInfo = info.getServerInfo();
if (serverInfo != null && !serverInfo.isConnected()) {
CommonUITool.openErrorBox(Messages.msgDBNotLogin);
return;
}
boolean isSupportTableComment = false;
Connection conn = null;
try {
conn = JDBCConnectionManager.getConnection(info, false);
isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(info, conn);
if (!isSupportTableComment) {
CommonUITool.openErrorBox(Messages.cannotSyncComments);
return;
}
} catch (Exception e) {
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn);
}
if (!CommonUITool.openConfirmBox(getSite().getShell(), Messages.bind(Messages.msgConfirmSyncComments, database.getLabel()))) {
return;
}
CommonTaskExec taskJobExec = new CommonTaskExec(null);
List<UpdateDescriptionTask> updateDescTasks = getUpdateDescriptionTaskList(info);
for (UpdateDescriptionTask task : updateDescTasks) {
taskJobExec.addTask(task);
}
if (updateDescTasks.size() == 0) {
CommonUITool.openInformationBox(Messages.msgNoComments);
return;
}
new ExecTaskWithProgress(taskJobExec).exec();
Set<String> failTables = new HashSet<String>();
for (UpdateDescriptionTask task : updateDescTasks) {
if (!task.isSuccess()) {
failTables.add(task.getTableName());
}
}
if (failTables.size() == 0) {
CommonUITool.openInformationBox(Messages.msgSuccessSyncComments);
} else {
CommonUITool.openErrorBox(Messages.bind(Messages.errSyncComments, failTables.toString()));
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class ServicePropertyPage method perform.
/**
*
* Perform the task and set cubrid.conf configuration file service section
* parameter
*
* @param confParaMap the conf parameter map
*/
private void perform(Map<String, Map<String, String>> confParaMap) {
SetCubridConfParameterTask task = new SetCubridConfParameterTask(node.getServer().getServerInfo());
task.setConfParameters(confParaMap);
CommonTaskExec taskExcutor = new CommonTaskExec(Messages.setCubridParameterTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
if (taskExcutor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgChangeServiceParaSuccess);
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class DeleteDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
if (database == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
task.setDbName(database.getName());
TaskExecutor taskExcutor = new CommonTaskExec(Messages.getDbSpaceInfoTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
DeleteDatabaseDialog dlg = new DeleteDatabaseDialog(getShell());
dlg.setDbSpaceInfo(task.getResultModel());
dlg.setDatabase(database);
ICubridNode parent = database.getParent();
if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
boolean isContinue = DatabaseUtils.processDatabaseDeleted(database);
if (isContinue) {
TreeViewer viewer = (TreeViewer) provider;
parent.removeChild(database);
viewer.remove(parent, obj);
viewer.setSelection(new StructuredSelection(parent));
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class AddStatusMonitorTemplateAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode selection = (ICubridNode) obj[0];
ServerInfo site = selection.getServer().getServerInfo();
boolean execDiagChecked = false;
final GetCMConfParameterTask task = new GetCMConfParameterTask(site);
TaskExecutor taskExec = new CommonTaskExec(null);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).exec();
if (!taskExec.isSuccess()) {
return;
}
Map<String, String> confParas = task.getConfParameters();
if (confParas == null) {
execDiagChecked = false;
} else {
if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
execDiagChecked = false;
} else {
execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
}
}
DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
dialog.setOperation(AddEditType.ADD);
dialog.setSelection(selection);
dialog.setExecDiagChecked(execDiagChecked);
if (dialog.open() == Dialog.OK) {
StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
AddStatusTemplateTask addTask = new AddStatusTemplateTask(site);
addTask.setStatusTemplateInfo(statusTemplateInfo);
addTask.buildMsg();
String taskName = Messages.bind(Messages.addTemplateTaskName, statusTemplateInfo.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(addTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection);
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class EditStatusMonitorTemplateAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode selection = (ICubridNode) obj[0];
ServerInfo serverInfo = selection.getServer().getServerInfo();
boolean execDiagChecked = false;
final GetCMConfParameterTask task = new GetCMConfParameterTask(serverInfo);
TaskExecutor taskExec = new CommonTaskExec(null);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).exec();
if (!taskExec.isSuccess()) {
return;
}
Map<String, String> confParas = task.getConfParameters();
if (confParas == null) {
execDiagChecked = false;
} else {
if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
execDiagChecked = false;
} else {
execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
}
}
DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
dialog.setOperation(AddEditType.EDIT);
dialog.setSelection(selection);
dialog.setExecDiagChecked(execDiagChecked);
if (dialog.open() == Dialog.OK) {
StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
updateTask.setStatusTemplateInfo(statusTemplateInfo);
updateTask.buildMsg();
String taskName = Messages.bind(Messages.editTemplateTaskName, statusTemplateInfo.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(updateTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
}
}
}
Aggregations