use of com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos 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.cubridmanager.core.logs.model.ManagerLogInfos in project cubrid-manager by CUBRID.
the class GetManagerLogListTask method getLogContentV1.
private ManagerLogInfos getLogContentV1() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
ManagerLogInfos managerLogInfos = new ManagerLogInfos();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open") != null && node.getValue("open").equals("accesslog")) {
// for
ManagerLogInfoList managerLogList = new ManagerLogInfoList();
String[] users = node.getValues("user");
String[] tasknames = node.getValues("taskname");
String[] times = node.getValues("time");
if (users != null) {
addLogToManagerLogList(managerLogList, users, tasknames, times);
managerLogInfos.setAccessLog(managerLogList);
}
} else if (node != null && node.getValue("open") != null && node.getValue("open").equals("errorlog")) {
// for
ManagerLogInfoList managerLogList = new ManagerLogInfoList();
String[] users = null;
users = node.getValues("user");
String[] tasknames = node.getValues("taskname");
String[] times = node.getValues("time");
String[] errornotes = node.getValues("errornote");
if (users != null) {
addLogToManagerLogList(managerLogList, users, tasknames, times, errornotes);
managerLogInfos.setErrorLog(managerLogList);
}
}
}
return managerLogInfos;
}
use of com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos in project cubrid-manager by CUBRID.
the class LogEditorPart method managerConnect.
/**
* each page of manager log connect
*
*/
public void managerConnect() {
GetManagerLogListTask task = null;
if (charsetName == null) {
task = new GetManagerLogListTask(this.cubridNode.getServer().getServerInfo());
} else {
task = new GetManagerLogListTask(this.cubridNode.getServer().getServerInfo(), charsetName);
}
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (final 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);
} else {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
GetManagerLogListTask getLogListTask = (GetManagerLogListTask) task;
ManagerLogInfos managerLogInfos = (ManagerLogInfos) getLogListTask.getLogContent();
setManagerLogInfo(managerLogInfos, false);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(task);
String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Aggregations