提交 09a7a1a5 编写于 作者: J jurgen

Error editor input fixed.

上级 ae85993a
......@@ -27,7 +27,7 @@ import org.jkiss.dbeaver.model.DBPConnectionEventType;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.runtime.AbstractJob;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
/**
* Connect job
......@@ -36,6 +36,7 @@ public class ConnectJob extends EventProcessorJob
{
private volatile Thread connectThread;
private boolean reflect = true;
private IStatus connectStatus;
public ConnectJob(
DataSourceDescriptor container)
......@@ -45,6 +46,10 @@ public class ConnectJob extends EventProcessorJob
setProperty(IProgressConstants.ICON_PROPERTY, ImageDescriptor.createFromImage(container.getDriver().getIcon()));
}
public IStatus getConnectStatus() {
return connectStatus;
}
@Override
protected IStatus run(DBRProgressMonitor monitor)
{
......@@ -67,13 +72,16 @@ public class ConnectJob extends EventProcessorJob
}
processEvents(DBPConnectionEventType.AFTER_CONNECT);
connectStatus = Status.OK_STATUS;
}
catch (Throwable ex) {
UIUtils.showErrorDialog(
null,
NLS.bind(CoreMessages.runtime_jobs_connect_status_error, container.getName()),
null,
ex);
connectStatus = RuntimeUtils.makeExceptionStatus(ex);
// UIUtils.showErrorDialog(
// null,
// NLS.bind(CoreMessages.runtime_jobs_connect_status_error, container.getName()),
// null,
// ex);
}
return Status.OK_STATUS;
}
......
......@@ -98,24 +98,22 @@ public class DataSourceConnectHandler extends DataSourceHandler
}
};
if (monitor != null) {
final IStatus result = connectJob.runSync(monitor);
connectJob.runSync(monitor);
final IStatus result = connectJob.getConnectStatus();
jobChangeAdapter.done(new IJobChangeEvent() {
@Override
public long getDelay()
{
public long getDelay() {
return 0;
}
@Override
public Job getJob()
{
public Job getJob() {
return connectJob;
}
@Override
public IStatus getResult()
{
return result;
public IStatus getResult() {
return connectJob.getConnectStatus();
}
});
if (!result.isOK()) {
......
......@@ -22,13 +22,16 @@ import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchAdapter;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPDataSource;
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;
......@@ -57,12 +60,18 @@ public abstract class DatabaseEditorInput<NODE extends DBNDatabaseNode> implemen
protected DatabaseEditorInput(NODE node, DBECommandContext commandContext)
{
this.node = node;
this.executionContext = node.getDataSource().getDefaultContext(false);
this.commandContext = commandContext != null ?
commandContext :
new DBECommandContextImpl(
this.executionContext,
false);
DBPDataSource dataSource = node.getDataSource();
if (dataSource != null) {
this.executionContext = dataSource.getDefaultContext(false);
this.commandContext = commandContext != null ?
commandContext :
new DBECommandContextImpl(
this.executionContext,
false);
} else {
this.executionContext = null;
this.commandContext = null;
}
}
@Override
......@@ -125,7 +134,13 @@ public abstract class DatabaseEditorInput<NODE extends DBNDatabaseNode> implemen
@Override
public DBSDataSourceContainer getDataSourceContainer()
{
return executionContext.getDataSource().getContainer();
if (executionContext != null) {
return executionContext.getDataSource().getContainer();
} else if (node instanceof DBNDataSource) {
return node.getDataSourceContainer();
} else {
return null;
}
}
@Override
......@@ -157,6 +172,7 @@ public abstract class DatabaseEditorInput<NODE extends DBNDatabaseNode> implemen
return defaultFolderId;
}
@Nullable
@Override
public DBECommandContext getCommandContext()
{
......
......@@ -53,7 +53,9 @@ public class DatabaseEditorUtils {
}
} else if (editor instanceof DBPContextProvider) {
DBCExecutionContext context = ((DBPContextProvider) editor).getExecutionContext();
bgColor = context.getDataSource().getContainer().getConnectionInfo().getColor();
if (context != null) {
bgColor = context.getDataSource().getContainer().getConnectionInfo().getColor();
}
}
if (bgColor == null) {
rootComposite.setBackground(null);
......
......@@ -20,6 +20,7 @@ package org.jkiss.dbeaver.ui.editors;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPContextProvider;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.edit.DBECommandContext;
......@@ -53,6 +54,7 @@ public interface IDatabaseEditorInput extends IEditorInput, DBPContextProvider {
* Command context
* @return command context
*/
@Nullable
DBECommandContext getCommandContext();
/**
......
......@@ -140,6 +140,7 @@ public class EntityEditor extends MultiPageDatabaseEditor
return getEditorInput().getDatabaseObject();
}
@Nullable
public DBECommandContext getCommandContext()
{
return getEditorInput().getCommandContext();
......@@ -390,7 +391,10 @@ public class EntityEditor extends MultiPageDatabaseEditor
firePropertyChange(IEditorPart.PROP_DIRTY);
}
};
getCommandContext().addCommandListener(commandListener);
DBECommandContext commandContext = getCommandContext();
if (commandContext != null) {
commandContext.addCommandListener(commandListener);
}
// Property listener
addPropertyListener(new IPropertyListener() {
......
......@@ -45,12 +45,14 @@ public class EntityEditorPropertyTester extends PropertyTester
}
EntityEditor editor = (EntityEditor)receiver;
DBECommandContext commandContext = editor.getEditorInput().getCommandContext();
if (property.equals(PROP_CAN_UNDO)) {
return commandContext.getUndoCommand() != null;
} else if (property.equals(PROP_CAN_REDO)) {
return commandContext.getRedoCommand() != null;
} else if (property.equals(PROP_DIRTY)) {
return commandContext.isDirty();
if (commandContext != null) {
if (property.equals(PROP_CAN_UNDO)) {
return commandContext.getUndoCommand() != null;
} else if (property.equals(PROP_CAN_REDO)) {
return commandContext.getRedoCommand() != null;
} else if (property.equals(PROP_DIRTY)) {
return commandContext.isDirty();
}
}
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册