use of org.eclipse.core.runtime.Status in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method showLogView.
/**
* show sql log view at broker table
*
* @param type sql type
*/
public void showLogView(String type) {
try {
int i = brokerInfoTable.getSelectionIndex();
if (i < 0) {
return;
}
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String brokerName = brokerInfoTable.getItem(i).getText(0);
String serverId = brokerInfoTable.getItem(i).getText(1);
//get all log infor
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(brokerName);
task.execute();
brokerLogInfos = task.getResultModel();
String logFileName = brokerName + "_" + serverId + "." + type + ".log";
sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
task.finish();
//get the current log
LogInfo logInfo = null;
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfoInlist : logInfoList) {
if (logFileName.equals(logInfoInlist.getName())) {
logInfo = logInfoInlist;
break;
}
}
}
if (logInfo == null) {
String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
LOGGER.error(msg);
//CommonUITool.openErrorBox(msg);
return;
}
final String filePath = logInfo.getPath();
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.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 (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files == null || files.length == 0) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, filePath));
}
} else if (task instanceof GetLogListTask) {
GetLogListTask getLogListTask = (GetLogListTask) task;
final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
task.finish();
}
return Status.OK_STATUS;
}
};
CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
checkFileTask.setFile(new String[] { filePath });
taskJobExecutor.addTask(checkFileTask);
GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
getLogListTask.setPath(filePath);
getLogListTask.setStart("1");
getLogListTask.setEnd("100");
taskJobExecutor.addTask(getLogListTask);
String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
} catch (Exception e) {
LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
// CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
}
}
use of org.eclipse.core.runtime.Status in project cubrid-manager by CUBRID.
the class VolumeFolderInfoEditor method loadData.
/**
* load the editor data
*
* @return boolean
*/
public boolean loadData() {
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
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);
} else {
final DbSpaceInfoList model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(model);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initialize();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
task.setDbName(database.getName());
taskJobExecutor.addTask(task);
String serverName = database.getServer().getName();
String dbName = database.getName();
String jobName = Messages.viewVolumeInfoJobName + " - " + volumeFolderName + "@" + dbName + "@" + serverName;
taskJobExecutor.schedule(jobName, null, false, Job.LONG);
return true;
}
use of org.eclipse.core.runtime.Status in project cubrid-manager by CUBRID.
the class VolumeInformationEditor method loadData.
/**
* load the data
*
* @return boolean
*/
public boolean loadData() {
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
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);
} else {
final DbSpaceInfoList model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(model);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initial();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setMinHeight(800);
scrolledComp.setMinWidth(800);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
task.setDbName(database.getName());
taskJobExecutor.addTask(task);
String jobName = Messages.viewVolumeInfoJobName + " - " + dbSpaceInfo.getSpacename() + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.LONG);
return true;
}
use of org.eclipse.core.runtime.Status in project cubrid-manager by CUBRID.
the class RestoreDatabaseDialog method postTaskFinished.
/**
* After a task has been executed, do some thing such as refresh.
*
* @param task the task
* @return IStatus if complete refresh false if run into error
*
*/
public IStatus postTaskFinished(ITask task) {
if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files == null || files.length == 0) {
String filePath = (String) checkFileTask.getData("filePath");
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(Messages.errBackupFileNoExist, filePath));
}
} else if (task instanceof CheckDirTask) {
CheckDirTask checkDirTask = (CheckDirTask) task;
final String[] dirs = checkDirTask.getNoExistDirectory();
if (dirs != null && dirs.length > 0) {
CreateDirDialog dialog = new CreateDirDialog(getShell());
dialog.setDirs(dirs);
if (dialog.open() != IDialogConstants.OK_ID) {
return Status.CANCEL_STATUS;
}
}
}
return Status.OK_STATUS;
}
use of org.eclipse.core.runtime.Status in project cubrid-manager by CUBRID.
the class ConnectDatabaseNodeJobExecutor method exec.
/**
* Execute to connect database
*
* @param monitor the IProgressMonitor
* @return <code>true</code> if successful;<code>false</code>otherwise;
*/
public IStatus exec(final IProgressMonitor monitor) {
monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectDatabase, dbNode.getDbName()));
//Check this database whether exist
List<String> realDbNameList = serverInfo.getAllDatabaseList();
if (!realDbNameList.contains(dbNode.getDbName())) {
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
if (task instanceof VerifyDbUserPasswordTask) {
IStatus status = connectDatabase((VerifyDbUserPasswordTask) task);
if (status == Status.CANCEL_STATUS) {
return Status.CANCEL_STATUS;
}
} else {
task.execute();
}
final String msg = task.getErrorMsg();
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
Aggregations