Issue #2722 - Add auto refresh to sub manager dialog

Former-commit-id: 8d92217e94 [formerly 227eb23157] [formerly 04ee397f2b] [formerly ab9621698f [formerly 04ee397f2b [formerly f678a39b37040bd637cf210f73aaef0841bda36e]]]
Former-commit-id: ab9621698f
Former-commit-id: 81c8a2b9d2b37711be589b2c809d03532ae8c45f [formerly e984863c1c]
Former-commit-id: f7566298b2
This commit is contained in:
Mike Duff 2014-02-04 12:40:52 -06:00
parent ce1a2a4d41
commit e1023f0bc4
6 changed files with 78 additions and 40 deletions

View file

@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthUtilizationDlg;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil;
/**
* Action handler for the bandwidth scheduling graph.
@ -40,6 +39,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil;
* Nov 25, 2012 1269 mpduff Initial creation.
* Dec 13, 2012 1269 lvenable Updated to use a graph utility for the graph data.
* Oct 28, 2013 2430 mpduff Removed redraw if already open.
* Jan 29, 2014 2722 mpduff Don't get graph data up front.
*
* </pre>
*
@ -58,11 +58,9 @@ public class BandwidthScheduleGraphAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (dlg == null || dlg.isDisposed()) {
GraphDataUtil gdu = new GraphDataUtil(null);
gdu.retrieveData();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
dlg = new BandwidthUtilizationDlg(shell, gdu);
dlg = new BandwidthUtilizationDlg(shell);
dlg.open();
} else {
dlg.open();

View file

@ -103,7 +103,8 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Nov 19, 2013 1531 mpduff Made graph resizable.
* Nov 25, 2013 2545 mpduff Default to Opsnet if Network not available yet.
* Dec 17, 2013 2633 mpduff Fix redraw problems..
* Jan 09, 2013 2633 mpduff On resize keep graph at bottom so data are always visible.
* Jan 09, 2014 2633 mpduff On resize keep graph at bottom so data are always visible.
* Jan 29, 2014 2722 mpduff Changed how graph data are requested.
* </pre>
*
* @author lvenable
@ -250,13 +251,13 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* @param graphDataUtil
* Bandwidth graph data object
*/
public BandwidthCanvasComp(Composite parentComp, GraphDataUtil graphDataUtil) {
public BandwidthCanvasComp(Composite parentComp) {
super(parentComp, SWT.BORDER);
this.parentComp = parentComp;
this.display = this.parentComp.getDisplay();
this.graphDataUtil = graphDataUtil;
this.bgd = this.graphDataUtil.getGraphData(false);
this.graphDataUtil = new GraphDataUtil(this);
this.bgd = this.graphDataUtil.getGraphData();
init();
}
@ -265,7 +266,6 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* Initialize method.
*/
private void init() {
this.graphDataUtil.setDataUpdateCallback(this);
NotificationManagerJob.addObserver("notify.msg", this);
this.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
@ -1409,7 +1409,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* @param graphData
* Bandwidth graph data.
*/
public void setGraphData(BandwidthGraphData graphData) {
private void setGraphData(BandwidthGraphData graphData) {
this.bgd = graphData;
generateCanvasSettings();
@ -1527,14 +1527,15 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
// Do a full update every 10 minutes
if (fullUpdateMinuteCount > 10) {
graphDataUtil.requestGraphDataUsingThread();
fullUpdateMinuteCount = 0;
}
}
}
}
/**
* This method will update the subscription table with any updates,
* deletions, or new subscriptions.
* This method will update the graph with any updates, deletions, or new
* subscriptions.
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
@ -1559,7 +1560,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
VizApp.runAsync(new Runnable() {
@Override
public void run() {
setGraphData(graphDataUtil.getGraphData(true));
setGraphData(graphDataUtil.getGraphData());
updateCanvasSettings();
updateCanvases();
layout();

View file

@ -53,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
* Nov 19, 2013 1531 mpduff Made resizable.
* Jan 29, 2014 2722 mpduff GraphDataUtil not in this class.
*
* </pre>
*
@ -77,9 +78,6 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
/** Graph composite */
private BandwidthCanvasComp canvasComp;
/** Graph data utility class */
private final GraphDataUtil graphDataUtil;
private MenuItem displayOpsNetMI;
private MenuItem displaySbnMI;
@ -92,12 +90,10 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
* @param graphDataUtil
* Graph data utility object
*/
public BandwidthUtilizationDlg(Shell parent, GraphDataUtil graphDataUtil) {
public BandwidthUtilizationDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE, CAVE.DO_NOT_BLOCK
| CAVE.INDEPENDENT_SHELL);
setText("Bandwidth Utilization");
this.graphDataUtil = graphDataUtil;
}
/**
@ -133,7 +129,7 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
mainComp.setLayout(gl);
mainComp.setLayoutData(gd);
canvasComp = new BandwidthCanvasComp(mainComp, graphDataUtil);
canvasComp = new BandwidthCanvasComp(mainComp);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gl = new GridLayout(1, false);

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Dec 12, 2012 1269 lvenable Initial creation
* Feb 14, 2013 1596 djohnson Remove sysouts, correct statusHandler class, handle null response.
* Mar 26, 2013 1827 djohnson Graph data should be requested from data delivery.
* Jan 29, 2014 2722 mpduff Callback is now passed in.
*
* </pre>
*
@ -67,7 +68,7 @@ public class GraphDataUtil implements Runnable {
private BandwidthGraphData graphData;
/** Callback called when the data has been updated */
private IDataUpdated dataUpdatedCB;
private final IDataUpdated dataUpdatedCB;
/** Executor service used for the threaded data retrieval */
private final ExecutorService service = Executors.newSingleThreadExecutor();
@ -83,21 +84,10 @@ public class GraphDataUtil implements Runnable {
this.dataUpdatedCB = dataUpdatedCB;
}
/**
* Set the updated data callback.
*
* @param dataUpdatedCB
* Call back called when the data has been updated via separate
* thread.
*/
public void setDataUpdateCallback(IDataUpdated dataUpdatedCB) {
this.dataUpdatedCB = dataUpdatedCB;
}
/**
* Perform a data retrieval on the UI thread.
*/
public void retrieveData() {
private void retrieveData() {
response = sendRequest(request);
if (response != null) {
@ -115,10 +105,11 @@ public class GraphDataUtil implements Runnable {
* returning the data.
* @return Bandwidth graph data.
*/
public BandwidthGraphData getGraphData(boolean newData) {
if (newData || graphData == null) {
public BandwidthGraphData getGraphData() {
if (graphData == null) {
retrieveData();
}
return graphData;
}

View file

@ -26,6 +26,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.xml.bind.JAXBException;
@ -72,6 +75,7 @@ import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
@ -148,6 +152,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Dec 05, 2013 2570 skorolev Show All subscriptions.
* Jan 08, 2014 2642 mpduff Update dialog for permissions, adding site to shared
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Feb 04, 2014 2722 mpduff Add auto-refresh task.
* </pre>
*
* @author mpduff
@ -278,6 +283,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
/** New menu */
private MenuItem newMI;
private final ScheduledExecutorService scheduler;
/**
* Constructor
*
@ -292,6 +299,9 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
| CAVE.DO_NOT_BLOCK);
this.filter = filter;
scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new RefreshTask(), 15, 15,
TimeUnit.MINUTES);
setText("Data Delivery Subscription Manager");
}
@ -364,6 +374,17 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
super.disposed();
scheduler.shutdownNow();
}
/**
* Create subscription menu.
*/
@ -659,8 +680,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
*/
@Override
public void handleRefresh() {
tableComp.populateData();
tableComp.populateTable();
tableComp.handleRefresh();
}
private void createBottomButtons() {
@ -1511,4 +1531,21 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
newMI.setEnabled(enable);
tableComp.enableMenus(enable);
}
/**
* Private inner work thread used to auto refresh dialog.
*/
private class RefreshTask implements Runnable {
@Override
public void run() {
if (TimeUtil.currentTimeMillis() - tableComp.getLastUpdateTime() >= TimeUtil.MILLIS_PER_MINUTE * 5) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
handleRefresh();
}
});
}
}
}
}

View file

@ -57,6 +57,7 @@ import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
@ -110,6 +111,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Jan 08, 2014 2642 mpduff Enable/disable menus based on site, allow user to add their site to a shared sub.
* Feb 04, 2014 2722 mpduff Add last update time.
* @version 1.0
*/
@ -163,6 +165,9 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
/** Currently selected site */
private boolean currentSiteSelected;
/** Last table update time */
protected long lastUpdateTime = TimeUtil.currentTimeMillis();
/**
* Constructor.
*
@ -760,6 +765,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
lastUpdateTime = TimeUtil.currentTimeMillis();
if (!isDisposed()) {
handleRefresh();
}
@ -783,9 +789,11 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
*/
@Override
public void handleRefresh() {
populateData();
populateTable();
if (!isDisposed()) {
populateData();
populateTable();
this.lastUpdateTime = TimeUtil.currentTimeMillis();
}
}
@Override
@ -888,4 +896,11 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
});
job.schedule();
}
/**
* @return the lastUpdateTime
*/
public long getLastUpdateTime() {
return lastUpdateTime;
}
}