use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class ResetAdminLogAction method refreshLogEditor.
/**
*
* Refresh the log editor
*
* @param node ICubridNode
*/
private void refreshLogEditor(ICubridNode node) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
IEditorPart editor = activePage.findEditor(node);
if (null != editor) {
LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.viewLogJobName);
GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
task.setPath(logInfo.getPath());
task.setStart("1");
task.setEnd("100");
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
try {
editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class TimeSetAction method run.
/**
* Open dialog
*/
public void run() {
TimeSetDialog timeSetDialog = new TimeSetDialog(getShell());
timeSetDialog.create();
timeSetDialog.getShell().setSize(580, 275);
if (timeSetDialog.open() == Dialog.OK) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) obj[0];
LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
task.setPath(logInfo.getPath());
task.setStart("1");
task.setEnd("100");
TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadLogTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
if (!taskExcutor.isSuccess()) {
return;
}
LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
IEditorPart editor;
try {
editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class RemoveAllDbLogAction method run.
/**
* Remove all database logs
*/
public void run() {
if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
return;
}
Object[] selected = this.getSelectedObj();
DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
//get last file name
String lastDBLog = "";
LogInfo currLogFile;
for (int i = 0, len = path.length; i < len; i++) {
currLogFile = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class)));
if (lastDBLog.compareTo(currLogFile.getPath()) < 0) {
lastDBLog = currLogFile.getPath();
}
}
for (int i = 0, len = path.length - 1; i < len; i++) {
if (!((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath().equals(lastDBLog)) {
path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
}
}
delAllLogTask.setPath(path);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
taskExecutor.addTask(delAllLogTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (!taskExecutor.isSuccess()) {
return;
}
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
ICubridNode parentNode = delNode.getParent().getParent();
parentNode.removeChild(delNode);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage activePage = window.getActivePage();
for (int i = 0, len = path.length; i < len; i++) {
IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
if (!((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath().equals(lastDBLog)) {
treeViewer.remove(((DefaultCubridNode) selected[0]).getChildren().get(i));
if (null != editor) {
activePage.closeEditor(editor, true);
}
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class RemoveAllErrorLogAction method run.
/**
* Remove all error logs
*/
public void run() {
if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
return;
}
Object[] selected = this.getSelectedObj();
DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
for (int i = 0, len = path.length; i < len; i++) {
path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
}
delAllLogTask.setPath(path);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
taskExecutor.addTask(delAllLogTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
ICubridNode parentNode = delNode.getParent().getParent();
parentNode.removeChild(delNode);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
for (int i = 0, len = path.length; i < len; i++) {
IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
treeViewer.remove(((DefaultCubridNode) selected[0]).getChildren().get(i));
if (null != editor) {
activePage.closeEditor(editor, true);
}
}
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class DeleteProcedureAction method run.
public void run() {
// FIXME logic code move to core module
Object[] objects = this.getSelectedObj();
if (objects == null || !isSupported(objects)) {
this.setEnabled(false);
return;
}
Shell shell = getShell();
CubridDatabase database = null;
ISchemaNode node = null;
if (objects[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_PROCEDURE.equals(((ISchemaNode) objects[0]).getType())) {
node = (ISchemaNode) objects[0];
database = node.getDatabase();
}
if (database == null || node == null) {
CommonUITool.openErrorBox(shell, Messages.errSelectProcedure);
return;
}
if (!CommonUITool.openConfirmBox(shell, Messages.msgSureDropProcedure)) {
return;
}
CommonSQLExcuterTask task = new CommonSQLExcuterTask(database.getDatabaseInfo());
String sql = " DROP PROCEDURE " + QuerySyntax.escapeKeyword(node.getName());
task.addSqls(sql);
TaskExecutor taskExcutor = new CommonTaskExec(null);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
ISelectionProvider provider = this.getSelectionProvider();
ICubridNode parent = node.getParent();
if (provider instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer) provider;
for (int i = 0; objects != null && i < objects.length; i++) {
parent.removeChild((ISchemaNode) objects[i]);
}
viewer.remove(parent, objects);
viewer.setSelection(new StructuredSelection(parent), true);
}
}
Aggregations