diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/ResourceBundle.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/ResourceBundle.java index 552a0d3..16a1147 100644 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/ResourceBundle.java +++ b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/ResourceBundle.java @@ -125,5 +125,11 @@ public interface ResourceBundle extends ClientBundle { @Source("expandall_32.png") ImageResource expandAll32(); + @Source("plaster_32.png") + ImageResource plaster32(); + + @Source("plaster.png") + ImageResource plaster(); + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png new file mode 100644 index 0000000..5e16f17 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png new file mode 100644 index 0000000..eff1676 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/validation/ValidationsTasksPanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/validation/ValidationsTasksPanel.java index 7b4d4ac..726651f 100644 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/validation/ValidationsTasksPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/validation/ValidationsTasksPanel.java @@ -4,11 +4,14 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.gcube.portlets.user.td.columnwidget.client.progress.ResumeDialogListener; +import org.gcube.portlets.user.td.columnwidget.client.progress.TaskResumeProgressDialog; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.OperationsId; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS; +import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession; import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata; import org.gcube.portlets.user.td.tablewidget.client.custom.ValidationCell; import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; @@ -17,8 +20,11 @@ import org.gcube.portlets.user.td.tablewidget.client.validation.tree.BaseDto; import org.gcube.portlets.user.td.tablewidget.client.validation.tree.FolderDto; import org.gcube.portlets.user.td.tablewidget.client.validation.tree.TreeDataGenerator; import org.gcube.portlets.user.td.tablewidget.client.validation.tree.ValidationDto; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.WidgetRequestEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.WidgetRequestType; import org.gcube.portlets.user.td.widgetcommonevent.shared.RequestProperties; @@ -27,6 +33,8 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.cell.client.Cell.Context; +import com.google.gwt.event.logical.shared.SelectionEvent; +import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.resources.client.ImageResource; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlUtils; @@ -43,6 +51,8 @@ import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.MarginData; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent; +import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent.BeforeShowContextMenuHandler; import com.sencha.gxt.widget.core.client.event.CollapseItemEvent; import com.sencha.gxt.widget.core.client.event.CollapseItemEvent.CollapseItemHandler; import com.sencha.gxt.widget.core.client.event.ExpandItemEvent; @@ -51,6 +61,9 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.grid.ColumnConfig; import com.sencha.gxt.widget.core.client.grid.ColumnModel; +import com.sencha.gxt.widget.core.client.menu.Item; +import com.sencha.gxt.widget.core.client.menu.Menu; +import com.sencha.gxt.widget.core.client.menu.MenuItem; import com.sencha.gxt.widget.core.client.toolbar.ToolBar; import com.sencha.gxt.widget.core.client.treegrid.TreeGrid; @@ -60,15 +73,20 @@ import com.sencha.gxt.widget.core.client.treegrid.TreeGrid; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class ValidationsTasksPanel extends FramedPanel { +public class ValidationsTasksPanel extends FramedPanel implements ResumeDialogListener { protected String WIDTH = "298px"; protected String HEIGHT = "520px"; - + protected ValidationsTasksPanel thisPanel; + + protected Menu contextMenu; + protected MenuItem resumeItem; + protected MenuItem resolveItem; + protected TRId trId; protected VerticalLayoutContainer con; protected EventBus eventBus; protected ValidationsTasksMetadata validationsTasksMetadata; - + protected TreeDataGenerator gen; protected TreeStore store; protected TreeGrid tree; @@ -141,6 +159,7 @@ public class ValidationsTasksPanel extends FramedPanel { super(); Log.debug("ValidationsTasksPanel"); this.eventBus = eventBus; + this.thisPanel=this; forceLayoutOnResize = true; retrieveCurrentTR(); @@ -151,6 +170,7 @@ public class ValidationsTasksPanel extends FramedPanel { Log.debug("ValidationsTasksPanel: " + trId); this.trId = trId; this.eventBus = eventBus; + this.thisPanel=this; forceLayoutOnResize = true; draw(); } @@ -247,8 +267,8 @@ public class ValidationsTasksPanel extends FramedPanel { validationButton.setTrueIcon(ResourceBundle.INSTANCE.ok()); validationButton.setFalseIcon(ResourceBundle.INSTANCE.error()); validationButton.setTrueTitle("Valid"); - validationButton.setFalseTitle("Resolve"); - validationButton.addSelectHandler(new SelectHandler() { + validationButton.setFalseTitle("Error"); + /*validationButton.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { @@ -257,7 +277,7 @@ public class ValidationsTasksPanel extends FramedPanel { requestSolution(context); } - }); + });*/ cc3.setCell(validationButton); @@ -319,7 +339,10 @@ public class ValidationsTasksPanel extends FramedPanel { } }); - + + createContextMenu(); + + ToolBar toolBar = new ToolBar(); TextButton btnExpandAll = new TextButton(); @@ -361,8 +384,11 @@ public class ValidationsTasksPanel extends FramedPanel { protected void requestSolution(Context context) { String key = (String) context.getKey(); BaseDto d = store.findModelWithKey(key); - - String title = ""; + requestResolve(d); + } + + protected void requestResolve(BaseDto d){ + //String title = ""; if (d != null) { Log.debug(d.toString()); if (d instanceof ValidationDto) { @@ -371,11 +397,11 @@ public class ValidationsTasksPanel extends FramedPanel { + v.getDescription() + ", " + v.getValid() + ", " + v.getInvocation() + "]"); if (v.getValid()) { - + } else { if (v.getInvocation() != null) { InvocationS invocationS = v.getInvocation(); - title = invocationS.toString(); + //title = invocationS.toString(); Long op = invocationS.getOperationId(); if (op.compareTo(OperationsId.ChangeToDimensionColumn .toLong()) == 0) { @@ -387,12 +413,14 @@ public class ValidationsTasksPanel extends FramedPanel { invocationS.getRefColumn()); map.put(Constants.REQUEST_PROPERTIES_COLUMNID, invocationS.getColumnId()); - map.put(Constants.REQUEST_PROPERTIES_TASKID, invocationS.getTaskId()); + map.put(Constants.REQUEST_PROPERTIES_TASKID, + invocationS.getTaskId()); RequestProperties props = new RequestProperties(map); widgetRequestEvent.setRequestProperties(props); eventBus.fireEvent(widgetRequestEvent); } else { - UtilsGXT3.info("Invocation Info", title); + //UtilsGXT3.info("Invocation Info", title); + } } } @@ -401,6 +429,124 @@ public class ValidationsTasksPanel extends FramedPanel { } } + + protected void requestResume(BaseDto selected){ + if (selected instanceof ValidationDto) { + ValidationDto v = (ValidationDto) selected; + Log.debug("ValidationDto: [" + v.getId() + ", " + + v.getDescription() + ", " + v.getValid() + ", " + + v.getInvocation() + "]"); + if (v.getInvocation() != null) { + if (v.getValid()) { + UtilsGXT3.info("Resume", "Is valid, resume not applicable"); + } else { + InvocationS invocationS = v.getInvocation(); + String taskId=invocationS.getTaskId(); + if(taskId==null || taskId.isEmpty()){ + UtilsGXT3.alert("Resume", "TaskId is null, resume not applicable"); + } else { + TaskResumeSession taskResumeSession=new TaskResumeSession(trId,taskId); + startTaskResume(taskResumeSession); + } + } + } else { + UtilsGXT3.alert("Resume", "Invocation is null, resume not applicable"); + } + } + + } + + + + protected void createContextMenu() { + contextMenu = new Menu(); + + resumeItem = new MenuItem(); + resumeItem.setText("Resume"); + resumeItem.setIcon(ResourceBundle.INSTANCE.refresh()); + resumeItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + BaseDto selected = tree.getSelectionModel().getSelectedItem(); + Log.debug(selected.toString()); + requestResume(selected); + } + }); + + + + resolveItem = new MenuItem(); + resolveItem.setText("Resolve"); + resolveItem.setIcon(ResourceBundle.INSTANCE.plaster()); + resolveItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + BaseDto selected = tree.getSelectionModel() + .getSelectedItem(); + Log.debug(selected.toString()); + requestResolve(selected); + + } + + }); + contextMenu.add(resumeItem); + contextMenu.setVisible(false); + tree.setContextMenu(contextMenu); + + tree.addBeforeShowContextMenuHandler(new BeforeShowContextMenuHandler() { + + @Override + public void onBeforeShowContextMenu(BeforeShowContextMenuEvent event) { + Menu contextMenu=event.getMenu(); + + BaseDto selected = tree.getSelectionModel() + .getSelectedItem(); + if (selected instanceof ValidationDto) { + ValidationDto v = (ValidationDto) selected; + Log.debug("ValidationDto: [" + v.getId() + ", " + + v.getDescription() + ", " + v.getValid() + ", " + + v.getInvocation() + "]"); + if (v.getInvocation() != null) { + if (v.getValid()) { + contextMenu.clear(); + contextMenu.add(resumeItem); + contextMenu.setVisible(true); + tree.setContextMenu(contextMenu); + } else { + InvocationS invocationS = v.getInvocation(); + Long op = invocationS.getOperationId(); + if (op.compareTo(OperationsId.ChangeToDimensionColumn + .toLong()) == 0) { + contextMenu.clear(); + contextMenu.add(resolveItem); + contextMenu.add(resumeItem); + contextMenu.setVisible(true); + tree.setContextMenu(contextMenu); + } else { + contextMenu.clear(); + contextMenu.add(resumeItem); + contextMenu.setVisible(true); + tree.setContextMenu(contextMenu); + } + } + } else { + contextMenu.clear(); + contextMenu.setVisible(false); + tree.setContextMenu(contextMenu); + } + + } else { + contextMenu.clear(); + contextMenu.setVisible(false); + tree.setContextMenu(contextMenu); + + } + + } + }); + } protected void retrieveValidations() { @@ -476,4 +622,59 @@ public class ValidationsTasksPanel extends FramedPanel { } } + protected void startTaskResume(TaskResumeSession taskResumeSession){ + Log.debug(taskResumeSession.toString()); + TDGWTServiceAsync.INSTANCE.startTaskResume(taskResumeSession, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.debug(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error in Resume", + caught.getLocalizedMessage()); + } + + } + + @Override + public void onSuccess(Void result) { + TaskResumeProgressDialog taskResumeProgressDialog=new TaskResumeProgressDialog(eventBus); + taskResumeProgressDialog.addResumeDialogListener(thisPanel); + taskResumeProgressDialog.show(); + + } + + }); + } + + @Override + public void resumeComplete(TRId trId) { + ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED; + ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( + ChangeTableRequestType.TASKRESUME, trId, why); + eventBus.fireEvent(changeTableRequestEvent); + + } + + @Override + public void resumeFailed(Throwable caught, String reason) { + UtilsGXT3.alert("Error in Resume", reason); + + } + + @Override + public void resumeStopped(TRId trId, String reason, String details) { + ChangeTableWhy why = ChangeTableWhy.TABLECURATION; + ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( + ChangeTableRequestType.TASKRESUME, trId, why); + eventBus.fireEvent(changeTableRequestEvent); + + } + + + + } diff --git a/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png b/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png new file mode 100644 index 0000000..5e16f17 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png b/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png new file mode 100644 index 0000000..eff1676 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/tablewidget/client/resources/plaster_32.png differ