diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/DBECommandContextImpl.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/AbstractCommandContext.java similarity index 94% rename from plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/DBECommandContextImpl.java rename to plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/AbstractCommandContext.java index c407555dbca3bd773ecaf868dbfd37a66fec8818..8e2d8aa2c7c1a299b2c17b61ca981eeb95e108c6 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/DBECommandContextImpl.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/model/impl/edit/AbstractCommandContext.java @@ -17,11 +17,8 @@ */ package org.jkiss.dbeaver.model.impl.edit; -import org.eclipse.ui.IWorkbenchCommandConstants; -import org.eclipse.ui.commands.ICommandService; import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.core.CoreMessages; -import org.jkiss.dbeaver.core.DBeaverUI; import org.jkiss.dbeaver.core.Log; import org.jkiss.dbeaver.model.DBPObject; import org.jkiss.dbeaver.model.edit.*; @@ -38,9 +35,9 @@ import java.util.*; /** * DBECommandContextImpl */ -public class DBECommandContextImpl implements DBECommandContext { +public abstract class AbstractCommandContext implements DBECommandContext { - static final Log log = Log.getLog(DBECommandContextImpl.class); + static final Log log = Log.getLog(AbstractCommandContext.class); private final DBCExecutionContext executionContext; private final List commands = new ArrayList(); @@ -58,7 +55,7 @@ public class DBECommandContextImpl implements DBECommandContext { * @param atomic atomic context reflect commands in UI only after all comands were executed. Non-atomic * reflects each command at the moment it executed */ - public DBECommandContextImpl(DBCExecutionContext executionContext, boolean atomic) + public AbstractCommandContext(DBCExecutionContext executionContext, boolean atomic) { this.executionContext = executionContext; this.atomic = atomic; @@ -653,13 +650,8 @@ public class DBECommandContextImpl implements DBECommandContext { session.close(); } - private void refreshCommandState() + protected void refreshCommandState() { - ICommandService commandService = (ICommandService) DBeaverUI.getActiveWorkbenchWindow().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements(IWorkbenchCommandConstants.EDIT_UNDO, null); - commandService.refreshElements(IWorkbenchCommandConstants.EDIT_REDO, null); - } } private static class PersistInfo { diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/SimpleCommandContext.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/SimpleCommandContext.java new file mode 100644 index 0000000000000000000000000000000000000000..2bec32cc6b6af75e41ffa12efa7e091e4842dd4f --- /dev/null +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/SimpleCommandContext.java @@ -0,0 +1,45 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2) + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jkiss.dbeaver.ui; + +import org.eclipse.ui.IWorkbenchCommandConstants; +import org.eclipse.ui.commands.ICommandService; +import org.jkiss.dbeaver.core.DBeaverUI; +import org.jkiss.dbeaver.model.exec.DBCExecutionContext; +import org.jkiss.dbeaver.model.impl.edit.AbstractCommandContext; + +/** + * SimpleCommandContext. + * Uses jface command service to update commands state + */ +public class SimpleCommandContext extends AbstractCommandContext { + + public SimpleCommandContext(DBCExecutionContext executionContext, boolean atomic) { + super(executionContext, atomic); + } + + protected void refreshCommandState() + { + ICommandService commandService = (ICommandService) DBeaverUI.getActiveWorkbenchWindow().getService(ICommandService.class); + if (commandService != null) { + commandService.refreshElements(IWorkbenchCommandConstants.EDIT_UNDO, null); + commandService.refreshElements(IWorkbenchCommandConstants.EDIT_REDO, null); + } + } + +} \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerObjectBase.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerObjectBase.java index 31ea66ae63f100cb5f28cf95de010d911a60847e..a630b1b5e8c41049c0a07f8df19416bcf32417ee 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerObjectBase.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerObjectBase.java @@ -26,14 +26,12 @@ import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.core.DBeaverCore; import org.jkiss.dbeaver.core.DBeaverUI; import org.jkiss.dbeaver.core.Log; -import org.jkiss.dbeaver.ui.editors.IDatabaseEditor; -import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput; import org.jkiss.dbeaver.model.DBPDataSource; import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.edit.DBECommand; import org.jkiss.dbeaver.model.edit.DBECommandContext; import org.jkiss.dbeaver.model.edit.DBEStructEditor; -import org.jkiss.dbeaver.model.impl.edit.DBECommandContextImpl; +import org.jkiss.dbeaver.model.impl.edit.AbstractCommandContext; import org.jkiss.dbeaver.model.navigator.DBNContainer; import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder; import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode; @@ -45,9 +43,12 @@ import org.jkiss.dbeaver.model.struct.DBSObjectReference; import org.jkiss.dbeaver.registry.editor.EntityEditorsRegistry; import org.jkiss.dbeaver.runtime.RuntimeUtils; import org.jkiss.dbeaver.ui.DBIcon; +import org.jkiss.dbeaver.ui.SimpleCommandContext; import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.controls.folders.IFolderContainer; import org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog; +import org.jkiss.dbeaver.ui.editors.IDatabaseEditor; +import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput; import org.jkiss.dbeaver.ui.views.navigator.database.DatabaseNavigatorView; import java.lang.reflect.InvocationTargetException; @@ -68,7 +69,7 @@ public abstract class NavigatorHandlerObjectBase extends AbstractHandler { private CommandTarget() { } - private CommandTarget(DBECommandContextImpl context) + private CommandTarget(AbstractCommandContext context) { this.context = context; } @@ -132,7 +133,7 @@ public abstract class NavigatorHandlerObjectBase extends AbstractHandler { // No editor found - create new command context DBPDataSource dataSource = ((DBNDatabaseNode) container).getObject().getDataSource(); if (dataSource != null) { - return new CommandTarget(new DBECommandContextImpl(dataSource.getDefaultContext(true), !openEditor)); + return new CommandTarget(new SimpleCommandContext(dataSource.getDefaultContext(true), !openEditor)); } } return new CommandTarget(); diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java index aceeab45ce4890a9cb1b5f70f596ed255bf4ced5..45d8b98f7db39da266ac7647e4548e06fd7fe838 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/DatabaseEditorInput.java @@ -30,14 +30,17 @@ import org.jkiss.dbeaver.model.DBPPropertySource; import org.jkiss.dbeaver.model.IDataSourceContainerProvider; import org.jkiss.dbeaver.model.edit.DBECommandContext; import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.model.impl.edit.DBECommandContextImpl; import org.jkiss.dbeaver.model.navigator.DBNDataSource; import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode; import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer; import org.jkiss.dbeaver.model.struct.DBSObject; +import org.jkiss.dbeaver.ui.SimpleCommandContext; import org.jkiss.dbeaver.ui.properties.PropertySourceEditable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; /** * DatabaseEditorInput @@ -65,7 +68,7 @@ public abstract class DatabaseEditorInput implemen this.executionContext = dataSource.getDefaultContext(false); this.commandContext = commandContext != null ? commandContext : - new DBECommandContextImpl( + new SimpleCommandContext( this.executionContext, false); } else {