Search in sources :

Example 1 with IResultSetPresentation

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;
}
Also used : IResultSetPresentation(org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)

Example 2 with IResultSetPresentation

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;
}
Also used : IResultSetPresentation(org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)

Example 3 with IResultSetPresentation

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;
}
Also used : DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) Arrays(java.util.Arrays) Nullable(org.jkiss.code.Nullable) DBPImage(org.jkiss.dbeaver.model.DBPImage) DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) NotNull(org.jkiss.code.NotNull) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) TextTransfer(org.eclipse.swt.dnd.TextTransfer) DatabaseObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.DatabaseObjectListControl) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) IResultSetPresentation(org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation) TreeContentProvider(org.jkiss.dbeaver.ui.controls.TreeContentProvider) CommonUtils(org.jkiss.utils.CommonUtils) DBDAttributeBindingMeta(org.jkiss.dbeaver.model.data.DBDAttributeBindingMeta) DBValueFormatting(org.jkiss.dbeaver.model.DBValueFormatting) Collection(java.util.Collection) IContributionManager(org.eclipse.jface.action.IContributionManager) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) Action(org.eclipse.jface.action.Action) org.eclipse.jface.viewers(org.eclipse.jface.viewers) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) IResultSetPanel(org.jkiss.dbeaver.ui.controls.resultset.IResultSetPanel) Color(org.eclipse.swt.graphics.Color) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) Control(org.eclipse.swt.widgets.Control) LoadingJob(org.jkiss.dbeaver.ui.LoadingJob) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding)

Aggregations

IResultSetPresentation (org.jkiss.dbeaver.ui.controls.resultset.IResultSetPresentation)3 IResultSetController (org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 IContributionManager (org.eclipse.jface.action.IContributionManager)1 org.eclipse.jface.viewers (org.eclipse.jface.viewers)1 SWT (org.eclipse.swt.SWT)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Color (org.eclipse.swt.graphics.Color)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Tree (org.eclipse.swt.widgets.Tree)1 NotNull (org.jkiss.code.NotNull)1 Nullable (org.jkiss.code.Nullable)1 DBPImage (org.jkiss.dbeaver.model.DBPImage)1 DBValueFormatting (org.jkiss.dbeaver.model.DBValueFormatting)1 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)1