diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingService.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingService.java index b1e07be..adff839 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingService.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingService.java @@ -1,12 +1,27 @@ package org.gcube.portlets.widgets.wstaskexecutor.client; +import java.util.List; + +import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope; + import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + /** - * The client side stub for the RPC service. + * The Interface GreetingService. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * May 4, 2018 */ @RemoteServiceRelativePath("greet") public interface GreetingService extends RemoteService { - String greetServer(String name) throws IllegalArgumentException; + + /** + * Gets the list of scopes for logged user. + * + * @return the list of scopes for logged user + * @throws Exception the exception + */ + List getListOfScopesForLoggedUser() throws Exception; } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingServiceAsync.java index 6c77709..58766f7 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingServiceAsync.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/GreetingServiceAsync.java @@ -3,7 +3,12 @@ */ package org.gcube.portlets.widgets.wstaskexecutor.client; +import java.util.List; + +import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope; + import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; /** @@ -47,4 +52,10 @@ public interface GreetingServiceAsync { // Utility class should not be instantiated } } + + /** + * @param asyncCallback + */ + void getListOfScopesForLoggedUser( + AsyncCallback> asyncCallback); } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java index 59df987..07985a4 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/WsTaskExecutorWidget.java @@ -1,7 +1,6 @@ package org.gcube.portlets.widgets.wstaskexecutor.client; -import com.google.gwt.core.client.GWT; /** * Entry point classes define onModuleLoad(). @@ -19,8 +18,7 @@ public class WsTaskExecutorWidget { * Create a remote service proxy to talk to the server-side Greeting * service. */ - private final GreetingServiceAsync greetingService = - GWT.create(GreetingService.class); + public static final GreetingServiceAsync greetingService = GreetingServiceAsync.Util.getInstance(); /** * diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogConfirm.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogConfirm.java new file mode 100644 index 0000000..79b5d4d --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogConfirm.java @@ -0,0 +1,150 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.dialog; + + +import org.gcube.portlets.widgets.wstaskexecutor.client.resource.Icons; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + + +/** + * The Class DialogConfirm. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 19, 2015 + */ +public class DialogConfirm extends DialogBox implements ClickHandler { + + private DockPanel dock = new DockPanel(); + private Button yesButton; + private VerticalPanel vpContainer; + private ImageResource loading = Icons.ICONS.loading(); + private HorizontalPanel hpButtons = new HorizontalPanel(); + private Button noButton; + /** + * Instantiates a new dialog confirm. + * + * @param img the img + * @param caption the caption + * @param text the text + */ + public DialogConfirm(Image img, String caption, String text) { + getElement().setClassName("gwt-DialogBoxNew"); + dock.setSpacing(4); + dock.setWidth("100%"); + setText(caption); +// setHeading(caption); + + yesButton = new Button("Yes"); + noButton = new Button("No", this); + + noButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + hide(); + } + }); + + vpContainer = new VerticalPanel(); + vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX); + vpContainer.add(new HTML(text)); + hpButtons = new HorizontalPanel(); + hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); +// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX); + hpButtons.setSpacing(3); + yesButton.getElement().getStyle().setMarginRight(20.0, Unit.PX); + hpButtons.add(yesButton); + hpButtons.add(noButton); + + dock.add(hpButtons, DockPanel.SOUTH); + dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER); + + if (img != null) + dock.add(img, DockPanel.WEST); + + dock.add(vpContainer, DockPanel.CENTER); + setWidget(dock); +// add(dock); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event + * .dom.client.ClickEvent) + */ + @Override + public void onClick(ClickEvent event) { +// hide(); + } + + /** + * Loader. + * + * @param message the message + */ + public void loader(String message){ + try{ + dock.remove(hpButtons); + }catch(Exception e){} + vpContainer.clear(); + HorizontalPanel hpMask = new HorizontalPanel(); + hpMask.add(new Image(loading)); + HTML html = new HTML(message); + html.getElement().getStyle().setMarginLeft(5, Unit.PX); + hpMask.add(html); + vpContainer.add(hpMask); + } + + /** + * Adds the to center panel. + * + * @param w the w + */ + public void addToCenterPanel(Widget w) { + vpContainer.add(w); + } + + /** + * Gets the dock. + * + * @return the dock + */ + public DockPanel getDock() { + return dock; + } + + /** + * Gets the yes button. + * + * @return the yes button + */ + public Button getYesButton() { + return yesButton; + } + + /** + * Gets the no button. + * + * @return the no button + */ + public Button getNoButton() { + return noButton; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java new file mode 100644 index 0000000..2e8aadb --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/DialogResult.java @@ -0,0 +1,81 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.dialog; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Widget; + +// TODO: Auto-generated Javadoc +/** + * The Class DialogResult. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jan 19, 2018 + */ +public class DialogResult extends DialogBox implements ClickHandler { + + /** The dock. */ + private DockPanel dock = new DockPanel(); + + /** The close button. */ + private Button closeButton; + + /** + * Instantiates a new dialog result. + * + * @param img the img + * @param title the title + * @param msg the msg + */ + public DialogResult(Image img, String title, String msg) { + getElement().setClassName("gwt-DialogBoxNew"); + setText(title); + closeButton = new Button("Close", this); + dock.setSpacing(4); + dock.setWidth("100%"); + dock.add(new HTML(msg), DockPanel.CENTER); + + dock.add(closeButton, DockPanel.SOUTH); + if(img!=null) + dock.add(img, DockPanel.WEST); + + dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_RIGHT); + setWidget(dock); + } + + + /** + * Gets the close button. + * + * @return the closeButton + */ + public Button getCloseButton() { + return closeButton; + } + + + /* (non-Javadoc) + * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent) + */ + @Override + public void onClick(ClickEvent event) { + hide(); + + } + + /** + * Adds the to center panel. + * + * @param w the w + */ + public void addToCenterPanel(Widget w){ + dock.add(w, DockPanel.CENTER); + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/PanelConfirmBuilder.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/PanelConfirmBuilder.java new file mode 100644 index 0000000..1f076b9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/dialog/PanelConfirmBuilder.java @@ -0,0 +1,163 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.dialog; + + +import org.gcube.portlets.widgets.wstaskexecutor.client.resource.Icons; + +import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + + + +/** + * The Class PanelConfirmBuilder. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Mar 13, 2018 + */ +public abstract class PanelConfirmBuilder { + + private DockPanel dock = new DockPanel(); + private Button yesButton; + private VerticalPanel vpContainer; + private ImageResource loading = Icons.ICONS.loading(); + private HorizontalPanel hpButtons = new HorizontalPanel(); + private Button noButton; + + /** + * On click no button. + */ + public abstract void onClickNoButton(); + + /** + * On click yes button. + */ + public abstract void onClickYesButton(); + + + /** + * Instantiates a new panel confirm builder. + * + * @param img the img + * @param caption the caption + * @param text the text + */ + public PanelConfirmBuilder(Image img, String caption, String text, AlertType type) { + dock.setSpacing(4); + dock.setWidth("100%"); +// setHeading(caption); + + yesButton = new Button("Yes"); + + yesButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + onClickYesButton(); + } + }); + + noButton = new Button("No"); + + noButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + onClickNoButton(); + } + }); + + vpContainer = new VerticalPanel(); + vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX); + Alert txt = new Alert(text); + txt.setType(type); + txt.setClose(false); + vpContainer.add(txt); + hpButtons = new HorizontalPanel(); + hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); +// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX); + hpButtons.setSpacing(3); + yesButton.getElement().getStyle().setMarginRight(20.0, Unit.PX); + hpButtons.add(yesButton); + hpButtons.add(noButton); + + dock.add(hpButtons, DockPanel.SOUTH); + dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER); + + if (img != null) + dock.add(img, DockPanel.WEST); + + dock.add(vpContainer, DockPanel.CENTER); +// add(dock); + } + + + /** + * Loader. + * + * @param message the message + */ + public void loader(String message){ + try{ + dock.remove(hpButtons); + }catch(Exception e){} + vpContainer.clear(); + HorizontalPanel hpMask = new HorizontalPanel(); + hpMask.add(new Image(loading)); + HTML html = new HTML(message); + html.getElement().getStyle().setMarginLeft(5, Unit.PX); + hpMask.add(html); + vpContainer.add(hpMask); + } + + /** + * Adds the to center panel. + * + * @param w the w + */ + public void addToCenterPanel(Widget w) { + vpContainer.add(w); + } + + /** + * Gets the dock. + * + * @return the dock + */ + public DockPanel getPanel() { + return dock; + } + + /** + * Gets the yes button. + * + * @return the yes button + */ + public Button getYesButton() { + return yesButton; + } + + /** + * Gets the no button. + * + * @return the no button + */ + public Button getNoButton() { + return noButton; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/Icons.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/Icons.java new file mode 100644 index 0000000..bb2c180 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/Icons.java @@ -0,0 +1,31 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.resource; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; + + +// TODO: Auto-generated Javadoc +/** + * The Interface Icons. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 7, 2018 + */ +public interface Icons extends ClientBundle { + + /** The Constant ICONS. */ + public static final Icons ICONS = GWT.create(Icons.class); + + /** + * Loading. + * + * @return the image resource + */ + @Source("loading.gif") + ImageResource loading(); + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/loading.gif b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/loading.gif new file mode 100644 index 0000000..27f0eee Binary files /dev/null and b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/resource/loading.gif differ diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/FormatUtil.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/FormatUtil.java new file mode 100644 index 0000000..b487898 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/FormatUtil.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.widgets.wstaskexecutor.client.view; + +import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope; + + +// TODO: Auto-generated Javadoc +/** + * The Class FormatUtil. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 16, 2018 + */ +public class FormatUtil { + + + /** + * Truncate a string and add an ellipsis ('...') to the end if it exceeds the + * specified length. + * + * @param value the string to truncate + * @param len the maximum length to allow before truncating + * @return the converted text + */ + public static String ellipse(String value, int len) { + if (value != null && value.length() > len) { + return value.substring(0, len - 3) + "..."; + } + return value; + } + + + /** + * Gets the folder title. + * + * @param folderName the folder name + * @param maxSize the max size + * @return the folder title + */ + public static String getFolderTitle(String folderName, int maxSize){ + String title = folderName!=null&&folderName.length()>0?folderName:""; + return FormatUtil.ellipse(title, maxSize); + } + + + /** + * To scope value. + * + * @param gcubeScope the gcube scope + * @return the string + */ + public static String toScopeValue(GcubeScope gcubeScope){ + + if(gcubeScope==null) + return null; + + return "("+gcubeScope.getScopeType()+") "+gcubeScope.getScopeTitle(); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/LoaderIcon.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/LoaderIcon.java new file mode 100644 index 0000000..c696efd --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/LoaderIcon.java @@ -0,0 +1,61 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.client.view; + +import org.gcube.portlets.widgets.wstaskexecutor.client.resource.Icons; + +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; + +/** + * The Class LoaderIcon. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 19, 2015 + */ +public class LoaderIcon extends HorizontalPanel{ + + + private Image imgLoading = new Image(Icons.ICONS.loading()); + private HTML txtLoading = new HTML(""); + + /** + * Instantiates a new loader icon. + * + * @param txtHTML the txt html + */ + public LoaderIcon(String txtHTML) { + this(); + setText(txtHTML); + } + + /** + * Instantiates a new loader icon. + */ + public LoaderIcon() { + setStyleName("marginTop20"); + add(imgLoading); + add(txtLoading); + } + + /** + * Sets the text. + * + * @param txtHTML the new text + */ + public void setText(String txtHTML){ + txtLoading.setHTML(""+txtHTML+""); + } + + /** + * Show. + * + * @param bool the bool + */ + public void show(boolean bool){ + this.setVisible(bool); + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.java new file mode 100644 index 0000000..8dca69b --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.java @@ -0,0 +1,258 @@ +package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder; + + +import org.gcube.portlets.widgets.wstaskexecutor.client.dialog.PanelConfirmBuilder; +import org.gcube.portlets.widgets.wstaskexecutor.client.view.LoaderIcon; + +import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.FluidRow; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.Widget; + + +// TODO: Auto-generated Javadoc +/** + * The Class AbstractViewDialogBox. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jan 8, 2018 + */ +public abstract class AbstractViewDialogBox extends Composite { + + /** The ui binder. */ + private static AbstractViewDialogBoxUiBinder uiBinder = + GWT.create(AbstractViewDialogBoxUiBinder.class); + + /** The default width. */ + public static int DEFAULT_WIDTH = 500; + + + /** + * The Enum CONFIRM_VALUE. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Mar 13, 2018 + */ + public static enum CONFIRM_VALUE {YES, NO} + /** + * The Interface AbstractViewDialogBoxUiBinder. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jan 9, 2018 + */ + interface AbstractViewDialogBoxUiBinder + extends UiBinder { + } + + + /** The button close dialog. */ + @UiField + Button button_close_dialog; + + /** The field root panel. */ + @UiField + HTMLPanel field_root_panel; + + /** The scroll panel. */ + @UiField + ScrollPanel scroll_panel; + + /** The validator field. */ + @UiField + FluidRow validator_field; + + /** The loader icon. */ + private LoaderIcon loaderIcon = new LoaderIcon(); + + /** The alert error. */ + protected Alert alertError = new Alert(); + + + /** The alert info. */ + protected Alert alertInfo = new Alert(); + + + protected PanelConfirmBuilder confirmBuilder; + + /** + * Close handler. + */ + public abstract void closeHandler(); + + + /** + * Confirm hanlder. + * + * @param confirm the confirm + */ + public abstract void confirmHanlder(CONFIRM_VALUE confirm, Command command); + + /** + * Because this class has a default constructor, it can + * be used as a binder template. In other words, it can be used in other + * *.ui.xml files as follows: + * + * Hello! + * + * Note that depending on the widget that is used, it may be necessary to + * implement HasHTML instead of HasText. + */ + public AbstractViewDialogBox() { + + initWidget(uiBinder.createAndBindUi(this)); + //setWidth(DEFAULT_WIDTH+"px"); + + alertError.setType(AlertType.ERROR); + alertError.setVisible(false); + alertError.setClose(false); + validator_field.add(alertError); + + alertInfo.setType(AlertType.INFO); + alertInfo.setVisible(false); + alertInfo.setClose(false); + validator_field.add(alertInfo); + + showLoading(false, ""); + field_root_panel.add(loaderIcon); + + bindEvents(); + } + + /** + * Bind events. + */ + private void bindEvents() { + + button_close_dialog.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + closeHandler(); + + } + }); + } + + + /** + * Adds the view as widget. + * + * @param child the child + */ + public void addViewAsWidget(Widget child) { + + scroll_panel.add(child); + } + + /** + * Show loading. + * + * @param visible the visible + * @param text the text + */ + public void showLoading(boolean visible, String text){ + + try{ + validator_field.remove(loaderIcon); + }catch(Exception e){ + + } + + loaderIcon.setVisible(visible); + loaderIcon.setText(text); + + validator_field.add(loaderIcon); + } + + + /** + * Sets the error. + * + * @param visible the visible + * @param error the error + */ + public void setError(boolean visible, String error) { + + try{ + validator_field.remove(alertError); + }catch(Exception e){ + + } + + alertError.setVisible(visible); + alertError.setText(error==null?"":error); + + validator_field.add(alertError); + } + + + /** + * Sets the error. + * + * @param visible the visible + * @param msg the msg + */ + public void setInfo(boolean visible, String msg) { + + + try{ + validator_field.remove(alertInfo); + }catch(Exception e){ + + } + + alertInfo.setVisible(visible); + alertInfo.setText(msg==null?"":msg); + + validator_field.add(alertInfo); + } + + + /** + * Sets the confirm. + * + * @param visible the visible + * @param msg the msg + */ + public void setConfirm(boolean visible, String msg, final Command yes, final Command no){ + + try{ + validator_field.remove(confirmBuilder.getPanel()); + }catch(Exception e){ + + } + + if(visible){ + + confirmBuilder = new PanelConfirmBuilder(null, null, msg, AlertType.WARNING) { + + @Override + public void onClickYesButton() { + + confirmHanlder(CONFIRM_VALUE.YES, yes); + } + + @Override + public void onClickNoButton() { + + confirmHanlder(CONFIRM_VALUE.NO, no); + } + }; + + validator_field.add(confirmBuilder.getPanel()); + } + + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.ui.xml b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.ui.xml new file mode 100644 index 0000000..cc6a5e6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/AbstractViewDialogBox.ui.xml @@ -0,0 +1,14 @@ + + + + + + + + + + Close + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.java new file mode 100644 index 0000000..3671c1e --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.java @@ -0,0 +1,246 @@ +package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget; +import org.gcube.portlets.widgets.wstaskexecutor.client.view.FormatUtil; +import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope; + +import com.github.gwtbootstrap.client.ui.ControlGroup; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.Pager; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + + +/** + * The Class CreateTaskConfigurationView. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * May 4, 2018 + */ +public abstract class CreateTaskConfigurationView extends Composite { + + /** The ui binder. */ + private static CreateTaskConfigurationViewUiBinder uiBinder = + GWT.create(CreateTaskConfigurationViewUiBinder.class); + + /** + * The Interface CreateTaskConfigurationViewUiBinder. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * May 4, 2018 + */ + interface CreateTaskConfigurationViewUiBinder + extends UiBinder { + } + + /** The pager. */ + @UiField + Pager pager; + + + @UiField + ListBox field_select_scope; + + @UiField + TextBox field_key_param; + + @UiField + TextBox field_value_param; + + @UiField + ControlGroup cg_input_task_id; + + @UiField + ControlGroup cg_select_vre; + + @UiField + ControlGroup cg_input_key_param; + + @UiField + ControlGroup cg_input_value_param; + + + + @UiField + TextBox field_task_id; + + + /** The folder id. */ + private String folderId; + + /** The map VR es. */ + private Map mapScopes = new HashMap(); + + + + private String currentScope; + + + /** + * Submit handler. + */ + public abstract void submitHandler(); + + /** + * Sets the error. + * + * @param visible the visible + * @param error the error + */ + public abstract void setError(boolean visible, String error); + + + + /** + * Sets the confirm. + * + * @param visible the visible + * @param msg the msg + */ + public abstract void setConfirm(boolean visible, String msg); + + + /** + * Because this class has a default constructor, it can + * be used as a binder template. In other words, it can be used in other + * *.ui.xml files as follows: + * + * Hello! + * + * Note that depending on the widget that is used, it may be necessary to + * implement HasHTML instead of HasText. + * + * @param folderId the folder id + */ + public CreateTaskConfigurationView(String folderId) { + this.folderId = folderId; + + initWidget(uiBinder.createAndBindUi(this)); + + pager.getLeft().setVisible(false); + + pager.getRight().addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + setError(false, ""); + boolean isValid = validateSubmit(); + if(isValid) + submitHandler(); + + } + }); + + + WsTaskExecutorWidget.greetingService.getListOfScopesForLoggedUser(new AsyncCallback>() { + + @Override + public void onSuccess(List result) { + + + for (GcubeScope gcubeScope : result) { + String toValue = FormatUtil.toScopeValue(gcubeScope); + mapScopes.put(gcubeScope.getScopeName(), gcubeScope); + field_select_scope.addItem(toValue, gcubeScope.getScopeName()); + + } + + if(result.size()>0){ + field_select_scope.setSelectedValue(result.get(0).getScopeName()); + //field_select_vre.setSelectedIndex(0); + //field_select_vre.fireEvent(DomEvent.fireNativeEvent(nativeEvent, handlerSource);); + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), field_select_scope); + } + } + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub + + } + }); + + + } + + + /** + * Inits the field catalogue name. + */ + private void initFields() { + + field_task_id.setText(""); + field_key_param.setText(""); + field_value_param.setText(""); + } + + /** + * Validate submit. + * + * @return true, if successful + */ + protected boolean validateSubmit() { + cg_input_task_id.setType(ControlGroupType.NONE); + cg_input_key_param.setType(ControlGroupType.NONE); + cg_input_value_param.setType(ControlGroupType.NONE); + //cg_remote_path.setType(ControlGroupType.NONE); + + if(field_select_scope.getSelectedItemText()==null){ + cg_select_vre.setType(ControlGroupType.ERROR); + setError(true, "You must select a Scope!"); + return false; + } + + if(field_task_id.getValue() == null || field_task_id.getValue().isEmpty()){ + cg_input_task_id.setType(ControlGroupType.ERROR); + setError(true, "You must type an Algorithm Identifier!"); + return false; + } + + if(field_key_param.getValue() == null || field_key_param.getValue().isEmpty()){ + cg_input_key_param.setType(ControlGroupType.WARNING); + setConfirm(true, "The key of input parameter is empty. Do you want continue anyway?"); + return false; + } + + if(field_value_param.getValue() == null || field_value_param.getValue().isEmpty()){ + cg_input_key_param.setType(ControlGroupType.WARNING); + setConfirm(true, "The value of input parameter is empty. Do you want continue anyway?"); + return false; + } + + return true; + } + + + /** + * Gets the selected scope. + * + * @return the selected scope + */ + public GcubeScope getSelectedScope(){ + //String item = field_select_scope.getSelectedItemText(); + String text = field_select_scope.getSelectedValue(); + return mapScopes.get(text); + } + + + + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.ui.xml b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.ui.xml new file mode 100644 index 0000000..82316d4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/client/view/binder/CreateTaskConfigurationView.ui.xml @@ -0,0 +1,57 @@ + + + + .noBorder { + border: 0px; + } + + + + + + + + Execute in the Scope + + + + + + + + The Algorithm Id + + + + + + With Parameter + + + Parameter Key + + + + + + Parameter Value + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css new file mode 100644 index 0000000..bd03bab --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/public/WsTaskExecutorWidget.css @@ -0,0 +1,30 @@ +/** Add css rules here for your application. */ +.ws-thredds-modal-body div.modal-body { + position: relative; + max-height: 600px !important; + padding: 15px; + overflow-y: auto; +} + +.textAreaWidth { + width: 500px !important; +} + +.myMarginLeft { + margin-left: 180px !important; +} + +.myLittleWidth { + width: 40px !important; + padding-left: 20px !important; +} + +.myFormWidth { + width: 750px !important; +} + +.myLittleMarginLeft{ + + margin-left: 25px !important; + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/GreetingServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/GreetingServiceImpl.java index c973901..4c9eda6 100644 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/GreetingServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/server/GreetingServiceImpl.java @@ -1,7 +1,10 @@ package org.gcube.portlets.widgets.wstaskexecutor.server; +import java.util.List; + import org.gcube.portlets.widgets.wstaskexecutor.client.GreetingService; -import org.gcube.portlets.widgets.wstaskexecutor.shared.FieldVerifier; +import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; /** @@ -11,38 +14,16 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService { - public String greetServer(String input) throws IllegalArgumentException { - // Verify that the input is valid. - if (!FieldVerifier.isValidName(input)) { - // If the input is not valid, throw an IllegalArgumentException back to - // the client. - throw new IllegalArgumentException( - "Name must be at least 4 characters long"); - } + /* (non-Javadoc) + * @see org.gcube.portlets.widgets.wstaskexecutor.client.GreetingService#getListOfScopesForLoggedUser() + */ + @Override + public List getListOfScopesForLoggedUser() + throws Exception { - String serverInfo = getServletContext().getServerInfo(); - String userAgent = getThreadLocalRequest().getHeader("User-Agent"); + // TODO Auto-generated method stub + return null; + } - // Escape data from the client to avoid cross-site script vulnerabilities. - input = escapeHtml(input); - userAgent = escapeHtml(userAgent); - return "Hello, " + input + "!

I am running " + serverInfo - + ".

It looks like you are using:
" + userAgent; - } - - /** - * Escape an html string. Escaping data received from the client helps to - * prevent cross-site script vulnerabilities. - * - * @param html the html string to escape - * @return the escaped string - */ - private String escapeHtml(String html) { - if (html == null) { - return null; - } - return html.replaceAll("&", "&").replaceAll("<", "<").replaceAll( - ">", ">"); - } } diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/FieldVerifier.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/FieldVerifier.java deleted file mode 100644 index 3a27bbf..0000000 --- a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/FieldVerifier.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.gcube.portlets.widgets.wstaskexecutor.shared; - -/** - *

- * FieldVerifier validates that the name the user enters is valid. - *

- *

- * This class is in the shared packing because we use it in both - * the client code and on the server. On the client, we verify that the name is - * valid before sending an RPC request so the user doesn't have to wait for a - * network round trip to get feedback. On the server, we verify that the name is - * correct to ensure that the input is correct regardless of where the RPC - * originates. - *

- *

- * When creating a class that is used on both the client and the server, be sure - * that all code is translatable and does not use native JavaScript. Code that - * is note translatable (such as code that interacts with a database or the file - * system) cannot be compiled into client side JavaScript. Code that uses native - * JavaScript (such as Widgets) cannot be run on the server. - *

- */ -public class FieldVerifier { - - /** - * Verifies that the specified name is valid for our service. - * - * In this example, we only require that the name is at least four - * characters. In your application, you can use more complex checks to ensure - * that usernames, passwords, email addresses, URLs, and other fields have the - * proper syntax. - * - * @param name the name to validate - * @return true if valid, false if invalid - */ - public static boolean isValidName(String name) { - if (name == null) { - return false; - } - return name.length() > 3; - } -} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScope.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScope.java new file mode 100644 index 0000000..6750e7b --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScope.java @@ -0,0 +1,140 @@ +package org.gcube.portlets.widgets.wstaskexecutor.shared; + + +import java.io.Serializable; + +import com.google.gwt.user.client.rpc.IsSerializable; + + +// TODO: Auto-generated Javadoc +/** + * The Class GcubeVRE. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 14, 2018 + */ +public class GcubeScope implements Serializable, IsSerializable, Comparable{ + + + /** + * + */ + private static final long serialVersionUID = -6427520549519606384L; + + + private GcubeScopeType scopeType; + + + private String scopeTitle; + + + private String scopeName; + + /** + * Instantiates a new gcube VRE. + */ + public GcubeScope() { + + } + + /** + * Instantiates a new gcube scope. + * + * @param scopeTitle the scope title + * @param scopeName the scope name + * @param scopeType the scope type + */ + public GcubeScope(String scopeTitle, String scopeName, GcubeScopeType scopeType) { + + super(); + this.scopeTitle = scopeTitle; + this.scopeName = scopeName; + this.scopeType = scopeType; + } + + + /** + * @return the scopeType + */ + public GcubeScopeType getScopeType() { + + return scopeType; + } + + + /** + * @return the scopeTitle + */ + public String getScopeTitle() { + + return scopeTitle; + } + + + /** + * @return the scopeName + */ + public String getScopeName() { + + return scopeName; + } + + + /** + * @param scopeType the scopeType to set + */ + public void setScopeType(GcubeScopeType scopeType) { + + this.scopeType = scopeType; + } + + + /** + * @param scopeTitle the scopeTitle to set + */ + public void setScopeTitle(String scopeTitle) { + + this.scopeTitle = scopeTitle; + } + + + /** + * @param scopeName the scopeName to set + */ + public void setScopeName(String scopeName) { + + this.scopeName = scopeName; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(GcubeScope o) { + + if(o==null) + return -1; + + return this.getScopeName().compareTo(o.getScopeName()); + + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + StringBuilder builder = new StringBuilder(); + builder.append("GcubeScope [scopeType="); + builder.append(scopeType); + builder.append(", scopeTitle="); + builder.append(scopeTitle); + builder.append(", scopeName="); + builder.append(scopeName); + builder.append("]"); + return builder.toString(); + } + + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScopeType.java b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScopeType.java new file mode 100644 index 0000000..0c5a503 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wstaskexecutor/shared/GcubeScopeType.java @@ -0,0 +1,19 @@ +/** + * + */ +package org.gcube.portlets.widgets.wstaskexecutor.shared; + + + +/** + * The Enum GcubeScopeType. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Mar 12, 2018 + */ +public enum GcubeScopeType { + + ROOT, + VO, + VRE +}