use of org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation in project dbeaver by serge-rider.
the class SpreadsheetCommandHandler method getActiveSpreadsheet.
public static Spreadsheet getActiveSpreadsheet(ExecutionEvent event) {
Object control = HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
if (control instanceof Spreadsheet) {
return (Spreadsheet) control;
}
IResultSetController rsv = ResultSetCommandHandler.getActiveResultSet(HandlerUtil.getActivePart(event));
if (rsv != null) {
IResultSetPresentation activePresentation = rsv.getActivePresentation();
if (activePresentation instanceof SpreadsheetPresentation) {
return ((SpreadsheetPresentation) activePresentation).getSpreadsheet();
}
}
return null;
}
use of org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation in project dbeaver by dbeaver.
the class SpreadsheetCommandHandler method getActiveSpreadsheet.
public static Spreadsheet getActiveSpreadsheet(ExecutionEvent event) {
Object control = HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
if (control instanceof Spreadsheet) {
return (Spreadsheet) control;
}
IResultSetController rsv = ResultSetCommandHandler.getActiveResultSet(HandlerUtil.getActivePart(event));
if (rsv != null) {
IResultSetPresentation activePresentation = rsv.getActivePresentation();
if (activePresentation instanceof SpreadsheetPresentation) {
return ((SpreadsheetPresentation) activePresentation).getSpreadsheet();
}
}
return null;
}
use of org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation in project dbeaver by serge-rider.
the class MetaDataPanel method createContents.
@Override
public Control createContents(final IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
this.colorDisabled = presentation.getControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
this.attributeList = new MetaDataTable(parent);
this.attributeList.setFitWidth(true);
this.attributeList.getItemsViewer().addSelectionChangedListener(event -> {
DBDAttributeBinding attr = getSelectedAttribute();
if (attr != null && !updateSelection) {
if (isAttributeVisible(attr)) {
updateSelection = true;
try {
presentation.setCurrentAttribute(attr);
} finally {
updateSelection = false;
}
}
}
});
if (this.presentation instanceof ISelectionProvider) {
final ISelectionChangedListener listener = event -> {
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(e -> ((ISelectionProvider) presentation).removeSelectionChangedListener(listener));
}
return this.attributeList;
}
Aggregations