Search in sources :

Example 6 with INavigatorNodeActionHandler

use of org.jkiss.dbeaver.ui.navigator.INavigatorNodeActionHandler in project dbeaver by dbeaver.

the class StatisticsNavigatorNodeRenderer method getDetailsTipText.

private String getDetailsTipText(DBNNode element, Tree tree, Event event) {
    if (element instanceof DBNDatabaseNode) {
        if (element instanceof DBNDataSource) {
            if (DBWorkbench.getPlatform().getPreferenceStore().getBoolean(NavigatorPreferences.NAVIGATOR_SHOW_NODE_ACTIONS)) {
                // Detect active action
                INavigatorNodeActionHandler overActionButton = getActionButtonFor(element, tree, event);
                if (overActionButton != null) {
                    return overActionButton.getNodeActionToolTip(view, element);
                }
            }
            if (DBWorkbench.getPlatform().getPreferenceStore().getBoolean(NavigatorPreferences.NAVIGATOR_SHOW_CONNECTION_HOST_NAME)) {
                return DataSourceUtils.getDataSourceAddressText(((DBNDataSource) element).getDataSourceContainer());
            }
            return null;
        }
        if (DBWorkbench.getPlatform().getPreferenceStore().getBoolean(NavigatorPreferences.NAVIGATOR_SHOW_STATISTICS_INFO)) {
            if (event.x > getTreeWidth(tree) - PERCENT_FILL_WIDTH) {
                DBSObject object = ((DBNDatabaseNode) element).getObject();
                if (object instanceof DBPObjectStatistics && ((DBPObjectStatistics) object).hasStatistics()) {
                    long statObjectSize = ((DBPObjectStatistics) object).getStatObjectSize();
                    if (statObjectSize > 0) {
                        String formattedSize;
                        try {
                            DBDDataFormatter formatter = object.getDataSource().getContainer().getDataFormatterProfile().createFormatter(DBDDataFormatter.TYPE_NAME_NUMBER, null);
                            formattedSize = formatter.formatValue(statObjectSize);
                        } catch (Exception e) {
                            formattedSize = String.valueOf(statObjectSize);
                        }
                        return "Object size on disk: " + formattedSize + " bytes";
                    }
                }
            }
        // renderObjectStatistics((DBNDatabaseNode) element, tree, gc, event);
        }
    }
    return null;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBDDataFormatter(org.jkiss.dbeaver.model.data.DBDDataFormatter) INavigatorNodeActionHandler(org.jkiss.dbeaver.ui.navigator.INavigatorNodeActionHandler) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBException(org.jkiss.dbeaver.DBException)

Aggregations

INavigatorNodeActionHandler (org.jkiss.dbeaver.ui.navigator.INavigatorNodeActionHandler)6 ScrollBar (org.eclipse.swt.widgets.ScrollBar)2 DBException (org.jkiss.dbeaver.DBException)2 DBDDataFormatter (org.jkiss.dbeaver.model.data.DBDDataFormatter)2 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2