use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class ManagerLogViewAction method run.
/**
* Open the log editor and show log conent
*/
public void run() {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
if (cubridNode == null) {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
cubridNode = (ICubridNode) obj[0];
}
final GetManagerLogListTask task = new GetManagerLogListTask(cubridNode.getServer().getServerInfo());
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
cubridNode = null;
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
} else {
Display.getDefault().syncExec(new Runnable() {
public void run() {
ManagerLogInfos managerLogInfos = (ManagerLogInfos) task.getLogContent();
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, LogEditorPart.ID);
if (editorPart != null) {
window.getActivePage().closeEditor(editorPart, false);
}
try {
IEditorPart editor = window.getActivePage().openEditor(cubridNode, LogEditorPart.ID);
((LogEditorPart) editor).setManagerLogInfo(managerLogInfos, true);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
cubridNode = null;
return Status.CANCEL_STATUS;
}
}
cubridNode = null;
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(task);
String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class CopyDatabaseDialog method okPressed.
/**
* When ok button press,call this method
*/
protected void okPressed() {
if (!verify()) {
return;
}
destDbName = destinationDBNameText.getText();
if (!CommonUITool.openConfirmBox(parentComp.getShell(), Messages.warnYesNoCopyDb)) {
return;
}
SocketTask checkTask = getCheckDirsTask();
SocketTask copyTask = getCopyDbTask();
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
taskExec.addTask(checkTask);
taskExec.addTask(copyTask);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
jobName = Messages.msgCopyDbRearJobName + " - " + dbName + "@" + serverName;
taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class UserEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> if it is successfully;<code>false</code>
* otherwise
*/
public boolean loadData() {
final CommonQueryTask<DbUserInfoList> userTask = new CommonQueryTask<DbUserInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbUserInfoList(), database.getDatabaseInfo().getCharSet());
userTask.setDbName(database.getName());
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo());
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo());
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof CommonQueryTask) {
userListInfo = ((CommonQueryTask<DbUserInfoList>) t).getResultModel();
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
initial();
}
});
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(userTask);
taskJobExecutor.addTask(classInfoTask);
taskJobExecutor.addTask(partitionTask);
String jobName = Messages.viewUserInfoJobName + " - " + userName + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerBrokerInfo.
/**
* Load Server Broker Info
*/
private void loadServerBrokerInfo(final ServerInfo serverInfo, final String key) {
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
BrokerInfos brokerInfos = task.getResultModel();
setBrokerData(sDashInfo, brokerInfos);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(task);
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerBrokerInfo);
}
use of com.cubrid.common.ui.spi.progress.TaskJobExecutor in project cubrid-manager by CUBRID.
the class LoadDatabaseDialog method loadDb.
/**
* Execute task and load database
*
* @param buttonId the button id
*/
private void loadDb(final int buttonId) {
TaskJobExecutor taskExcutor = new LoadDbTaskExecutor(buttonId);
LoadDbTask loadDbTask1 = new LoadDbTask(database.getServer().getServerInfo());
LoadDbTask loadDbTask2 = new LoadDbTask(database.getServer().getServerInfo());
loadDbTask1.setDbName(databaseNameText.getText());
loadDbTask2.setDbName(databaseNameText.getText());
loadDbTask1.setDbUser(userNameText.getText());
loadDbTask2.setDbUser(userNameText.getText());
if (checkSyntaxButton.getSelection()) {
loadDbTask1.setCheckOption("both");
loadDbTask2.setCheckOption("both");
} else {
loadDbTask1.setCheckOption("load");
loadDbTask2.setCheckOption("load");
}
if (commitPeriodButton.getSelection()) {
loadDbTask1.setUsedPeriod(true, commitPeriodText.getText());
loadDbTask2.setUsedPeriod(true, commitPeriodText.getText());
} else {
loadDbTask1.setUsedPeriod(false, "");
loadDbTask2.setUsedPeriod(false, "");
}
if (estimatedSizeButton.getSelection()) {
loadDbTask1.setUsedEstimatedSize(true, estimatedSizeText.getText());
loadDbTask2.setUsedEstimatedSize(true, estimatedSizeText.getText());
} else {
loadDbTask1.setUsedEstimatedSize(false, "");
loadDbTask2.setUsedEstimatedSize(false, "");
}
if (useErrorControlFileButton.getSelection()) {
loadDbTask1.setUsedErrorContorlFile(true, errorControlFileText.getText());
loadDbTask2.setUsedErrorContorlFile(true, errorControlFileText.getText());
} else {
loadDbTask1.setUsedErrorContorlFile(false, "");
loadDbTask2.setUsedErrorContorlFile(false, "");
}
if (ignoreClassFileButton.getSelection()) {
loadDbTask1.setUsedIgnoredClassFile(true, ignoredClassFileText.getText());
loadDbTask2.setUsedIgnoredClassFile(true, ignoredClassFileText.getText());
} else {
loadDbTask1.setUsedIgnoredClassFile(false, "");
loadDbTask2.setUsedIgnoredClassFile(false, "");
}
loadDbTask1.setNoUsedOid(oidButton.getSelection());
loadDbTask2.setNoUsedOid(oidButton.getSelection());
if (noStatisButton != null) {
loadDbTask1.setNoUsedStatistics(noStatisButton.getSelection());
loadDbTask2.setNoUsedStatistics(noStatisButton.getSelection());
}
loadDbTask1.setNoUsedLog(false);
loadDbTask2.setNoUsedLog(false);
if (selectLoadFileFromListButton.getSelection()) {
String schemaPath = "";
String objectPath = "";
String indexPath = "";
String triggerPath = "";
for (int i = 0, n = unloadInfoTable.getItemCount(); i < n; i++) {
if (unloadInfoTable.getItem(i).getChecked()) {
String type = unloadInfoTable.getItem(i).getText(0);
String path = unloadInfoTable.getItem(i).getText(1);
if (type != null && type.trim().equals("schema")) {
schemaPath = path;
}
if (type != null && type.trim().equals("object")) {
objectPath = path;
}
if (type != null && type.trim().equals("index")) {
indexPath = path;
}
if (type != null && type.trim().equals("trigger")) {
triggerPath = path;
}
}
}
boolean isAddTask1 = false;
if (schemaPath != null && schemaPath.trim().length() > 0) {
loadDbTask1.setSchemaPath(schemaPath);
isAddTask1 = true;
} else {
loadDbTask1.setSchemaPath("none");
}
if (objectPath != null && objectPath.trim().length() > 0) {
loadDbTask1.setObjectPath(objectPath);
isAddTask1 = true;
} else {
loadDbTask1.setObjectPath("none");
}
if (indexPath != null && indexPath.trim().length() > 0) {
loadDbTask1.setIndexPath(indexPath);
isAddTask1 = true;
} else {
loadDbTask1.setIndexPath("none");
}
boolean isAddTask2 = false;
if (triggerPath != null && triggerPath.trim().length() > 0) {
loadDbTask2.setSchemaPath(triggerPath);
isAddTask2 = true;
}
if (isAddTask1) {
taskExcutor.addTask(loadDbTask1);
}
if (isAddTask2) {
taskExcutor.addTask(loadDbTask2);
}
} else if (selectUnloadFileFromSysButton.getSelection()) {
boolean isAddTask1 = false;
if (loadSchemaButton.getSelection()) {
String schemaPath = loadSchemaText.getText();
loadDbTask1.setSchemaPath(schemaPath);
isAddTask1 = true;
} else {
loadDbTask1.setSchemaPath("none");
}
if (loadObjButton.getSelection()) {
String objPath = loadObjText.getText();
loadDbTask1.setObjectPath(objPath);
isAddTask1 = true;
} else {
loadDbTask1.setObjectPath("none");
}
if (loadIndexButton.getSelection()) {
String indexPath = loadIndexText.getText();
loadDbTask1.setIndexPath(indexPath);
isAddTask1 = true;
} else {
loadDbTask1.setIndexPath("none");
}
boolean isAddTask2 = false;
if (loadTriggerButton.getSelection()) {
String triggerPath = loadTriggerText.getText();
loadDbTask2.setSchemaPath(triggerPath);
isAddTask2 = true;
}
if (isAddTask1) {
taskExcutor.addTask(loadDbTask1);
}
if (isAddTask2) {
taskExcutor.addTask(loadDbTask2);
}
}
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.msgLoadDBRearJobName + " - " + dbName + "@" + serverName;
taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
}
Aggregations