/*\r
- * Copyright (c) 2011 Greek Research and Technology Network\r
+ * Copyright 2011 GRNET S.A. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer.\r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials\r
+ * provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * The views and conclusions contained in the software and\r
+ * documentation are those of the authors and should not be\r
+ * interpreted as representing official policies, either expressed\r
+ * or implied, of GRNET S.A.\r
*/\r
package gr.grnet.pithos.web.client;\r
\r
-import gr.grnet.pithos.web.client.rest.GetCommand;\r
-import gr.grnet.pithos.web.client.rest.resource.TagsResource;\r
-\r
-import java.util.List;\r
-\r
-import com.google.gwt.core.client.GWT;\r
import com.google.gwt.dom.client.NativeEvent;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.event.dom.client.KeyCodes;\r
-import com.google.gwt.user.client.DeferredCommand;\r
import com.google.gwt.user.client.Event.NativePreviewEvent;\r
-import com.google.gwt.user.client.ui.Anchor;\r
import com.google.gwt.user.client.ui.DialogBox;\r
import com.google.gwt.user.client.ui.FlowPanel;\r
-import com.google.gwt.user.client.ui.Label;\r
import com.google.gwt.user.client.ui.TabPanel;\r
import com.google.gwt.user.client.ui.TextBox;\r
\r
\r
protected TabPanel inner = null;\r
\r
+ protected Pithos app;\r
+\r
/**\r
* The widget's constructor.\r
*\r
*/\r
- public AbstractPropertiesDialog() {\r
-\r
+ public AbstractPropertiesDialog(Pithos _app) {\r
+ app = _app;\r
// Enable IE selection for the dialog (must disable it upon closing it)\r
- GSS.enableIESelection();\r
+ Pithos.enableIESelection();\r
\r
setAnimationEnabled(true);\r
\r
}\r
- /**\r
- * Retrieves all user tags from the server and updates the FlowPanel\r
- *\r
- * @param userId\r
- */\r
- protected void updateTags() {\r
- GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, GSS.get().getCurrentUserResource().getTagsPath(),null) {\r
-\r
- @Override\r
- public void onComplete() {\r
- allTagsContent.clear();\r
- TagsResource tagr = getResult();\r
- List<String> userTags = tagr.getTags();\r
- Anchor tag = null;\r
- for(String usrTag : userTags){\r
- tag = new Anchor(usrTag.toString(), false);\r
- tag.addStyleName("pithos-tag");\r
- allTagsContent.add(tag);\r
- Label separator = new Label(", ");\r
- separator.addStyleName("pithos-tag");\r
- allTagsContent.add(separator);\r
- tag.addClickHandler( new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- String existing = tags.getText();\r
- if (MULTIPLE_VALUES_TEXT.equals(existing)) existing = "";\r
- String newTag = ((Anchor) event.getSource()).getText().trim();\r
- // insert the new tag only if it is not in the list\r
- // already\r
- if (existing.indexOf(newTag) == -1 && !existing.trim().endsWith(newTag))\r
- tags.setText(existing.trim()\r
- + (existing.length() > 0 ? ", " : "")\r
- + newTag);\r
- }\r
- });\r
- }\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- GSS.get().displayError("Unable to fetch user tags");\r
- }\r
- };\r
- DeferredCommand.addCommand(tc);\r
-\r
- }\r
\r
/**\r
* Accepts any change and updates the file\r
protected abstract void accept();\r
\r
@Override\r
- @SuppressWarnings("fallthrough")\r
protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
super.onPreviewNativeEvent(preview);\r
\r
switch (evt.getKeyCode()) {\r
case KeyCodes.KEY_ENTER:\r
accept();\r
- case KeyCodes.KEY_ESCAPE:\r
- closeDialog();\r
- break;\r
+ //$FALL-THROUGH$\r
+ case KeyCodes.KEY_ESCAPE:\r
+ closeDialog();\r
+ break;\r
}\r
}\r
\r
* (we disable the prevention on creation of the dialog)\r
*/\r
public void closeDialog() {\r
- GSS.preventIESelection();\r
+ Pithos.preventIESelection();\r
hide();\r
}\r
-\r
}\r