提交 7e19c9e7 编写于 作者: S serge-rider

Metadata panel selection listener. RSV panels UI fix

上级 14f39688
......@@ -682,7 +682,14 @@ public class ResultSetViewer extends Viewer
}
}
}
if (!settings.enabledPanelIds.contains(settings.activePanelId)) {
settings.activePanelId = null;
}
if (!settings.enabledPanelIds.isEmpty()) {
if (settings.activePanelId == null) {
// Set first panel active
settings.activePanelId = settings.enabledPanelIds.iterator().next();
}
for (String panelId : settings.enabledPanelIds) {
if (!CommonUtils.isEmpty(panelId)) {
activatePanel(panelId, panelId.equals(settings.activePanelId), false);
......@@ -742,7 +749,7 @@ public class ResultSetViewer extends Viewer
if (!show) {
viewerSash.setMaximizedControl(presentationPanel);
if (activePanelTab != null && UIUtils.hasFocus(activePanelTab.getControl())) {
if (activePanelTab != null && !activePanelTab.getControl().isDisposed() && UIUtils.hasFocus(activePanelTab.getControl())) {
// Set focus to presentation
activePresentation.getControl().setFocus();
}
......@@ -754,7 +761,7 @@ public class ResultSetViewer extends Viewer
activePresentation.updateValueView();
// Set focus to panel
if (activePanelTab != null && UIUtils.hasFocus(activePresentation.getControl())) {
if (activePanelTab != null && !activePanelTab.getControl().isDisposed() && UIUtils.hasFocus(activePresentation.getControl())) {
activePanelTab.getControl().setFocus();
}
}
......
......@@ -20,6 +20,8 @@ package org.jkiss.dbeaver.ui.controls.resultset.panel;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
......@@ -56,6 +58,7 @@ public class MetaDataPanel implements IResultSetPanel {
private MetaDataTable attributeList;
private List<DBDAttributeBinding> curAttributes;
private Color colorDisabled;
private transient boolean updateSelection = false;
public MetaDataPanel() {
}
......@@ -86,23 +89,41 @@ public class MetaDataPanel implements IResultSetPanel {
@Override
public void selectionChanged(SelectionChangedEvent event) {
DBDAttributeBinding attr = getSelectedAttribute();
if (attr != null) {
if (attr != null && !updateSelection) {
if (isAttributeVisible(attr)) {
presentation.setCurrentAttribute(attr);
updateSelection = true;
try {
presentation.setCurrentAttribute(attr);
} finally {
updateSelection = false;
}
}
}
}
});
if (this.presentation instanceof ISelectionProvider) {
((ISelectionProvider) this.presentation).addSelectionChangedListener(
new ISelectionChangedListener() {
final ISelectionChangedListener listener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
DBDAttributeBinding attr = presentation.getCurrentAttribute();
if (attr != null && attr != getSelectedAttribute()) {
attributeList.getItemsViewer().setSelection(new StructuredSelection(attr));
if (!updateSelection && MetaDataPanel.this.presentation.getController().getVisiblePanel() == MetaDataPanel.this) {
DBDAttributeBinding attr = presentation.getCurrentAttribute();
if (attr != null && attr != getSelectedAttribute()) {
updateSelection = true;
try {
attributeList.getItemsViewer().setSelection(new StructuredSelection(attr));
} finally {
updateSelection = false;
}
}
}
}
};
((ISelectionProvider) this.presentation).addSelectionChangedListener(listener);
attributeList.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
((ISelectionProvider) presentation).removeSelectionChangedListener(listener);
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册