use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardList method addItem.
@Override
public void addItem(String dashboardId) {
DashboardDescriptor dashboardDescriptor = DashboardRegistry.getInstance().getDashboard(dashboardId);
if (dashboardDescriptor == null) {
return;
}
viewContainer.getViewConfiguration().readDashboardConfiguration(dashboardDescriptor);
new DashboardItem(this, dashboardId);
viewContainer.getViewConfiguration().saveSettings();
layout(true, true);
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardAddDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite dialogArea = super.createDialogArea(parent);
// AdvancedListViewer listViewer = new AdvancedListViewer(dialogArea, SWT.NONE);
// listViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
TableViewer dashboardTable = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
dashboardTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
Table table = dashboardTable.getTable();
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
gd.heightHint = 200;
table.setLayoutData(gd);
table.setHeaderVisible(true);
UIUtils.createTableColumn(table, SWT.LEFT, UIDashboardMessages.dialog_add_dashboard_column_name);
UIUtils.createTableColumn(table, SWT.LEFT, UIDashboardMessages.dialog_add_dashboard_column_description);
dashboardTable.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DashboardDescriptor dashboardDescriptor = (DashboardDescriptor) cell.getElement();
if (cell.getColumnIndex() == 0) {
cell.setText(dashboardDescriptor.getName());
} else {
cell.setText(CommonUtils.notEmpty(dashboardDescriptor.getDescription()));
}
}
});
dashboardTable.addDoubleClickListener(event -> {
if (!dashboardTable.getSelection().isEmpty()) {
okPressed();
}
});
dashboardTable.addSelectionChangedListener(event -> {
ISelection selection = dashboardTable.getSelection();
getButton(IDialogConstants.OK_ID).setEnabled(!selection.isEmpty());
if (selection instanceof IStructuredSelection) {
selectedDashboard = (DashboardDescriptor) ((IStructuredSelection) selection).getFirstElement();
}
getButton(IDialogConstants.OK_ID).setEnabled(selectedDashboard != null);
});
table.addPaintListener(e -> {
if (table.getItemCount() == 0) {
final String dbmsName = viewConfiguration.getDataSourceContainer().getDriver().getName();
final String msg = NLS.bind(UIDashboardMessages.dialog_add_dashboard_message_no_more_dashboards_for, dbmsName);
UIUtils.drawMessageOverControl(table, e, msg, 0);
}
});
dashboardTable.setContentProvider(new ListContentProvider());
java.util.List<DashboardDescriptor> dashboards = new ArrayList<>(DashboardRegistry.getInstance().getDashboards(viewConfiguration.getDataSourceContainer(), false));
dashboards.removeIf(descriptor -> viewConfiguration.getDashboardConfig(descriptor.getId()) != null);
dashboardTable.setInput(dashboards);
UIUtils.asyncExec(() -> UIUtils.packColumns(table, true));
return dialogArea;
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class DashboardViewConfiguration method loadSettings.
private void loadSettings() {
File configFile = getConfigFile();
if (!configFile.exists()) {
return;
}
try {
Document document = XMLUtils.parseDocument(configFile);
for (Element viewElement : XMLUtils.getChildElementList(document.getDocumentElement(), "view")) {
openConnectionOnActivate = CommonUtils.getBoolean(viewElement.getAttribute("openConnectionOnActivate"), openConnectionOnActivate);
useSeparateConnection = CommonUtils.getBoolean(viewElement.getAttribute("useSeparateConnection"), useSeparateConnection);
}
for (Element dbElement : XMLUtils.getChildElementList(document.getDocumentElement(), "dashboard")) {
String dashboardId = dbElement.getAttribute("id");
DashboardDescriptor dashboard = DashboardRegistry.getInstance().getDashboard(dashboardId);
if (dashboard != null) {
DashboardItemViewConfiguration itemConfig = new DashboardItemViewConfiguration(dashboard, dbElement);
items.add(itemConfig);
} else {
log.warn("Dashboard '" + dashboardId + "' not found");
}
}
} catch (Exception e) {
log.error("Error loading dashboard view configuration", e);
}
items.sort(Comparator.comparingInt(DashboardItemViewConfiguration::getIndex));
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by serge-rider.
the class HandlerDashboardAddItem method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DashboardView view = getActiveDashboardView(event);
if (view != null) {
DashboardAddDialog addDialog = new DashboardAddDialog(HandlerUtil.getActiveShell(event), view.getConfiguration());
if (addDialog.open() == IDialogConstants.OK_ID) {
DashboardDescriptor selectedDashboard = addDialog.getSelectedDashboard();
if (selectedDashboard != null) {
view.getConfiguration().readDashboardConfiguration(selectedDashboard);
view.getDashboardListViewer().getDefaultGroup().addItem(selectedDashboard.getId());
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.dashboard.registry.DashboardDescriptor in project dbeaver by dbeaver.
the class DashboardViewConfiguration method loadSettings.
private void loadSettings() {
File configFile = getConfigFile();
if (!configFile.exists()) {
return;
}
try {
Document document = XMLUtils.parseDocument(configFile);
for (Element viewElement : XMLUtils.getChildElementList(document.getDocumentElement(), "view")) {
openConnectionOnActivate = CommonUtils.getBoolean(viewElement.getAttribute("openConnectionOnActivate"), openConnectionOnActivate);
useSeparateConnection = CommonUtils.getBoolean(viewElement.getAttribute("useSeparateConnection"), useSeparateConnection);
}
for (Element dbElement : XMLUtils.getChildElementList(document.getDocumentElement(), "dashboard")) {
String dashboardId = dbElement.getAttribute("id");
DashboardDescriptor dashboard = DashboardRegistry.getInstance().getDashboard(dashboardId);
if (dashboard != null) {
DashboardItemViewConfiguration itemConfig = new DashboardItemViewConfiguration(dashboard, dbElement);
items.add(itemConfig);
} else {
log.warn("Dashboard '" + dashboardId + "' not found");
}
}
} catch (Exception e) {
log.error("Error loading dashboard view configuration", e);
}
items.sort(Comparator.comparingInt(DashboardItemViewConfiguration::getIndex));
}
Aggregations