Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99624 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
342555fad2
commit
d406e0371a
|
@ -35,14 +35,14 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
||||
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
private static final String WIDTH = "640px";
|
||||
private static final String HEIGHT = "378px";
|
||||
private static final String PANELWIDTH = "620px";
|
||||
private static final String PANELHEIGHT = "308px";
|
||||
private static final String PROGRESSWIDTH = "618px";
|
||||
|
||||
|
||||
private EventBus eventBus;
|
||||
private String taskId;
|
||||
private MonitorUpdater progressUpdater;
|
||||
|
@ -52,27 +52,24 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
private TRId trId;
|
||||
private String reason;
|
||||
private String details;
|
||||
|
||||
|
||||
protected boolean backgroundBtnEnabled=true;
|
||||
|
||||
protected ToolButton backgroundBtn;
|
||||
|
||||
|
||||
protected ArrayList<MonitorDialogListener> listeners = new ArrayList<MonitorDialogListener>();
|
||||
protected ArrayList<MonitorDialogEventUIListener> monitorDialogEventUIListeners = new ArrayList<MonitorDialogEventUIListener>();
|
||||
|
||||
|
||||
private MonitorDetailPanel monitorDetailPanel;
|
||||
|
||||
|
||||
public MonitorDialog(String taskId, EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
this.taskId=taskId;
|
||||
this.taskId = taskId;
|
||||
trId = null;
|
||||
initWindow();
|
||||
create();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void initWindow(){
|
||||
|
||||
protected void initWindow() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
|
@ -81,8 +78,8 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
setClosable(true);
|
||||
setHeadingText("Progress");
|
||||
}
|
||||
|
||||
protected void create(){
|
||||
|
||||
protected void create() {
|
||||
FramedPanel panel = new FramedPanel();
|
||||
panel.setWidth(PANELWIDTH);
|
||||
panel.setHeight(PANELHEIGHT);
|
||||
|
@ -90,41 +87,44 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
panel.setBodyBorder(false);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
/*FlowLayoutContainer progressDetailContainer = new FlowLayoutContainer();
|
||||
progressDetailContainer.setScrollMode(ScrollMode.AUTO);
|
||||
MarginData layoutData = new MarginData(new Margins(5, 5, 5, 5));*/
|
||||
|
||||
|
||||
/*
|
||||
* FlowLayoutContainer progressDetailContainer = new
|
||||
* FlowLayoutContainer();
|
||||
* progressDetailContainer.setScrollMode(ScrollMode.AUTO); MarginData
|
||||
* layoutData = new MarginData(new Margins(5, 5, 5, 5));
|
||||
*/
|
||||
|
||||
ProgressBar progressBar = new ProgressBar();
|
||||
progressBar.setWidth(PROGRESSWIDTH);
|
||||
|
||||
/*FieldSet detailsSet = new FieldSet();
|
||||
detailsSet.setHeadingText("Details");
|
||||
detailsSet.setCollapsible(true);*/
|
||||
|
||||
monitorDetailPanel=new MonitorDetailPanel(eventBus);
|
||||
//detailsSet.add(monitorDetailPanel);
|
||||
|
||||
/*TextField
|
||||
|
||||
FlowLayoutContainer progressDetailContainer = new FlowLayoutContainer();
|
||||
progressDetailContainer.setScrollMode(ScrollMode.ALWAYS);
|
||||
MarginData layoutData = new MarginData(new Margins(0, 5, 0, 0));
|
||||
c.add(new TextButton("Button 1"), layoutData);
|
||||
c.add(new TextButton("Button 2"), layoutData);
|
||||
c.add(new TextButton("Button 3"), layoutData);
|
||||
Viewport v = new Viewport();
|
||||
v.add(c);
|
||||
RootPanel.get().add(v);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* FieldSet detailsSet = new FieldSet();
|
||||
* detailsSet.setHeadingText("Details");
|
||||
* detailsSet.setCollapsible(true);
|
||||
*/
|
||||
|
||||
monitorDetailPanel = new MonitorDetailPanel(eventBus);
|
||||
// detailsSet.add(monitorDetailPanel);
|
||||
|
||||
/*
|
||||
* TextField
|
||||
*
|
||||
* FlowLayoutContainer progressDetailContainer = new
|
||||
* FlowLayoutContainer();
|
||||
* progressDetailContainer.setScrollMode(ScrollMode.ALWAYS); MarginData
|
||||
* layoutData = new MarginData(new Margins(0, 5, 0, 0)); c.add(new
|
||||
* TextButton("Button 1"), layoutData); c.add(new
|
||||
* TextButton("Button 2"), layoutData); c.add(new
|
||||
* TextButton("Button 3"), layoutData); Viewport v = new Viewport();
|
||||
* v.add(c); RootPanel.get().add(v);
|
||||
*/
|
||||
|
||||
btnOk = new TextButton("Ok");
|
||||
btnOk.setWidth("70px");
|
||||
//btnOk.setIcon(ResourceBundle.INSTANCE.ok());
|
||||
//btnOk.setIconAlign(IconAlign.RIGHT);
|
||||
// btnOk.setIcon(ResourceBundle.INSTANCE.ok());
|
||||
// btnOk.setIconAlign(IconAlign.RIGHT);
|
||||
btnOk.setTitle("Ok");
|
||||
|
||||
|
||||
|
||||
btnOk.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -132,14 +132,13 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btnBackground = new TextButton("Background");
|
||||
btnBackground.setWidth("70px");
|
||||
//btnBackground.setIcon(ResourceBundle.INSTANCE.background());
|
||||
//btnBackground.setIconAlign(IconAlign.RIGHT);
|
||||
// btnBackground.setIcon(ResourceBundle.INSTANCE.background());
|
||||
// btnBackground.setIconAlign(IconAlign.RIGHT);
|
||||
btnBackground.setTitle("Background");
|
||||
|
||||
|
||||
|
||||
btnBackground.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -147,17 +146,14 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
btnAbort = new TextButton("Abort");
|
||||
btnAbort.setWidth("70px");
|
||||
//btnAbort.setIcon(ResourceBundle.INSTANCE.abort());
|
||||
//btnAbort.setIconAlign(IconAlign.RIGHT);
|
||||
// btnAbort.setIcon(ResourceBundle.INSTANCE.abort());
|
||||
// btnAbort.setIconAlign(IconAlign.RIGHT);
|
||||
btnAbort.setTitle("Abort");
|
||||
|
||||
|
||||
|
||||
btnAbort.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -165,52 +161,53 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
flowButton.add(btnOk, new BoxLayoutData(new Margins(0, 4, 0, 4)));
|
||||
flowButton.add(btnBackground, new BoxLayoutData(new Margins(0, 4, 0, 4)));
|
||||
flowButton.add(btnBackground,
|
||||
new BoxLayoutData(new Margins(0, 4, 0, 4)));
|
||||
flowButton.add(btnAbort, new BoxLayoutData(new Margins(0, 4, 0, 4)));
|
||||
|
||||
|
||||
v.add(progressBar,
|
||||
new VerticalLayoutData(1, -1, new Margins(5, 5, 5, 5)));
|
||||
|
||||
v.add(monitorDetailPanel,new VerticalLayoutData(1, -1, new Margins(5, 5, 5, 5)));
|
||||
|
||||
v.add(flowButton, new VerticalLayoutData(1, 36,
|
||||
|
||||
v.add(progressBar, new VerticalLayoutData(1, -1,
|
||||
new Margins(5, 5, 5, 5)));
|
||||
|
||||
/*progressDetailContainer.add(progressBar, layoutData);
|
||||
progressDetailContainer.add(monitorDetailPanel, layoutData);*/
|
||||
|
||||
|
||||
v.add(monitorDetailPanel, new VerticalLayoutData(1, -1, new Margins(5,
|
||||
5, 5, 5)));
|
||||
|
||||
v.add(flowButton,
|
||||
new VerticalLayoutData(1, 36, new Margins(5, 5, 5, 5)));
|
||||
|
||||
/*
|
||||
* progressDetailContainer.add(progressBar, layoutData);
|
||||
* progressDetailContainer.add(monitorDetailPanel, layoutData);
|
||||
*/
|
||||
|
||||
panel.add(v);
|
||||
add(panel);
|
||||
|
||||
|
||||
|
||||
|
||||
OperationMonitorSession operationMonitorSession = new OperationMonitorSession(
|
||||
taskId);
|
||||
progressUpdater = new MonitorUpdater(operationMonitorSession);
|
||||
progressUpdater.addListener(new MonitorBarUpdater(progressBar));
|
||||
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
addMonitorDialogEventUIListener(progressUpdater);
|
||||
show();
|
||||
btnOk.setVisible(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void startAbort() {
|
||||
btnOk.setEnabled(false);
|
||||
btnBackground.setEnabled(false);
|
||||
btnAbort.setEnabled(false);
|
||||
fireRequestAborted();
|
||||
fireRequestAborted();
|
||||
}
|
||||
|
||||
|
||||
protected void startBackground() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -221,6 +218,38 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
close();
|
||||
}
|
||||
|
||||
public boolean isAbortBtnEnabled() {
|
||||
if (btnAbort != null) {
|
||||
return btnAbort.isEnabled();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAbortBtnEnabled(boolean abortBtnEnabled) {
|
||||
if (btnBackground != null) {
|
||||
btnBackground.setEnabled(abortBtnEnabled);
|
||||
btnBackground.setVisible(abortBtnEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isBackgroundBtnEnabled() {
|
||||
if (btnBackground != null) {
|
||||
return btnBackground.isEnabled();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundBtnEnabled(boolean backgroundBtnEnabled) {
|
||||
if (btnBackground != null) {
|
||||
btnBackground.setEnabled(backgroundBtnEnabled);
|
||||
btnBackground.setVisible(backgroundBtnEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void addProgressDialogListener(MonitorDialogListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
@ -228,19 +257,20 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
public void removeProgressDialogListener(MonitorDialogListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addMonitorDialogEventUIListener(MonitorDialogEventUIListener listener) {
|
||||
|
||||
public void addMonitorDialogEventUIListener(
|
||||
MonitorDialogEventUIListener listener) {
|
||||
monitorDialogEventUIListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeMonitorDialogEventUIListener(MonitorDialogEventUIListener listener) {
|
||||
public void removeMonitorDialogEventUIListener(
|
||||
MonitorDialogEventUIListener listener) {
|
||||
monitorDialogEventUIListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void monitorInitializing(OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
forceLayout();
|
||||
|
@ -249,7 +279,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
@Override
|
||||
public void monitorUpdate(OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
forceLayout();
|
||||
|
@ -257,7 +287,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
@Override
|
||||
public void monitorComplete(TRId trId, OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
Log.debug("Operation Complete return: " + trId.toString());
|
||||
|
@ -270,20 +300,21 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void monitorFailed(Throwable caught, String reason, String details, OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
public void monitorFailed(Throwable caught, String reason, String details,
|
||||
OperationMonitor operationMonitor) {
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
|
||||
|
||||
}
|
||||
forceLayout();
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
fireOperationFailed(caught,reason,details);
|
||||
fireOperationFailed(caught, reason, details);
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateInvocation() {
|
||||
|
@ -295,8 +326,9 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void monitorStopped(TRId trId, String reason, String details, OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
public void monitorStopped(TRId trId, String reason, String details,
|
||||
OperationMonitor operationMonitor) {
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
|
||||
|
@ -312,7 +344,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
@Override
|
||||
public void monitorGeneratingView(OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
forceLayout();
|
||||
|
@ -321,13 +353,11 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
@Override
|
||||
public void monitorValidate(OperationMonitor operationMonitor) {
|
||||
if(monitorDetailPanel!=null){
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void monitorAborted() {
|
||||
|
@ -339,7 +369,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
public void monitorPutInBackground() {
|
||||
fireOperationPutInBackground();
|
||||
close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
|
@ -347,34 +377,35 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String reason, String details) {
|
||||
protected void fireOperationFailed(Throwable caught, String reason,
|
||||
String details) {
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationFailed(caught,reason, details);
|
||||
listener.operationFailed(caught, reason, details);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationStopped(trId, reason, details);
|
||||
}
|
||||
|
||||
|
||||
protected void fireOperationAborted() {
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationAborted();
|
||||
}
|
||||
|
||||
|
||||
protected void fireOperationPutInBackground() {
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationPutInBackground();
|
||||
}
|
||||
|
||||
protected void fireRequestAborted(){
|
||||
for(MonitorDialogEventUIListener listener: monitorDialogEventUIListeners){
|
||||
|
||||
protected void fireRequestAborted() {
|
||||
for (MonitorDialogEventUIListener listener : monitorDialogEventUIListeners) {
|
||||
listener.requestAborted();
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireRequestPutInBackground(){
|
||||
for(MonitorDialogEventUIListener listener: monitorDialogEventUIListeners){
|
||||
|
||||
protected void fireRequestPutInBackground() {
|
||||
for (MonitorDialogEventUIListener listener : monitorDialogEventUIListeners) {
|
||||
listener.requestPutInBackground();
|
||||
}
|
||||
}
|
||||
|
@ -384,30 +415,25 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
*/
|
||||
@Override
|
||||
protected void initTools() {
|
||||
/*if (backgroundBtnEnabled) {
|
||||
backgroundBtn = new ToolButton(ToolButton.CLOSE);
|
||||
backgroundBtn.setToolTip("Put in the background");
|
||||
backgroundBtn.addSelectHandler(new SelectHandler() {
|
||||
/*
|
||||
* if (backgroundBtnEnabled) { backgroundBtn = new
|
||||
* ToolButton(ToolButton.CLOSE);
|
||||
* backgroundBtn.setToolTip("Put in the background");
|
||||
* backgroundBtn.addSelectHandler(new SelectHandler() {
|
||||
*
|
||||
* @Override public void onSelect(SelectEvent event) { hide(); } });
|
||||
*
|
||||
* header.addTool(backgroundBtn); }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
header.addTool(backgroundBtn);
|
||||
}*/
|
||||
|
||||
super.initTools();
|
||||
|
||||
|
||||
closeBtn.setVisible(false);
|
||||
/*
|
||||
closeBtn.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
close();
|
||||
}
|
||||
});*/
|
||||
* closeBtn.addSelectHandler(new SelectHandler() {
|
||||
*
|
||||
* public void onSelect(SelectEvent event) { close(); } });
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -416,8 +442,8 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
}
|
||||
|
||||
public void updateOperationMonitor(OperationMonitor operationMonitor){
|
||||
if(monitorDetailPanel!=null){
|
||||
public void updateOperationMonitor(OperationMonitor operationMonitor) {
|
||||
if (monitorDetailPanel != null) {
|
||||
monitorDetailPanel.update(operationMonitor);
|
||||
}
|
||||
forceLayout();
|
||||
|
|
Loading…
Reference in New Issue