2 * Copyright 2011-2012 GRNET S.A. All rights reserved.
\r
4 * Redistribution and use in source and binary forms, with or
\r
5 * without modification, are permitted provided that the following
\r
6 * conditions are met:
\r
8 * 1. Redistributions of source code must retain the above
\r
9 * copyright notice, this list of conditions and the following
\r
12 * 2. Redistributions in binary form must reproduce the above
\r
13 * copyright notice, this list of conditions and the following
\r
14 * disclaimer in the documentation and/or other materials
\r
15 * provided with the distribution.
\r
17 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
\r
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
\r
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
\r
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
27 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
28 * POSSIBILITY OF SUCH DAMAGE.
\r
30 * The views and conclusions contained in the software and
\r
31 * documentation are those of the authors and should not be
\r
32 * interpreted as representing official policies, either expressed
\r
33 * or implied, of GRNET S.A.
\r
35 package gr.grnet.pithos.web.client;
\r
37 import gr.grnet.pithos.web.client.MessagePanel.Images;
\r
38 import gr.grnet.pithos.web.client.foldertree.Folder;
\r
40 import com.google.gwt.dom.client.NativeEvent;
\r
41 import com.google.gwt.event.dom.client.ClickEvent;
\r
42 import com.google.gwt.event.dom.client.ClickHandler;
\r
43 import com.google.gwt.event.dom.client.KeyCodes;
\r
44 import com.google.gwt.event.dom.client.KeyDownEvent;
\r
45 import com.google.gwt.user.client.Event.NativePreviewEvent;
\r
46 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
47 import com.google.gwt.user.client.ui.Anchor;
\r
48 import com.google.gwt.user.client.ui.Button;
\r
49 import com.google.gwt.user.client.ui.DialogBox;
\r
50 import com.google.gwt.user.client.ui.HTML;
\r
51 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
52 import com.google.gwt.user.client.ui.VerticalPanel;
\r
55 * The 'delete folder' dialog box.
\r
57 public class DeleteFolderDialog extends DialogBox {
\r
59 protected Pithos app;
\r
60 protected Folder folder;
\r
63 * The widget's constructor.
\r
64 * @param images the supplied images
\r
66 public DeleteFolderDialog(Pithos _app, Images images, Folder _folder) {
\r
68 this.folder = _folder;
\r
70 Anchor close = new Anchor("close");
\r
71 close.addStyleName("close");
\r
72 close.addClickHandler(new ClickHandler() {
\r
75 public void onClick(ClickEvent event) {
\r
80 // Set the dialog's caption.
\r
81 setText("Confirmation");
\r
82 setAnimationEnabled(true);
\r
83 setGlassEnabled(true);
\r
84 setStyleName("pithos-DialogBox");
\r
85 // Create a VerticalPanel to contain the HTML label and the buttons.
\r
86 VerticalPanel outer = new VerticalPanel();
\r
89 VerticalPanel inner = new VerticalPanel();
\r
90 inner.addStyleName("inner");
\r
92 HTML text = new HTML("<table><tr><td rowspan='2'>" + AbstractImagePrototype.create(images.warn()).getHTML() +
\r
93 "</td><td>" + "Are you sure you want to <b>permanently</b> delete folder '" + folder.getName() +
\r
94 "'?</td></tr></table>");
\r
95 text.setStyleName("pithos-warnMessage");
\r
97 inner.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
\r
99 // Create the 'Delete' button, along with a listener that hides the dialog
\r
100 // when the button is clicked and deletes the folder.
\r
101 Button ok = new Button("Delete", new ClickHandler() {
\r
103 public void onClick(ClickEvent event) {
\r
104 app.deleteFolder(folder, null);
\r
108 ok.addStyleName("button");
\r
111 outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
\r
116 protected void onPreviewNativeEvent(NativePreviewEvent preview) {
\r
117 super.onPreviewNativeEvent(preview);
\r
119 NativeEvent evt = preview.getNativeEvent();
\r
120 if (evt.getType().equals(KeyDownEvent.getType().getName()))
\r
121 // Use the popup's key preview hooks to close the dialog when either
\r
122 // enter or escape is pressed.
\r
123 switch (evt.getKeyCode()) {
\r
124 case KeyCodes.KEY_ENTER:
\r
126 app.deleteFolder(folder, null);
\r
128 case KeyCodes.KEY_ESCAPE:
\r