Search in sources :

Example 1 with DashboardListViewer

use of org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer in project dbeaver by serge-rider.

the class DashboardItemViewDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite dialogArea = super.createDialogArea(parent);
    Composite chartGroup = UIUtils.createPlaceholder(dialogArea, 1);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 450;
    gd.heightHint = 300;
    chartGroup.setLayoutData(gd);
    chartGroup.setLayout(new FillLayout());
    DashboardListViewer dashboardListViewer = new DashboardListViewer(parentPart.getSite(), sourceItem.getDataSourceContainer(), parentPart.getViewConfiguration());
    dashboardListViewer.setSingleChartMode(true);
    dashboardListViewer.createControl(chartGroup);
    DashboardItem targetItem = new DashboardItem((DashboardList) dashboardListViewer.getDefaultGroup(), sourceItem.getDashboardId());
    targetItem.moveViewFrom(sourceItem, false);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DashboardItem(org.jkiss.dbeaver.ui.dashboard.control.DashboardItem) FillLayout(org.eclipse.swt.layout.FillLayout) DashboardListViewer(org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)

Example 2 with DashboardListViewer

use of org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer in project dbeaver by serge-rider.

the class DashboardUpdater method getViewDashboards.

private void getViewDashboards(DashboardView view, List<DashboardContainer> dashboards) {
    long currentTime = System.currentTimeMillis();
    DashboardListViewer viewManager = view.getDashboardListViewer();
    if (viewManager == null || !viewManager.getDataSourceContainer().isConnected()) {
        return;
    }
    for (DashboardGroupContainer group : viewManager.getGroups()) {
        for (DashboardContainer dashboard : group.getItems()) {
            Date lastUpdateTime = dashboard.getLastUpdateTime();
            if (lastUpdateTime == null || (currentTime - lastUpdateTime.getTime()) >= dashboard.getUpdatePeriod()) {
                dashboards.add(dashboard);
            }
        }
    }
}
Also used : DashboardListViewer(org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)

Example 3 with DashboardListViewer

use of org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer in project dbeaver by serge-rider.

the class DashboardView method createDashboardControls.

private void createDashboardControls(Composite parent) {
    try {
        String secondaryId = getViewSite().getSecondaryId();
        if (CommonUtils.isEmpty(secondaryId)) {
            throw new IllegalStateException("Dashboard view requires active database connection");
        }
        String projectName, dsId;
        int divPos = secondaryId.indexOf("/");
        if (divPos == -1) {
            projectName = null;
            dsId = secondaryId;
        } else {
            projectName = secondaryId.substring(0, divPos);
            dsId = secondaryId.substring(divPos + 1);
        }
        dataSourceContainer = DBUtils.findDataSource(projectName, dsId);
        if (dataSourceContainer == null) {
            throw new IllegalStateException("Database connection '" + dsId + "' not found");
        }
        dataSourceContainer.getRegistry().addDataSourceListener(this);
        configuration = new DashboardViewConfiguration(dataSourceContainer, secondaryId);
        dashboardListViewer = new DashboardListViewer(getSite(), dataSourceContainer, configuration);
        dashboardListViewer.createControl(parent);
        dashboardListViewer.createDashboardsFromConfiguration();
        getSite().setSelectionProvider(dashboardListViewer);
        parent.layout(true, true);
        updateStatus();
    } catch (Throwable e) {
        log.error("Error initializing dashboard view", e);
    }
}
Also used : DashboardViewConfiguration(org.jkiss.dbeaver.ui.dashboard.model.DashboardViewConfiguration) DashboardListViewer(org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)

Example 4 with DashboardListViewer

use of org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer in project dbeaver by dbeaver.

the class DashboardUpdater method getViewDashboards.

private void getViewDashboards(DashboardView view, List<DashboardContainer> dashboards) {
    long currentTime = System.currentTimeMillis();
    DashboardListViewer viewManager = view.getDashboardListViewer();
    if (viewManager == null || !viewManager.getDataSourceContainer().isConnected()) {
        return;
    }
    for (DashboardGroupContainer group : viewManager.getGroups()) {
        for (DashboardContainer dashboard : group.getItems()) {
            Date lastUpdateTime = dashboard.getLastUpdateTime();
            if (lastUpdateTime == null || (currentTime - lastUpdateTime.getTime()) >= dashboard.getUpdatePeriod()) {
                dashboards.add(dashboard);
            }
        }
    }
}
Also used : DashboardListViewer(org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)

Example 5 with DashboardListViewer

use of org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer in project dbeaver by dbeaver.

the class DashboardView method createDashboardControls.

private void createDashboardControls(Composite parent) {
    try {
        String secondaryId = getViewSite().getSecondaryId();
        if (CommonUtils.isEmpty(secondaryId)) {
            throw new IllegalStateException("Dashboard view requires active database connection");
        }
        String projectName, dsId;
        int divPos = secondaryId.indexOf("/");
        if (divPos == -1) {
            projectName = null;
            dsId = secondaryId;
        } else {
            projectName = secondaryId.substring(0, divPos);
            dsId = secondaryId.substring(divPos + 1);
        }
        dataSourceContainer = DBUtils.findDataSource(projectName, dsId);
        if (dataSourceContainer == null) {
            throw new IllegalStateException("Database connection '" + dsId + "' not found");
        }
        dataSourceContainer.getRegistry().addDataSourceListener(this);
        configuration = new DashboardViewConfiguration(dataSourceContainer, secondaryId);
        dashboardListViewer = new DashboardListViewer(getSite(), dataSourceContainer, configuration);
        dashboardListViewer.createControl(parent);
        dashboardListViewer.createDashboardsFromConfiguration();
        getSite().setSelectionProvider(dashboardListViewer);
        parent.layout(true, true);
        updateStatus();
    } catch (Throwable e) {
        log.error("Error initializing dashboard view", e);
    }
}
Also used : DashboardViewConfiguration(org.jkiss.dbeaver.ui.dashboard.model.DashboardViewConfiguration) DashboardListViewer(org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)

Aggregations

DashboardListViewer (org.jkiss.dbeaver.ui.dashboard.control.DashboardListViewer)6 FillLayout (org.eclipse.swt.layout.FillLayout)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 DashboardItem (org.jkiss.dbeaver.ui.dashboard.control.DashboardItem)2 DashboardViewConfiguration (org.jkiss.dbeaver.ui.dashboard.model.DashboardViewConfiguration)2