Search in sources :

Example 1 with IToolTipProvider

use of org.eclipse.jface.viewers.IToolTipProvider in project dbeaver by serge-rider.

the class SQLScriptTaskDataSourceSelectorDialog method createScriptColumns.

static void createScriptColumns(ColumnViewer viewer) {
    final ILabelProvider mainLabelProvider = (ILabelProvider) viewer.getLabelProvider();
    ViewerColumnController columnController = new ViewerColumnController("sqlTaskScriptViewer", viewer);
    columnController.setForceAutoSize(true);
    columnController.addColumn(ModelMessages.model_navigator_Name, DTUIMessages.sql_script_task_data_source_selection_dialog_column_description_script, SWT.LEFT, true, true, new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return mainLabelProvider.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            return mainLabelProvider.getImage(element);
        }

        @Override
        public String getToolTipText(Object element) {
            if (mainLabelProvider instanceof IToolTipProvider) {
                return ((IToolTipProvider) mainLabelProvider).getToolTipText(element);
            }
            return null;
        }
    });
    columnController.addColumn(ModelMessages.model_navigator_Connection, DTUIMessages.sql_script_task_data_source_selection_dialog_column_description_script_data_source, SWT.LEFT, true, true, new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof DBNResource) {
                Collection<DBPDataSourceContainer> containers = ((DBNResource) element).getAssociatedDataSources();
                if (!CommonUtils.isEmpty(containers)) {
                    StringBuilder text = new StringBuilder();
                    for (DBPDataSourceContainer container : containers) {
                        if (text.length() > 0) {
                            text.append(", ");
                        }
                        text.append(container.getName());
                    }
                    return text.toString();
                }
            }
            return "";
        }

        @Override
        public Image getImage(Object element) {
            return null;
        }
    });
    columnController.createColumns(true);
}
Also used : ViewerColumnController(org.jkiss.dbeaver.ui.controls.ViewerColumnController) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) IToolTipProvider(org.eclipse.jface.viewers.IToolTipProvider) Collection(java.util.Collection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 2 with IToolTipProvider

use of org.eclipse.jface.viewers.IToolTipProvider in project dbeaver by serge-rider.

the class AdvancedList method onMouseMove.

private void onMouseMove(MouseEvent e) {
    AdvancedListItem item = getItemByPos(e.x, e.y);
    if (item == hoverItem) {
        return;
    }
    AdvancedListItem[] redrawItems = new AdvancedListItem[] { item, hoverItem };
    hoverItem = item;
    if (item == null) {
        toolTipHandler.updateToolTipText(null);
    } else {
        ILabelProvider labelProvider = item.getLabelProvider();
        if (labelProvider instanceof IToolTipProvider) {
            String toolTipText = ((IToolTipProvider) labelProvider).getToolTipText(item.getData());
            if (!CommonUtils.isEmpty(toolTipText)) {
                toolTipHandler.updateToolTipText(toolTipText);
            }
        }
    }
    GC gc = new GC(this);
    try {
        paintList(gc, redrawItems);
    } finally {
        gc.dispose();
    }
}
Also used : IToolTipProvider(org.eclipse.jface.viewers.IToolTipProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) GC(org.eclipse.swt.graphics.GC)

Aggregations

ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)2 IToolTipProvider (org.eclipse.jface.viewers.IToolTipProvider)2 Collection (java.util.Collection)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 GC (org.eclipse.swt.graphics.GC)1 Image (org.eclipse.swt.graphics.Image)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 ViewerColumnController (org.jkiss.dbeaver.ui.controls.ViewerColumnController)1