提交 0feb8241 编写于 作者: S serge-rider

#4209 Dashboard renderer fix. Reset command

上级 b09d8c04
......@@ -125,7 +125,8 @@ public class DashboardItem extends Composite implements DashboardContainer {
private void paintItem(PaintEvent e) {
Point itemSize = getSize();
e.gc.setLineWidth(groupContainer.getSelectedItem() == this ? 2 : 1);
e.gc.drawRoundRectangle(1, 1, itemSize.x - 2, itemSize.y - 2, 3, 3);
e.gc.setLineStyle(groupContainer.getSelectedItem() == this ? SWT.LINE_SOLID : SWT.LINE_DASH);
e.gc.drawRectangle(1, 1, itemSize.x - 2, itemSize.y - 2);
// if (groupContainer.getSelectedItem() == this) {
// e.gc.drawRoundRectangle(1, 1, itemSize.x - 4, itemSize.y - 4, 3, 3);
// }
......@@ -273,6 +274,15 @@ public class DashboardItem extends Composite implements DashboardContainer {
lastUpdateTime = new Date();
}
@Override
public void resetDashboardData() {
UIUtils.asyncExec(() -> {
if (renderer != null) {
renderer.resetDashboardData(this, lastUpdateTime);
}
});
}
@Override
public long getUpdatePeriod() {
return dashboardDescriptor.getUpdatePeriod();
......
......@@ -33,6 +33,8 @@ public interface DashboardRenderer {
void updateDashboardData(DashboardContainer container, Date lastUpdateTime, DashboardDataset dataset);
void resetDashboardData(DashboardContainer dashboardItem, Date lastUpdateTime);
void disposeDashboard(DashboardContainer container);
}
......@@ -223,8 +223,20 @@ public class DashboardRendererHistogram implements DashboardRenderer {
}
@Override
public void disposeDashboard(DashboardContainer container) {
public void resetDashboardData(DashboardContainer container, Date lastUpdateTime) {
DashboardChartComposite chartComposite = (DashboardChartComposite) container.getDashboardControl();
if (chartComposite.isDisposed()) {
return;
}
JFreeChart chart = chartComposite.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
TimeSeriesCollection chartDataset = (TimeSeriesCollection) plot.getDataset();
chartDataset.removeAllSeries();
}
@Override
public void disposeDashboard(DashboardContainer container) {
}
}
......@@ -60,10 +60,13 @@ public interface DashboardContainer {
void updateDashboardData(DashboardDataset dataset);
void resetDashboardData();
/**
* Dashboard update period in seconds
*/
long getUpdatePeriod();
Control getDashboardControl();
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.dashboard.view;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
public class HandlerDashboardAddItem extends HandlerDashboardAbstract {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DashboardView view = getActiveDashboardView(event);
if (view != null) {
}
return null;
}
}
\ No newline at end of file
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.dashboard.view;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
public class HandlerDashboardRemoveItem extends HandlerDashboardAbstract {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DashboardView view = getActiveDashboardView(event);
if (view != null) {
}
return null;
}
}
\ No newline at end of file
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.dashboard.view;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardContainer;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardGroupContainer;
public class HandlerDashboardReset extends HandlerDashboardAbstract {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DashboardView view = getActiveDashboardView(event);
if (view != null) {
for (DashboardGroupContainer gc : view.getDashboardViewManager().getGroups()) {
for (DashboardContainer dc : gc.getItems()) {
dc.resetDashboardData();
}
}
}
return null;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册