提交 5fcc29dc 编写于 作者: J jurgen

Remove jface from model.

Former-commit-id: 4a47ba6f
上级 252ebb4d
......@@ -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<CommandInfo> commands = new ArrayList<CommandInfo>();
......@@ -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 {
......
/*
* 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
......@@ -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();
......
......@@ -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<NODE extends DBNDatabaseNode> implemen
this.executionContext = dataSource.getDefaultContext(false);
this.commandContext = commandContext != null ?
commandContext :
new DBECommandContextImpl(
new SimpleCommandContext(
this.executionContext,
false);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册