From 1b763d097861f2ef826b32ce7fb5d559aa1c8463 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Wed, 14 Oct 2015 15:15:13 +0000 Subject: [PATCH] Added dialog confirm git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@119761 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/AppControllerExplorer.java | 46 ------ .../client/view/windows/DialogConfirm.java | 147 ++++++++++++++++++ 2 files changed, 147 insertions(+), 46 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogConfirm.java diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index ea216ef..51ef257 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -592,32 +592,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt }); - eventBus.addHandler(DeleteBulkEvent.TYPE, new DeleteBulkEventHandler() { - - @Override - public void onDeleteBulk(final DeleteBulkEvent deleteBulkEvent) { - - /*NEVER USED - rpcWorkspaceService.deleteBulk(deleteBulkEvent.getBulkId(), new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR+ "deleting bulk "+ ConstantsExplorer.TRY_AGAIN, null); - - } - - @Override - public void onSuccess(Boolean result) { - if(result) - BulkCreatorWindow.getInstance().removeProgress(deleteBulkEvent.getBulkId()); - } - - });*/ - - } - }); - - eventBus.addHandler(GetShareLinkEvent.TYPE, new GetSharedLinkEventHandler() { @Override @@ -811,9 +785,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt default: } - - - } }); @@ -842,8 +813,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt } }); - - } }); @@ -879,7 +848,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt }); - eventBus.addHandler(PreviewMessageEvent.TYPE, new PreviewMessageEventHandler() { @Override @@ -936,23 +904,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onSuccess(MessageModel result) { - //Commented for Massi - // if(openMessageEvent.getOpenType().equals(OpenType.REPLY)) - //// new SendMessage(result, MessageOperationType.OPEN); //OPEN MESSAGE - //// notifySubscriber(openMessageEvent); - // else{ - // openMessageEvent.setMessage(result); - //// notifySubscriber(openMessageEvent); - //// new SendMessage(result, MessageOperationType.FORWARD); - // } - openMessageEvent.setMessage(result); //This fill item text and list contact notifySubscriber(openMessageEvent); } }); - - - } }); @@ -965,7 +920,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt }); - eventBus.addHandler(SendMessageEvent.TYPE, new SendMessageEventHandler() { @Override diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogConfirm.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogConfirm.java new file mode 100644 index 0000000..539b324 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogConfirm.java @@ -0,0 +1,147 @@ +/** + * + */ +package org.gcube.portlets.user.workspace.client.view.windows; + +import org.gcube.portlets.user.workspace.client.resources.Resources; + +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 = Resources.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) { + + dock.setSpacing(4); + dock.setWidth("100%"); + setText(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); + } + + /* + * (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