提交 7d3ecc50 编写于 作者: S Serge Rider

Reference panel init fix (get correct ref entity + provide correct eec...

Reference panel init fix (get correct ref entity + provide correct eec context). Fixes cross-database references


Former-commit-id: 75a7a479
上级 00d6a792
......@@ -18,6 +18,7 @@ package org.jkiss.dbeaver.model.runtime;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.jkiss.dbeaver.DBException;
......@@ -99,7 +100,13 @@ public abstract class AbstractJob extends Job
finished = false;
RuntimeUtils.setThreadName(getName());
return this.run(progressMonitor);
IStatus result = this.run(progressMonitor);
if (!logErrorStatus(result)) {
if (!result.isOK()) {
log.error("Error running job '" + getName() + "' execution: " + result.getMessage());
}
}
return result;
} catch (Throwable e) {
log.error(e);
return GeneralUtils.makeExceptionStatus(e);
......@@ -110,6 +117,20 @@ public abstract class AbstractJob extends Job
}
}
private boolean logErrorStatus(IStatus status) {
if (status.getException() != null) {
log.error("Error during job '" + getName() + "' execution", status.getException());
return true;
} else if (status instanceof MultiStatus) {
for (IStatus cStatus : status.getChildren()) {
if (logErrorStatus(cStatus)) {
return true;
}
}
}
return false;
}
protected abstract IStatus run(DBRProgressMonitor monitor);
......
......@@ -1133,7 +1133,6 @@ public class ResultSetViewer extends Viewer
activePanelTab.getControl().setFocus();
}
}
getPresentationSettings().panelsVisible = show;
if (saveSettings) {
savePresentationSettings();
......@@ -2912,9 +2911,15 @@ public class ResultSetViewer extends Viewer
@Override
public void updatePanelsContent(boolean forceRefresh) {
updateEditControls();
for (IResultSetPanel panel : getActivePanels()) {
panel.refresh(forceRefresh);
IResultSetPanel visiblePanel = getVisiblePanel();
if (visiblePanel != null) {
visiblePanel.refresh(forceRefresh);
}
// for (IResultSetPanel panel : getActivePanels()) {
// if (visiblePanel == panel) {
// panel.refresh(forceRefresh);
// }
// }
}
@Override
......
......@@ -111,7 +111,9 @@ public class ReferencesPanel implements IResultSetPanel {
@Override
public void refresh(boolean force) {
resultsContainer.refreshReferences();
if (presentation.getController().getVisiblePanel() == this) {
resultsContainer.refreshReferences();
}
}
@Override
......
......@@ -30,6 +30,7 @@ import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.data.DBDDataFilter;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
......@@ -103,7 +104,7 @@ class ReferencesResultsContainer implements IResultSetContainer {
@Override
public DBCExecutionContext getExecutionContext() {
return parentController.getExecutionContext();
return DBUtils.getDefaultContext(dataContainer, false);
}
@Override
......@@ -184,7 +185,7 @@ class ReferencesResultsContainer implements IResultSetContainer {
if (assoc instanceof DBSEntityReferrer) {
List<? extends DBSEntityAttributeRef> attrs = ((DBSEntityReferrer) assoc).getAttributeReferences(monitor);
if (!CommonUtils.isEmpty(attrs)) {
ReferenceKey referenceKey = new ReferenceKey(false, entity, assoc, attrs);
ReferenceKey referenceKey = new ReferenceKey(false, assoc.getAssociatedEntity(), assoc, attrs);
refs.add(referenceKey);
}
}
......
......@@ -138,11 +138,6 @@ public class FilterValueEditPopup extends Dialog {
});
}
// Resize the column to fit the contents
UIUtils.asyncExec(() -> {
UIUtils.packColumns(table, false);
});
FocusAdapter focusListener = new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
......@@ -185,6 +180,10 @@ public class FilterValueEditPopup extends Dialog {
filter.filterPattern = null;
filter.loadValues();
// Resize the column to fit the contents
UIUtils.asyncExec(() -> {
UIUtils.packColumns(table, true);
});
return tableComposite;
}
......
......@@ -41,6 +41,7 @@ import org.jkiss.dbeaver.model.data.DBDLabelValuePair;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.exec.DBExecUtils;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.sql.SQLUtils;
......@@ -55,6 +56,7 @@ import org.jkiss.dbeaver.ui.data.editors.ReferenceValueEditor;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.List;
import java.util.regex.Pattern;
......@@ -224,11 +226,19 @@ class GenericFilterValueEdit {
if (tableViewer.getTable().getColumns().length > 1)
tableViewer.getTable().getColumn(1).setText("Count");
loadJob = new KeyLoadJob("Load '" + attr.getName() + "' values") {
private List<DBDLabelValuePair> result;
@Override
List<DBDLabelValuePair> readEnumeration(DBRProgressMonitor monitor) throws DBException {
try (DBCSession session = DBUtils.openUtilSession(monitor, attributeEnumerable, "Read value enumeration")) {
return attributeEnumerable.getValueEnumeration(session, filterPattern, MAX_MULTI_VALUES);
}
DBExecUtils.tryExecuteRecover(monitor, attributeEnumerable.getDataSource(), param -> {
try (DBCSession session = DBUtils.openUtilSession(monitor, attributeEnumerable, "Read value enumeration")) {
result = attributeEnumerable.getValueEnumeration(session, filterPattern, MAX_MULTI_VALUES);
} catch (DBException e) {
throw new InvocationTargetException(e);
}
});
return result;
}
};
loadJob.schedule();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册