Search in sources :

Example 51 with DBNDataSource

use of org.jkiss.dbeaver.model.navigator.DBNDataSource in project dbeaver by dbeaver.

the class DefaultNavigatorNodeRenderer method paintNodeDetails.

public void paintNodeDetails(DBNNode node, Tree tree, GC gc, Event event) {
    Color conColor = null;
    Object element = event.item.getData();
    if (element instanceof DBNDatabaseNode) {
        DBPDataSourceContainer ds = ((DBNDatabaseNode) element).getDataSourceContainer();
        conColor = UIUtils.getConnectionColor(ds.getConnectionConfiguration());
    }
    if (conColor != null) {
        gc.setForeground(conColor);
        if (element instanceof DBNDataSource) {
        // int boxSize = event.height - 4;
        // gc.setLineWidth(2);
        // gc.setLineStyle(SWT.LINE_SOLID);
        // gc.fillRectangle(0, event.y + 2, textSize.x, textSize.y);
        // gc.drawRectangle(0, event.y + 2, textSize.x - 1, textSize.y - 1);
        // gc.drawRectangle(event.x - 2, event.y + 1, event.width + 3, event.height - 2/*, event.height / 2, event.height / 2*/);
        // gc.drawLine(event.x, event.y, event.x + event.width, event.y);
        // gc.drawLine(10, event.y + event.height - 1, event.x + event.width, event.y + event.height - 1);
        // gc.drawLine(event.x, event.y + event.height - 1, event.x + event.width, event.y + event.height - 1);
        } else {
            int oldLineWidth = gc.getLineWidth();
            gc.setForeground(conColor);
            gc.setLineWidth(3);
            if (((TreeItem) event.item).getItemCount() > 0) {
                gc.drawLine(event.x - 20, event.y - 1, event.x - 20, event.y + event.height + 1);
            } else {
                gc.drawLine(event.x - 4, event.y - 1, event.x - 4, event.y + event.height + 1);
            }
            gc.setLineWidth(oldLineWidth);
        }
    }
}
Also used : DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) Color(org.eclipse.swt.graphics.Color) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 52 with DBNDataSource

use of org.jkiss.dbeaver.model.navigator.DBNDataSource 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)

Example 53 with DBNDataSource

use of org.jkiss.dbeaver.model.navigator.DBNDataSource in project dbeaver by serge-rider.

the class NavigatorHandlerLocalFolderCreate method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structSelection = (IStructuredSelection) selection;
        List<DBNDataSource> dataSources = new ArrayList<>();
        DBNProjectDatabases databasesNode = null;
        DBNLocalFolder parentFolder = null;
        for (Iterator iter = structSelection.iterator(); iter.hasNext(); ) {
            Object element = iter.next();
            if (element instanceof DBNDataSource) {
                dataSources.add((DBNDataSource) element);
                element = ((DBNDataSource) element).getParentNode();
            }
            if (element instanceof DBNLocalFolder) {
                parentFolder = (DBNLocalFolder) element;
                databasesNode = parentFolder.getParentNode();
            } else if (element instanceof DBNProjectDatabases) {
                databasesNode = (DBNProjectDatabases) element;
            }
        }
        if (databasesNode != null) {
            createFolder(HandlerUtil.getActiveWorkbenchWindow(event), activePart, databasesNode, parentFolder, dataSources, null);
        }
    }
    return null;
}
Also used : DBNProjectDatabases(org.jkiss.dbeaver.model.navigator.DBNProjectDatabases) DBNLocalFolder(org.jkiss.dbeaver.model.navigator.DBNLocalFolder) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 54 with DBNDataSource

use of org.jkiss.dbeaver.model.navigator.DBNDataSource in project dbeaver by serge-rider.

the class EntityEditorInput method getToolTipText.

@Override
public String getToolTipText() {
    StringBuilder toolTip = new StringBuilder();
    for (DBNNode node = getNavigatorNode(); node != null; node = node.getParentNode()) {
        if (node instanceof DBSFolder) {
            continue;
        }
        toolTip.append(node.getNodeType());
        toolTip.append(": ");
        toolTip.append(node.getNodeName());
        toolTip.append(" \n");
        if (node instanceof DBNDataSource) {
            break;
        }
    }
    return toolTip.toString();
}
Also used : DBSFolder(org.jkiss.dbeaver.model.struct.DBSFolder) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource)

Example 55 with DBNDataSource

use of org.jkiss.dbeaver.model.navigator.DBNDataSource in project dbeaver by serge-rider.

the class DiagramCreateWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = UIUtils.createPlaceholder(parent, 1);
    Composite configGroup = UIUtils.createControlGroup(placeholder, ERDMessages.wizard_page_diagram_create_group_settings, 2, GridData.FILL_BOTH, 0);
    //$NON-NLS-1$
    final Text projectNameText = UIUtils.createLabelText(configGroup, "Name", null);
    projectNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            diagram.setName(projectNameText.getText());
            updateState();
        }
    });
    Label contentLabel = UIUtils.createControlLabel(configGroup, ERDMessages.wizard_page_diagram_create_label_init_content);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = 2;
    contentLabel.setLayoutData(gd);
    final DBNProject rootNode = DBeaverCore.getInstance().getNavigatorModel().getRoot().getProject(DBeaverCore.getInstance().getProjectRegistry().getActiveProject());
    if (rootNode == null) {
        setControl(placeholder);
        return;
    }
    contentTree = new DatabaseNavigatorTree(configGroup, rootNode.getDatabases(), SWT.SINGLE | SWT.CHECK);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    gd.heightHint = 400;
    contentTree.setLayoutData(gd);
    CheckboxTreeViewer viewer = (CheckboxTreeViewer) contentTree.getViewer();
    viewer.setCheckStateProvider(new ICheckStateProvider() {

        @Override
        public boolean isChecked(Object element) {
            return false;
        }

        @Override
        public boolean isGrayed(Object element) {
            if (element instanceof DBNDatabaseNode && !(element instanceof DBNDataSource)) {
                DBSObject object = ((DBNDatabaseNode) element).getObject();
                if (object instanceof DBSTable) {
                    return false;
                }
            }
            return true;
        }
    });
    setControl(placeholder);
}
Also used : DBNProject(org.jkiss.dbeaver.model.navigator.DBNProject) DBSTable(org.jkiss.dbeaver.model.struct.rdb.DBSTable) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Aggregations

DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)59 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)26 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)23 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)17 DBException (org.jkiss.dbeaver.DBException)15 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)13 DBNResource (org.jkiss.dbeaver.model.navigator.DBNResource)12 DBNProject (org.jkiss.dbeaver.model.navigator.DBNProject)10 ArrayList (java.util.ArrayList)8 ISelection (org.eclipse.jface.viewers.ISelection)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 DBNLocalFolder (org.jkiss.dbeaver.model.navigator.DBNLocalFolder)8 IFile (org.eclipse.core.resources.IFile)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)6 SQLScriptExecuteSettings (org.jkiss.dbeaver.tools.sql.SQLScriptExecuteSettings)6 GridData (org.eclipse.swt.layout.GridData)5 IResource (org.eclipse.core.resources.IResource)4 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)4 ICheckStateProvider (org.eclipse.jface.viewers.ICheckStateProvider)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4