use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by dbeaver.
the class DashboardManagerDialog method createDashboard.
private void createDashboard() {
DashboardDescriptor newDashboard = new DashboardDescriptor("", "", "", "");
DashboardEditDialog editDialog = new DashboardEditDialog(getShell(), newDashboard);
if (editDialog.open() == IDialogConstants.OK_ID) {
DashboardRegistry.getInstance().createDashboard(newDashboard);
refreshDashboards();
}
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by dbeaver.
the class DashboardManagerDialog method copyDashboard.
private void copyDashboard() {
DashboardDescriptor newDashboard = new DashboardDescriptor(selectedDashboard);
newDashboard.setCustom(true);
String origId = newDashboard.getId();
for (int i = 2; ; i++) {
if (DashboardRegistry.getInstance().getDashboard(newDashboard.getId()) != null) {
newDashboard.setId(origId + " " + i);
} else {
break;
}
}
DashboardEditDialog editDialog = new DashboardEditDialog(getShell(), newDashboard);
if (editDialog.open() == IDialogConstants.OK_ID) {
DashboardRegistry.getInstance().createDashboard(newDashboard);
refreshDashboards();
}
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardManagerDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
getShell().setMinimumSize(300, 300);
Composite dialogArea = super.createDialogArea(parent);
Composite group = UIUtils.createPlaceholder(dialogArea, 2);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
{
treeViewer = new TreeViewer(group, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 300;
treeViewer.getControl().setLayoutData(gd);
treeViewer.getTree().setHeaderVisible(true);
UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, UIDashboardMessages.dialog_dashboard_manager_treecolumn_name);
// UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, "Description");
treeViewer.setContentProvider(new TreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
List<? extends DBPNamedObject> result = null;
if (parentElement instanceof List) {
result = (List) parentElement;
} else if (parentElement instanceof DBPDataSourceProviderDescriptor) {
result = DashboardRegistry.getInstance().getDashboards((DBPDataSourceProviderDescriptor) parentElement, false);
} else if (parentElement instanceof DBPDriver) {
result = DashboardRegistry.getInstance().getDashboards((DBPDriver) parentElement, false);
}
if (result == null) {
return new Object[0];
}
result.sort(DBUtils.nameComparator());
return result.toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof DashboardDescriptor) {
return false;
}
return true;
}
});
treeViewer.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DBPNamedObject element = (DBPNamedObject) cell.getElement();
if (cell.getColumnIndex() == 0) {
cell.setText(element.getName());
if (element instanceof DBPDriver) {
cell.setImage(DBeaverIcons.getImage(((DBPDriver) element).getIcon()));
} else if (element instanceof DBPDataSourceProviderDescriptor) {
cell.setImage(DBeaverIcons.getImage(((DBPDataSourceProviderDescriptor) element).getIcon()));
} else if (element instanceof DashboardDescriptor) {
DashboardDescriptor dashboardDescriptor = (DashboardDescriptor) element;
DBPImage icon;
if (dashboardDescriptor.isCustom()) {
icon = DBIcon.TYPE_OBJECT;
} else {
icon = dashboardDescriptor.getDefaultViewType().getIcon();
}
if (icon != null) {
cell.setImage(DBeaverIcons.getImage(icon));
}
}
} else {
if (element instanceof DBPDriver) {
cell.setText(CommonUtils.notEmpty(((DBPDriver) element).getDescription()));
} else if (element instanceof DBPDataSourceProviderDescriptor) {
cell.setText(((DBPDataSourceProviderDescriptor) element).getDescription());
}
}
}
});
treeViewer.setInput(DashboardRegistry.getInstance().getAllSupportedSources());
treeViewer.addDoubleClickListener(event -> {
if (selectedDashboard != null) {
editDashboard();
}
});
treeViewer.addSelectionChangedListener(event -> {
this.selectedDashboard = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof DashboardDescriptor) {
this.selectedDashboard = (DashboardDescriptor) selectedObject;
}
}
this.updateButtons();
});
UIUtils.asyncExec(() -> {
treeViewer.expandAll();
UIUtils.packColumns(treeViewer.getTree(), true, null);
});
}
{
Composite buttonBar = new Composite(group, SWT.TOP);
buttonBar.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_VERTICAL);
buttonBar.setLayoutData(gd);
newButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_new, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createDashboard();
}
});
newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
copyButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_copy, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
copyDashboard();
}
});
copyButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_edit, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editDashboard();
}
});
editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
deleteButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_delete, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteDashboard();
}
});
deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
UIUtils.createInfoLabel(dialogArea, UIDashboardMessages.dialog_dashboard_manager_infolabel_predifined_dashboard);
this.updateButtons();
return group;
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardManagerDialog method copyDashboard.
private void copyDashboard() {
DashboardDescriptor newDashboard = new DashboardDescriptor(selectedDashboard);
newDashboard.setCustom(true);
String origId = newDashboard.getId();
for (int i = 2; ; i++) {
if (DashboardRegistry.getInstance().getDashboard(newDashboard.getId()) != null) {
newDashboard.setId(origId + " " + i);
} else {
break;
}
}
DashboardEditDialog editDialog = new DashboardEditDialog(getShell(), newDashboard);
if (editDialog.open() == IDialogConstants.OK_ID) {
DashboardRegistry.getInstance().createDashboard(newDashboard);
refreshDashboards();
}
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardManagerDialog method createDashboard.
private void createDashboard() {
DashboardDescriptor newDashboard = new DashboardDescriptor("", "", "", "");
DashboardEditDialog editDialog = new DashboardEditDialog(getShell(), newDashboard);
if (editDialog.open() == IDialogConstants.OK_ID) {
DashboardRegistry.getInstance().createDashboard(newDashboard);
refreshDashboards();
}
}
Aggregations