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);
}
}
}
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;
}
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;
}
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();
}
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);
}
Aggregations