use of org.eclipse.ui.IWorkbenchPage 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 org.eclipse.ui.IWorkbenchPage 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 org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class CopyToClipboardAction method openNewQueryEditor.
/**
* Open the new query editor
*
* @return IEditorPart
*/
private IEditorPart openNewQueryEditor() {
IWorkbenchPage activePage = LayoutUtil.getActivePage();
QueryUnit queryUnit = new QueryUnit();
Object[] selected = getSelectedObj();
CubridDatabase database = null;
if (selected.length >= 1 && selected[0] instanceof ISchemaNode) {
database = ((ISchemaNode) selected[0]).getDatabase();
queryUnit.setDatabase(database);
}
try {
IEditorPart editor = activePage.openEditor(queryUnit, QueryEditorPart.ID);
if (editor != null && database != null) {
((QueryEditorPart) editor).connect(database);
}
return editor;
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
return null;
}
use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class CopyToClipboardAction method doRun.
/**
* Do run
*
* @param objects
*/
protected void doRun(final Object[] objects) {
final int len = objects.length;
final Display display = PlatformUI.getWorkbench().getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
IEditorPart ep = null;
if (isCopyToEditor) {
IWorkbenchPage activePage = LayoutUtil.getActivePage();
ep = activePage.getActiveEditor();
if (!(ep instanceof QueryEditorPart)) {
ep = openNewQueryEditor();
}
if (!(ep instanceof QueryEditorPart)) {
ep = null;
}
}
StringBuffer allTableSql = new StringBuffer();
for (int i = 0; i < len; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) objects[i];
String sql = getStmtSQL(table, ep);
if (sql != null && sql.trim().length() > 0) {
allTableSql.append(sql);
allTableSql.append(StringUtil.NEWLINE);
allTableSql.append(StringUtil.NEWLINE);
}
}
if (allTableSql.length() > 0) {
if (isCopyToEditor) {
if (ep instanceof QueryEditorPart) {
((QueryEditorPart) ep).setQuery(allTableSql.toString(), true, false, false);
}
} else {
CommonUITool.copyContentToClipboard(allTableSql.toString());
}
}
}
});
}
use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class AbstractBasicPart method postSchemaDataChanged.
public void postSchemaDataChanged(PropertyChangeEvent evt) {
String property = evt.getPropertyName();
boolean isDataChanged = PropertyChangeProvider.CHILD_CHANGE.equals(property) | PropertyChangeProvider.OUTPUT_CHANGE.equals(property) | PropertyChangeProvider.INPUT_CHANGE.equals(property) | PropertyChangeProvider.TEXT_CHANGE.equals(property);
if (!isDataChanged) {
return;
}
IWorkbenchPage page = getActivePage();
if (page == null) {
return;
}
IEditorPart editor = page.getActiveEditor();
if (editor instanceof ERSchemaEditor) {
ERSchemaEditor erEditor = (ERSchemaEditor) editor;
erEditor.setDirty(true);
}
}
Aggregations