+++ /dev/null
-build.properties
-.idea
-*.iml
-bin
-dependencies
-war
-.gwt
-.project
-.classpath
-.settings
-.gwt-tmp
+++ /dev/null
-<?xml version="1.0" encoding="utf-8" ?>
-<project name="pithos" default="gwt-compile" basedir=".">
- <description>The Pithos web client project build file</description>
-
- <property file="build.properties"/>
- <property name="deps.dir" value="dependencies"/>
-
- <property name="gwt.workers" value="1"/>
-
- <property name="gwt.version" value="2.1.1"/>
- <property name="gwt.home" value="${deps.dir}/gwt-${gwt.version}"/>
- <property name="gwt.filename" value="gwt-${gwt.version}.zip"/>
- <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/${gwt.filename}"/>
-
- <property name="gwt.module.class" value="Pithos" />
- <property name="gwt.root.package" value="gr.grnet.pithos.web" />
- <property name="gwt.root.path" value="gr/grnet/pithos/web" />
- <property name="gwt.module" value="${gwt.root.package}.${gwt.module.class}" />
-
- <property name="src.dir" value="${basedir}/src"/>
-
- <!-- Build dirs -->
- <property name="build.dir" value="${basedir}/bin" />
- <property name="build.classes.dir" value="${build.dir}/classes" />
- <property name="gwt.www.dir" value="${build.dir}/www" />
- <property name="gwt.www.admin.dir" value="${build.dir}/wwwadmin" />
- <property name="dist.war" value="${ant.project.name}.war"/>
- <property name="war.dir" value="${basedir}/war" />
- <property name="war.web-inf.dir" value="${war.dir}/WEB-INF"/>
- <property name="war.lib.dir" value="${war.web-inf.dir}/lib"/>
-
- <!-- set classpath -->
- <path id="project.class.path">
- <pathelement location="${gwt.home}/gwt-user.jar"/>
- </path>
-
- <target name="check-dependencies" description="Checks if all dependencies are present">
- <condition property="dependencies.present">
- <and>
- <available file="${gwt.home}" type="dir"/>
- </and>
- </condition>
- <echo message="dependencies.present=${dependencies.present}"/>
- </target>
-
- <target name="fetch-dependencies" unless="dependencies.present" description="Fetch the dpendencies if not present" depends="check-dependencies">
- <mkdir dir="${deps.dir}"/>
- <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
- <unzip src="${deps.dir}/${gwt.filename}" dest="${gwt.home}/.."/>
- </target>
-
- <target name="check-gwt-compile" description="Checks is the web gwt client sources are up-to-date with the compiled artifacts">
- <uptodate property="compilation-not-needed">
- <srcfiles dir="${src.dir}">
- <include name="${gwt.root.path}/**"/>
- </srcfiles>
- <mergemapper to="${gwt.www.dir}/${gwt.module}/${gwt.module}.nocache.js"/>
- </uptodate>
- </target>
-
- <target name="gwt-compile" depends="check-gwt-compile, fetch-dependencies" unless="compilation-not-needed" description="Compile the gwt web client code to JavaScript">
- <java classname="com.google.gwt.dev.Compiler" failonerror="true" fork="true">
- <arg value="-localWorkers" />
- <arg value="${gwt.workers}" />
- <arg value="-war"/>
- <arg value="${gwt.www.dir}"/>
- <arg value="${gwt.module}"/>
-
- <classpath>
- <pathelement path="${gwt.home}/gwt-dev.jar"/>
- <pathelement path="${gwt.home}/gwt-user.jar" />
- <path refid="project.class.path"/>
- <pathelement path="${src.dir}" />
- </classpath>
- </java>
- <!--move file="${gwt.www.dir}/${gwt.module}/${gwt.module.class}.html" tofile="${gwt.www.dir}/${gwt.module}/index.html"/-->
- </target>
-
- <target name="uploadToVM" depends="gwt-compile">
- <scp todir="chstath@pithos.dev.grnet.gr:/var/www/pithos_web_client" keyfile="${ssh.key}" passphrase="${passphrase}">
- <fileset dir="${gwt.www.dir}/${gwt.module}"/>
- </scp>
- </target>
-
- <target name="clean" description="Delete all build artifacts">
- <delete dir="${build.dir}"/>
- </target>
-
- <target name="distclean" depends="clean" description="Delete all downloaded dependencies">
- <delete dir="${deps.dir}"/>
- </target>
-
- <target name="run-web-dev-mode" description="Run web client in development mode">
- <java fork="true" classname="com.google.gwt.dev.DevMode" spawn="true">
- <classpath>
- <pathelement location="${src.dir}"/>
- <pathelement location="${build.classes.dir}"/>
- <pathelement path="${gwt.home}/gwt-dev.jar"/>
- <pathelement path="${gwt.home}/gwt-user.jar" />
- <path refid="project.class.path"/>
- </classpath>
- <jvmarg value="-Xmx256M"/>
- <jvmarg value="-Xdebug"/>
- <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=55555"/>
- <arg value="-war"/>
- <arg value="${gwt.www.dir}"/>
- <arg value="-noserver"/>
- <arg value="-startupUrl"/>
- <arg value="http://127.0.0.1:8080/client"/>
- <arg value="${gwt.module}"/>
- </java>
- </target>
-</project>
+++ /dev/null
-<!--
- ~ Copyright 2011 GRNET S.A. All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or
- ~ without modification, are permitted provided that the following
- ~ conditions are met:
- ~
- ~ 1. Redistributions of source code must retain the above
- ~ copyright notice, this list of conditions and the following
- ~ disclaimer.
- ~
- ~ 2. Redistributions in binary form must reproduce the above
- ~ copyright notice, this list of conditions and the following
- ~ disclaimer in the documentation and/or other materials
- ~ provided with the distribution.
- ~
- ~ THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- ~ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- ~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- ~ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- ~ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- ~ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ~ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- ~ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ~ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- ~ POSSIBILITY OF SUCH DAMAGE.
- ~
- ~ The views and conclusions contained in the software and
- ~ documentation are those of the authors and should not be
- ~ interpreted as representing official policies, either expressed
- ~ or implied, of GRNET S.A.
- -->
-
-<module>
- <inherits name="com.google.gwt.user.User"/>
- <inherits name="com.google.gwt.user.theme.standard.Standard"/>
- <inherits name="com.google.gwt.http.HTTP"/>
- <inherits name="com.google.gwt.json.JSON"/>
-
- <entry-point class='gr.grnet.pithos.web.client.Pithos' />
- <stylesheet src='pithos.css' />
-
- <source path="client"/>
-</module>
+++ /dev/null
-/*\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 com.google.gwt.dom.client.NativeEvent;\r
-import com.google.gwt.event.dom.client.KeyCodes;\r
-import com.google.gwt.user.client.Event.NativePreviewEvent;\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.TabPanel;\r
-import com.google.gwt.user.client.ui.TextBox;\r
-\r
-/**\r
- * Abstract class, parent of all 'File properties' dialog boxes.\r
- *\r
- */\r
-public abstract class AbstractPropertiesDialog extends DialogBox {\r
-\r
- protected static final String MULTIPLE_VALUES_TEXT = "(Multiple values)";\r
-\r
- /**\r
- * Text box with the tags associated with the file\r
- */\r
- protected TextBox tags = new TextBox();\r
-\r
- protected String initialTagText;\r
-\r
- /**\r
- * A FlowPanel with all user tags\r
- */\r
- protected FlowPanel allTagsContent;\r
-\r
-\r
- protected TabPanel inner = null;\r
-\r
- protected Pithos app;\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- */\r
- public AbstractPropertiesDialog(Pithos _app) {\r
- app = _app;\r
- // Enable IE selection for the dialog (must disable it upon closing it)\r
- Pithos.enableIESelection();\r
-\r
- setAnimationEnabled(true);\r
-\r
- }\r
-\r
- /**\r
- * Accepts any change and updates the file\r
- *\r
- */\r
- protected abstract void accept();\r
-\r
- @Override\r
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
- super.onPreviewNativeEvent(preview);\r
-\r
- NativeEvent evt = preview.getNativeEvent();\r
- if (evt.getType().equals("keydown"))\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (evt.getKeyCode()) {\r
- case KeyCodes.KEY_ENTER:\r
- accept();\r
- //$FALL-THROUGH$\r
- case KeyCodes.KEY_ESCAPE:\r
- closeDialog();\r
- break;\r
- }\r
- }\r
-\r
-\r
-\r
- public void selectTab(int _tab) {\r
- inner.selectTab(_tab);\r
- }\r
-\r
-\r
- /**\r
- * Enables IE selection prevention and hides the dialog\r
- * (we disable the prevention on creation of the dialog)\r
- */\r
- public void closeDialog() {\r
- Pithos.preventIESelection();\r
- hide();\r
- }\r
-}\r
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import java.util.List;
-
-public class Clipboard {
- public final static int CUT=1;
- public final static int COPY=2;
-
- private int operation;
-
- private List<File> files;
-
- private Folder folder;
-
- /**
- * Retrieve the item.
- *
- * @return the item
- */
- public Object getItem() {
- if (folder != null)
- return folder;
- if (files != null)
- return files;
- return null;
- }
-
- public void setItem(int _operation, Folder _folder) {
- operation = _operation;
- folder = _folder;
- files = null;
- }
-
- public void setItem(int _operation, List<File> _files) {
- operation = _operation;
- files = _files;
- folder = null;
- }
-
- public int getOperation() {
- return operation;
- }
-
- public void clear() {
- folder = null;
- files = null;
- }
-
- public boolean isEmpty() {
- return (files == null || files.isEmpty()) && folder == null;
- }
-
- public boolean hasFiles() {
- return files != null && !files.isEmpty();
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.i18n.client.Constants;
-
-
-/**
- * This interface contains bindings for the compile-time configurable
- * entities of the application.
- *
- */
-public interface Configuration extends Constants {
- /**
- * @return the login URL
- */
- @DefaultStringValue("/.")
- String loginUrl();
-
- /**
- * @return the authentication cookie name
- */
- @DefaultStringValue("_pithos2_a")
- String authCookie();
-
- /**
- * @return the separator string between username and token in the
- * authentication cookie
- */
- @DefaultStringValue("|")
- String cookieSeparator();
-
- /**
- * @return the relative path of the API root URL
- */
- @DefaultStringValue("/v1/")
- String apiPath();
-
- /**
- * @return the version string
- */
- @DefaultStringValue("")
- String version();
-
- @DefaultStringValue("X-Auth-Token")
- String authTokenCookie();
-
- @DefaultStringValue("_shibsession_")
- String shibSessionCookiePrefix();
-}
+++ /dev/null
-#
-# Copyright 2011 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# 1. Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-#
-
-loginUrl=/.
-authCookie=_pithos2_a
-cookieSeparator=|
-apiPath=/v1/
-version=2.0
-authTokenCookie=X-Auth-Token
-shibSessionCookiePrefix=_shibsession_
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-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.VerticalPanel;
-
-
-/**
- * A dialog for requesting confirmation from the user.
- */
-public abstract class ConfirmationDialog extends DialogBox {
-
- /**
- * The widget's constructor.
- *
- * @param message the message to display
- * @param buttonLabel the label of the confirmation button
- */
- public ConfirmationDialog(String message, String buttonLabel) {
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- // Set the dialog's caption.
- setText("Confirmation");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
- // Create a VerticalPanel to contain the label and the buttons.
- VerticalPanel outer = new VerticalPanel();
- outer.add(close);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
-
- HTML text = new HTML("<table><tr><td rowspan='2'> " +
- AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() +
- "</td><td>" + message + "</td></tr></table>");
- text.setStyleName("pithos-warnMessage");
- inner.add(text);
- inner.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
-
- // Create the 'Update' button, along with a listener that hides the
- // dialog when the button is clicked and renames the file.
- Button ok = new Button(buttonLabel, new ClickHandler() {
-
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- confirm();
- hide();
- }
- });
- ok.addStyleName("button");
- inner.add(ok);
-
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- hide();
- confirm();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- cancel();
- break;
- }
- }
-
- public abstract void confirm();
-
- public abstract void cancel();
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-/**
- * A dialog box that displays the user credentials for use in other client
- * applications.
- */
-public class CredentialsDialog extends DialogBox {
-
- private final String WIDTH_FIELD = "35em";
- private final String WIDTH_TEXT = "42em";
-
- /**
- * The widget constructor.
- */
- public CredentialsDialog(final Pithos app, final MessagePanel.Images images) {
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- // Set the dialog's caption.
- setText("User Credentials");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
- // A VerticalPanel that contains the 'about' label and the 'OK' button.
- VerticalPanel outer = new VerticalPanel();
- outer.add(close);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
-
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("<p>These are the user credentials that are " +
- "required for interacting with Pithos");
- text.setStyleName("pithos-credentialsText");
- text.setWidth(WIDTH_TEXT);
- inner.add(text);
- FlexTable table = new FlexTable();
- table.setText(0, 0, "Username");
- table.setText(1, 0, "Token");
- TextBox username = new TextBox();
- username.setText(app.getUsername());
- username.setReadOnly(true);
- username.setWidth(WIDTH_FIELD);
- username.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- Pithos.enableIESelection();
- ((TextBox) event.getSource()).selectAll();
- Pithos.preventIESelection();
- }
-
- });
- table.setWidget(0, 1, username);
-
- TextBox tokenBox = new TextBox();
- tokenBox.setText(app.getToken());
- tokenBox.setReadOnly(true);
- tokenBox.setWidth(WIDTH_FIELD);
- tokenBox.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- Pithos.enableIESelection();
- ((TextBox) event.getSource()).selectAll();
- Pithos.preventIESelection();
- }
-
- });
- table.setWidget(1, 1, tokenBox);
-
- table.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(0, 1, "props-values");
- table.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(1, 1, "props-values");
- inner.add(table);
-
- // Create the 'OK' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button confirm = new Button("Close", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- confirm.addStyleName("button");
- inner.add(confirm);
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when
- // either enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-}
+++ /dev/null
-/*\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 com.google.gwt.core.client.Scheduler;\r
-import gr.grnet.pithos.web.client.MessagePanel.Images;\r
-import gr.grnet.pithos.web.client.foldertree.File;\r
-import gr.grnet.pithos.web.client.foldertree.Resource;\r
-import gr.grnet.pithos.web.client.rest.DeleteRequest;\r
-import gr.grnet.pithos.web.client.rest.RestException;\r
-\r
-import java.util.Iterator;\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.http.client.Response;\r
-import com.google.gwt.user.client.Command;\r
-import com.google.gwt.user.client.Event.NativePreviewEvent;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.Anchor;\r
-import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.DialogBox;\r
-import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-\r
-/**\r
- * The 'delete file' dialog box.\r
- */\r
-public class DeleteFileDialog extends DialogBox {\r
-\r
- private List<File> files;\r
-\r
- protected Pithos app;\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- * @param images the supplied images\r
- */\r
- public DeleteFileDialog(Pithos _app, Images images, List<File> _files) {\r
- app = _app;\r
- files = _files;\r
- Anchor close = new Anchor();\r
- close.addStyleName("close");\r
- close.addClickHandler(new ClickHandler() {\r
- \r
- @Override\r
- public void onClick(ClickEvent event) {\r
- hide();\r
- }\r
- });\r
- // Set the dialog's caption.\r
- setText("Confirmation");\r
- setAnimationEnabled(true);\r
- setGlassEnabled(true);\r
- setStyleName("pithos-DialogBox");\r
- // Create a VerticalPanel to contain the label and the buttons.\r
- VerticalPanel outer = new VerticalPanel();\r
- outer.add(close);\r
- \r
- VerticalPanel inner = new VerticalPanel();\r
- inner.addStyleName("inner");\r
-\r
- HTML text;\r
- if (files.size() == 1)\r
- text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete file '" + files.get(0).getName() + "'?</td></tr></table>");\r
- else\r
- text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete the selected files?</td></tr></table>");\r
- text.setStyleName("pithos-warnMessage");\r
- inner.add(text);\r
-\r
- // Create the 'Delete' button, along with a listener that hides the dialog\r
- // when the button is clicked and deletes the file.\r
- Button ok = new Button("Delete", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- deleteFiles();\r
- hide();\r
- }\r
- });\r
- ok.addStyleName("button");\r
- inner.add(ok);\r
- inner.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);\r
- outer.add(inner);\r
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
- setWidget(outer);\r
- }\r
-\r
- /**\r
- * Generate an RPC request to delete a file.\r
- */\r
- protected void deleteFiles() {\r
- Iterator<File> iter = files.iterator();\r
- deleteFile(iter);\r
- }\r
-\r
- protected void deleteFile(final Iterator<File> iter) {\r
- if (iter.hasNext()) {\r
- File f = iter.next();\r
- String path = f.getUri();\r
- DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwner(), path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- deleteFile(iter);\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if (t instanceof RestException) {\r
- app.displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
- }\r
- else\r
- app.displayError("System error unable to delete file: "+t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- deleteFile.setHeader("X-Auth-Token", app.getToken());\r
- Scheduler.get().scheduleDeferred(deleteFile);\r
- }\r
- else {\r
- app.updateFolder(files.get(0).getParent(), true, new Command() {\r
- \r
- @Override\r
- public void execute() {\r
- app.updateStatistics();\r
- }\r
- });\r
- }\r
- }\r
-\r
- @Override\r
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
- super.onPreviewNativeEvent(preview);\r
-\r
- NativeEvent evt = preview.getNativeEvent();\r
- if (evt.getType().equals("keydown"))\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (evt.getKeyCode()) {\r
- case KeyCodes.KEY_ENTER:\r
- hide();\r
- deleteFiles();\r
- break;\r
- case KeyCodes.KEY_ESCAPE:\r
- hide();\r
- break;\r
- }\r
- }\r
-\r
-\r
-\r
-}\r
+++ /dev/null
-/*\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 com.google.gwt.event.dom.client.KeyDownEvent;\r
-import gr.grnet.pithos.web.client.MessagePanel.Images;\r
-import gr.grnet.pithos.web.client.foldertree.Folder;\r
-\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.Event.NativePreviewEvent;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.Anchor;\r
-import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.DialogBox;\r
-import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-\r
-/**\r
- * The 'delete folder' dialog box.\r
- */\r
-public class DeleteFolderDialog extends DialogBox {\r
-\r
- protected Pithos app;\r
- protected Folder folder;\r
- \r
- /**\r
- * The widget's constructor.\r
- * @param images the supplied images\r
- */\r
- public DeleteFolderDialog(Pithos _app, Images images, Folder _folder) {\r
- this.app = _app;\r
- this.folder = _folder;\r
-\r
- Anchor close = new Anchor();\r
- close.addStyleName("close");\r
- close.addClickHandler(new ClickHandler() {\r
- \r
- @Override\r
- public void onClick(ClickEvent event) {\r
- hide();\r
- }\r
- });\r
-\r
- // Set the dialog's caption.\r
- setText("Confirmation");\r
- setAnimationEnabled(true);\r
- setGlassEnabled(true);\r
- setStyleName("pithos-DialogBox");\r
- // Create a VerticalPanel to contain the HTML label and the buttons.\r
- VerticalPanel outer = new VerticalPanel();\r
- outer.add(close);\r
- \r
- VerticalPanel inner = new VerticalPanel();\r
- inner.addStyleName("inner");\r
-\r
- HTML text = new HTML("<table><tr><td rowspan='2'>" + AbstractImagePrototype.create(images.warn()).getHTML() +\r
- "</td><td>" + "Are you sure you want to <b>permanently</b> delete folder '" + folder.getName() +\r
- "'?</td></tr></table>");\r
- text.setStyleName("pithos-warnMessage");\r
- inner.add(text);\r
- inner.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- // Create the 'Delete' button, along with a listener that hides the dialog\r
- // when the button is clicked and deletes the folder.\r
- Button ok = new Button("Delete", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- app.deleteFolder(folder);\r
- hide();\r
- }\r
- });\r
- ok.addStyleName("button");\r
- inner.add(ok);\r
- outer.add(inner);\r
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
- setWidget(outer);\r
- }\r
-\r
- @Override\r
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
- super.onPreviewNativeEvent(preview);\r
-\r
- NativeEvent evt = preview.getNativeEvent();\r
- if (evt.getType().equals(KeyDownEvent.getType().getName()))\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (evt.getKeyCode()) {\r
- case KeyCodes.KEY_ENTER:\r
- hide();\r
- app.deleteFolder(folder);\r
- break;\r
- case KeyCodes.KEY_ESCAPE:\r
- hide();\r
- break;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-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.TextArea;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-/**
- * A dialog box that displays info about invitations
- */
-public class FeedbackDialog extends DialogBox {
-
- private final String WIDTH_FIELD = "35em";
- private final String WIDTH_TEXT = "42em";
-
- /**
- * The widget constructor.
- */
- public FeedbackDialog(final Pithos app) {
- // Set the dialog's caption.
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- setText("Send feedback");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
- VerticalPanel outer = new VerticalPanel();
- outer.add(close);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("Pithos is currently in alpha test and we would appreciate any<br>" + "kind of feedback. We welcome any suggestions, questions and<br>" + " bug reports you may have.");
- text.setStyleName("pithos-credentialsText");
- inner.add(text);
- FlexTable table = new FlexTable();
- table.setText(0, 0, "Please describe your problem here, provide as many details as possible");
- final TextArea msg = new TextArea();
- msg.setWidth("100%");
- msg.setHeight("100px");
- table.setWidget(1, 0, msg);
-
- table.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(0, 1, "props-values");
- inner.add(table);
-
- // Create the 'OK' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button confirm = new Button("Submit feedback", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- PostRequest sendFeedback = new PostRequest("/tools/", "", "feedback", "feedback-msg=" + msg.getText()) {
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
-
- @Override
- public void onSuccess(Resource result) {
- app.displayInformation("Feedback sent");
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- }
- };
- sendFeedback.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(sendFeedback);
- hide();
- }
- });
- confirm.addStyleName("button");
- inner.add(confirm);
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when
- // either enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.commands.CopyCommand;
-import gr.grnet.pithos.web.client.commands.CutCommand;
-import gr.grnet.pithos.web.client.commands.DeleteCommand;
-import gr.grnet.pithos.web.client.commands.PasteCommand;
-import gr.grnet.pithos.web.client.commands.PropertiesCommand;
-import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
-import gr.grnet.pithos.web.client.commands.ToTrashCommand;
-import gr.grnet.pithos.web.client.commands.UploadFileCommand;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import java.util.List;
-
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'File Context' menu implementation.
- */
-public class FileContextMenu extends PopupPanel {
-
- /**
- * The widget's images.
- */
- private final Images images;
-
- private MenuItem cutItem;
-
- private MenuItem copyItem;
-
- private MenuItem pasteItem;
-
- private MenuItem updateItem;
-
- private MenuItem sharingItem;
-
- private MenuItem propItem;
-
- private MenuItem trashItem;
-
- private MenuItem deleteItem;
-
- private MenuItem downloadItem;
-
- private MenuItem saveAsItem;
-
- /**
- * The image bundle for this widget's images that reuses images defined in
- * other menus.
- */
- public interface Images extends ClientBundle {
-
- @Source("gr/grnet/pithos/resources/mimetypes/document.png")
- ImageResource fileContextMenu();
-
- @Source("gr/grnet/pithos/resources/doc_versions.png")
- ImageResource versions();
-
- @Source("gr/grnet/pithos/resources/groups22.png")
- ImageResource sharing();
-
- @Source("gr/grnet/pithos/resources/border_remove.png")
- ImageResource unselectAll();
-
- @Source("gr/grnet/pithos/resources/demo.png")
- ImageResource viewImage();
-
- @Source("gr/grnet/pithos/resources/folder_new.png")
- ImageResource folderNew();
-
- @Source("gr/grnet/pithos/resources/folder_outbox.png")
- ImageResource fileUpdate();
-
- @Source("gr/grnet/pithos/resources/view_text.png")
- ImageResource viewText();
-
- @Source("gr/grnet/pithos/resources/folder_inbox.png")
- ImageResource download();
-
- @Source("gr/grnet/pithos/resources/trash.png")
- ImageResource emptyTrash();
-
- @Source("gr/grnet/pithos/resources/refresh.png")
- ImageResource refresh();
-
- /**
- * Will bundle the file 'editcut.png' residing in the package
- * 'gr.grnet.pithos.web.resources'.
- *
- * @return the image prototype
- */
- @Source("gr/grnet/pithos/resources/editcut.png")
- ImageResource cut();
-
- /**
- * Will bundle the file 'editcopy.png' residing in the package
- * 'gr.grnet.pithos.web.resources'.
- *
- * @return the image prototype
- */
- @Source("gr/grnet/pithos/resources/editcopy.png")
- ImageResource copy();
-
- /**
- * Will bundle the file 'editpaste.png' residing in the package
- * 'gr.grnet.pithos.web.resources'.
- *
- * @return the image prototype
- */
- @Source("gr/grnet/pithos/resources/editpaste.png")
- ImageResource paste();
-
- /**
- * Will bundle the file 'editdelete.png' residing in the package
- * 'gr.grnet.pithos.web.resources'.
- *
- * @return the image prototype
- */
- @Source("gr/grnet/pithos/resources/editdelete.png")
- ImageResource delete();
-
- /**
- * Will bundle the file 'translate.png' residing in the package
- * 'gr.grnet.pithos.web.resources'.
- *
- * @return the image prototype
- */
- @Source("gr/grnet/pithos/resources/translate.png")
- ImageResource selectAll();
- }
-
- public static native String getDate()/*-{
- return (new Date()).toUTCString();
- }-*/;
-
- /**
- * The widget's constructor.
- *
- * @param newImages the image bundle passed on by the parent object
- */
- public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, final List<File> selectedFiles) {
- // The popup's constructor's argument is a boolean specifying that it
- // auto-close itself when the user clicks outside of it.
- super(true);
- setAnimationEnabled(true);
- images = newImages;
- MenuBar contextMenu = new MenuBar(true);
- Boolean[] permissions = null;
- boolean canWrite = true;
- if (selectedFolder != null) {
- permissions = selectedFolder.getPermissions().get(app.getUsername());
- canWrite = selectedFolder.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
- }
- else {
- for (File f : selectedFiles) {
- permissions = f.getPermissions().get(app.getUsername());
- canWrite &= (f.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]));
- }
- }
- boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView());
- if (selectedFolder != null) {
- if (!selectedFolder.isInTrash()) {
- if (canWrite && app.getClipboard().hasFiles()) {
- List<File> files = (List<File>) app.getClipboard().getItem();
- pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, selectedFolder));
- contextMenu.addItem(pasteItem);
- }
-
- if (canWrite) {
- MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(app, this, selectedFolder));
- contextMenu.addItem(upload);
- }
- if (isFolderTreeSelected) {
- cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(app, this, selectedFiles));
- contextMenu.addItem(cutItem);
- }
-
-
- if (isFolderTreeSelected) {
- trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(app, this, selectedFiles));
- contextMenu.addItem(trashItem);
- }
- }
- else {
- MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(app, this, selectedFiles));
- contextMenu.addItem(restore);
- }
- }
- copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(app, this, selectedFiles));
- contextMenu.addItem(copyItem);
-
- if (isFolderTreeSelected) {
- deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, selectedFiles, MessagePanel.images));
- contextMenu.addItem(deleteItem);
- }
-
- if (selectedFolder != null && !selectedFolder.isInTrash()) {
- if (isFolderTreeSelected && selectedFiles.size() == 1)
- contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
-
- }
- contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</span>", true, new Command() {
-
- @Override
- public void execute() {
- for (File f : selectedFiles)
- Window.open(app.getApiPath() + f.getOwner() + f.getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
- }
- }));
-
- add(contextMenu);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import com.google.gwt.cell.client.ImageResourceCell;
-import com.google.gwt.cell.client.SafeHtmlCell;
-import com.google.gwt.cell.client.TextCell;
-import com.google.gwt.cell.client.ValueUpdater;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.event.dom.client.ContextMenuHandler;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates.Template;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.user.cellview.client.CellTable;
-import com.google.gwt.user.cellview.client.Column;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.MultiSelectionModel;
-import com.google.gwt.view.client.ProvidesKey;
-
-/**
- * A composite that displays the list of files in a particular folder.
- */
-public class FileList extends Composite {
-
- ListDataProvider<File> provider = new ListDataProvider<File>();
-
- /**
- * The styles applied to the table.
- */
- interface TableStyle extends CellTable.Style {
- }
-
- interface TableResources extends CellTable.Resources {
- @Override
- @Source({CellTable.Style.DEFAULT_CSS, "PithosCellTable.css"})
- TableStyle cellTableStyle();
- }
-
- static interface Templates extends SafeHtmlTemplates {
- Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<div id='dragHelper' style='border:1px solid black; background-color:#ffffff; color:black; width:150px;z-index:100'></div>")
- SafeHtml outerHelper();
-
- @Template("<span id='{0}'>{0}</span>")
- public SafeHtml filenameSpan(String filename);
-
- @Template("<a href='{0}' title='{1}' rel='lytebox[mnf]' onclick='myLytebox.start(this, false, false); return false;'>(view)</a>")
- public SafeHtml viewLink(String link, String title);
-
- @Template("<table><tr><td rowspan='3'>{0}</td><td style='font-size:95%;' id='{1}'>{1}</td></tr><tr><td>{2}</td></tr></table>")
- public SafeHtml rendelContactCell(String imageHtml, String name, String fileSize);
-
- @Template("<span id='{0}' class='{1}'>{2}</span>")
- public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
- }
-
- protected final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
-
- /**
- * Specifies that the images available for this composite will be the ones
- * available in FileContextMenu.
- */
- public interface Images extends FolderTreeView.Images {
-
- @Source("gr/grnet/pithos/resources/blank.gif")
- ImageResource blank();
-
- @Source("gr/grnet/pithos/resources/asc.png")
- ImageResource asc();
-
- @Source("gr/grnet/pithos/resources/desc.png")
- ImageResource desc();
-
- @Source("gr/grnet/pithos/resources/mimetypes/document_shared.png")
- ImageResource documentShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst.png")
- ImageResource wordprocessor();
-
- @Source("gr/grnet/pithos/resources/mimetypes/log.png")
- ImageResource spreadsheet();
-
- @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr.png")
- ImageResource presentation();
-
- @Source("gr/grnet/pithos/resources/mimetypes/acroread.png")
- ImageResource pdf();
-
- @Source("gr/grnet/pithos/resources/mimetypes/image.png")
- ImageResource image();
-
- @Source("gr/grnet/pithos/resources/mimetypes/video2.png")
- ImageResource video();
-
- @Source("gr/grnet/pithos/resources/mimetypes/knotify.png")
- ImageResource audio();
-
- @Source("gr/grnet/pithos/resources/mimetypes/html.png")
- ImageResource html();
-
- @Source("gr/grnet/pithos/resources/mimetypes/txt.png")
- ImageResource txt();
-
- @Source("gr/grnet/pithos/resources/mimetypes/ark2.png")
- ImageResource zip();
-
- @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst_shared.png")
- ImageResource wordprocessorShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/log_shared.png")
- ImageResource spreadsheetShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr_shared.png")
- ImageResource presentationShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/acroread_shared.png")
- ImageResource pdfShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/image_shared.png")
- ImageResource imageShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/video2_shared.png")
- ImageResource videoShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/knotify_shared.png")
- ImageResource audioShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/html_shared.png")
- ImageResource htmlShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/txt_shared.png")
- ImageResource txtShared();
-
- @Source("gr/grnet/pithos/resources/mimetypes/ark2_shared.png")
- ImageResource zipShared();
-
- }
-
- /**
- * The number of files in this folder.
- */
- int folderFileCount;
-
- /**
- * Total folder size
- */
- long folderTotalSize;
-
- /**
- * A cache of the files in the list.
- */
- private List<File> files;
-
- /**
- * The widget's image bundle.
- */
- protected final Images images;
-
- protected CellTable<File> celltable;
-
- private final MultiSelectionModel<File> selectionModel;
-
- protected final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
-
- SortableHeader nameHeader;
-
- FolderTreeView treeView;
-
- protected Pithos app;
-
- /**
- * Construct the file list widget. This entails setting up the widget
- * layout, fetching the number of files in the current folder from the
- * server and filling the local file cache of displayed files with data from
- * the server, as well.
- *
- * @param _images
- */
- public FileList(final Pithos _app, Images _images, FolderTreeView _treeView) {
- app = _app;
- images = _images;
- this.treeView = _treeView;
-
- CellTable.Resources resources = GWT.create(TableResources.class);
-
- ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
-
- @Override
- public Object getKey(File item) {
- return item.getUri();
- }
- };
-
- celltable = new CellTable<File>(10, resources, keyProvider);
- celltable.setWidth("100%");
- celltable.setStyleName("pithos-List");
-
- Column<File, ImageResource> status = new Column<File, ImageResource>(new ImageResourceCell() {
- @Override
- public boolean handlesSelection() {
- return false;
- }
- })
- {
- @Override
- public ImageResource getValue(File entity) {
- return getFileIcon(entity);
- }
- };
- celltable.addColumn(status,"");
-
- final Column<File,SafeHtml> nameColumn = new Column<File,SafeHtml>(new SafeHtmlCell()) {
-
- @Override
- public SafeHtml getValue(File object) {
- SafeHtmlBuilder sb = new SafeHtmlBuilder();
- sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
- if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg")) {
- sb.appendHtmlConstant(" ")
- .append(Templates.INSTANCE.viewLink(app.getApiPath() + object.getOwner() + object.getUri() + "?X-Auth-Token=" + app.getToken(), object.getName()));
- }
-
- return sb.toSafeHtml();
- }
-
- };
- celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
- allHeaders.add(nameHeader);
- nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
-
- celltable.redrawHeaders();
-
- Column<File,String> aColumn = new Column<File,String>(new TextCell()) {
- @Override
- public String getValue(File object) {
- // TODO Auto-generated method stub
- return object.getSizeAsString();
- }
- };
- SortableHeader aheader = new SortableHeader("Size");
- celltable.addColumn(aColumn, aheader);
- allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "size"));
-
- aColumn = new Column<File,String>(new TextCell()) {
- @Override
- public String getValue(File object) {
- return object.getLastModified() != null ? formatter.format(object.getLastModified()) : "";
- }
- };
- aheader = new SortableHeader("Last Modified");
- celltable.addColumn(aColumn, aheader);
- allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "date"));
-
- provider.addDataDisplay(celltable);
-
- VerticalPanel vp = new VerticalPanel();
- vp.setWidth("100%");
- vp.addStyleName("pithos-FileListContainer");
-
- vp.add(celltable);
-
- vp.setCellWidth(celltable, "100%");
- vp.addHandler(new ContextMenuHandler() {
- @Override
- public void onContextMenu(ContextMenuEvent event) {
- TreeView tree = app.getSelectedTree();
- if (tree != null && (tree.equals(app.getFolderTreeView()) || tree.equals(app.getOtherSharedTreeView()))) {
- Folder selectedFolder = app.getSelection();
- FileContextMenu contextMenu = new FileContextMenu(app, images, tree, selectedFolder, getSelectedFiles());
- int x = event.getNativeEvent().getClientX();
- int y = event.getNativeEvent().getClientY();
- contextMenu.setPopupPosition(x, y);
- contextMenu.show();
- }
- }
- }, ContextMenuEvent.getType());
- initWidget(vp);
-
- selectionModel = new MultiSelectionModel<File>(keyProvider);
-
- celltable.setSelectionModel(selectionModel, PithosSelectionEventManager.<File> createDefaultManager());
-// celltable.setPageSize(Pithos.VISIBLE_FILE_COUNT);
-
- sinkEvents(Event.ONCONTEXTMENU);
-// sinkEvents(Event.ONMOUSEUP);
-// sinkEvents(Event.ONMOUSEDOWN);
-// sinkEvents(Event.ONCLICK);
-// sinkEvents(Event.ONKEYDOWN);
- sinkEvents(Event.ONDBLCLICK);
- Pithos.preventIESelection();
- }
-
- public List<File> getSelectedFiles() {
- return new ArrayList<File>(selectionModel.getSelectedSet());
- }
-
- @Override
- public void onBrowserEvent(Event event) {
-
-// if (files == null || files.size() == 0) {
-// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-// contextMenu = new FileContextMenu(images, false, true);
-// contextMenu.show();
-// event.preventDefault();
-// event.cancelBubble(true);
-// }
-// return;
-// }
-// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
-// GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
-// contextMenu = new FileContextMenu(images, false, false);
-// contextMenu = contextMenu.onEvent(event);
-// event.cancelBubble(true);
-// event.preventDefault();
-// } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-// contextMenu = new FileContextMenu(images, false, true);
-// contextMenu = contextMenu.onEmptyEvent(event);
-// event.cancelBubble(true);
-// event.preventDefault();
-// } else
- if (DOM.eventGetType(event) == Event.ONDBLCLICK)
- if (getSelectedFiles().size() == 1) {
- File file = getSelectedFiles().get(0);
- Window.open(app.getApiPath() + file.getOwner() + file.getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
- event.preventDefault();
- return;
- }
- super.onBrowserEvent(event);
- }
-
- /**
- * Update the display of the file list.
- */
- void update(@SuppressWarnings("unused") boolean sort) {
- showCellTable();
- }
-
- /**
- * Return the proper icon based on the MIME type of the file.
- *
- * @param file
- * @return the icon
- */
- protected ImageResource getFileIcon(File file) {
- String mimetype = file.getContentType();
- boolean shared = file.isShared();
- if (mimetype == null)
- return shared ? images.documentShared() : images.document();
- mimetype = mimetype.toLowerCase();
- if (mimetype.startsWith("application/pdf"))
- return shared ? images.pdfShared() : images.pdf();
- else if (mimetype.endsWith("excel"))
- return shared ? images.spreadsheetShared() : images.spreadsheet();
- else if (mimetype.endsWith("msword"))
- return shared ? images.wordprocessorShared() : images.wordprocessor();
- else if (mimetype.endsWith("powerpoint"))
- return shared ? images.presentationShared() : images.presentation();
- else if (mimetype.startsWith("application/zip") ||
- mimetype.startsWith("application/gzip") ||
- mimetype.startsWith("application/x-gzip") ||
- mimetype.startsWith("application/x-tar") ||
- mimetype.startsWith("application/x-gtar"))
- return shared ? images.zipShared() : images.zip();
- else if (mimetype.startsWith("text/html"))
- return shared ? images.htmlShared() : images.html();
- else if (mimetype.startsWith("text/plain"))
- return shared ? images.txtShared() : images.txt();
- else if (mimetype.startsWith("image/"))
- return shared ? images.imageShared() : images.image();
- else if (mimetype.startsWith("video/"))
- return shared ? images.videoShared() : images.video();
- else if (mimetype.startsWith("audio/"))
- return shared ? images.audioShared() : images.audio();
- return shared ? images.documentShared() : images.document();
- }
-
- /**
- * Fill the file cache with data.
- */
- public void setFiles(final List<File> _files) {
- files = new ArrayList<File>();
- for (File fres : _files)
- files.add(fres);
- Collections.sort(files, new Comparator<File>() {
-
- @Override
- public int compare(File arg0, File arg1) {
- return arg0.getName().compareTo(arg1.getName());
- }
-
- });
- folderFileCount = files.size();
-
- nameHeader.setSorted(true);
- nameHeader.toggleReverseSort();
- for (SortableHeader otherHeader : allHeaders) {
- if (otherHeader != nameHeader) {
- otherHeader.setSorted(false);
- otherHeader.setReverseSort(true);
- }
- }
-
- provider.setList(files);
- selectionModel.clear();
- app.showFolderStatistics(folderFileCount);
- celltable.setPageSize(folderFileCount);
- }
-
- /**
- * Does the list contains the requested filename
- *
- * @param fileName
- * @return true/false
- */
- public boolean contains(String fileName) {
- for (int i = 0; i < files.size(); i++)
- if (files.get(i).getName().equals(fileName))
- return true;
- return false;
- }
-
- public void clearSelectedRows() {
- Iterator<File> it = selectionModel.getSelectedSet().iterator();
- while(it.hasNext()){
- selectionModel.setSelected(it.next(),false);
- }
- }
-
- /**
- *
- */
- public void selectAllRows() {
- Iterator<File> it = provider.getList().iterator();
- while(it.hasNext()){
- selectionModel.setSelected(it.next(),true);
- }
- }
-
- protected void sortFiles(final String sortingProperty, final boolean sortingType){
- Collections.sort(files, new Comparator<File>() {
-
- @Override
- public int compare(File arg0, File arg1) {
- if (sortingType){
- if (sortingProperty.equals("version")) {
- return arg0.getVersion() - arg1.getVersion();
- } else if (sortingProperty.equals("owner")) {
- return arg0.getOwner().compareTo(arg1.getOwner());
- } else if (sortingProperty.equals("date")) {
- if (arg0.getLastModified() != null && arg1.getLastModified() != null)
- return arg0.getLastModified().compareTo(arg1.getLastModified());
- return 0;
- } else if (sortingProperty.equals("size")) {
- return (int) (arg0.getBytes() - arg1.getBytes());
- } else if (sortingProperty.equals("name")) {
- return arg0.getName().compareTo(arg1.getName());
- } else if (sortingProperty.equals("path")) {
- return arg0.getUri().compareTo(arg1.getUri());
- } else {
- return arg0.getName().compareTo(arg1.getName());
- }
- }
- else if (sortingProperty.equals("version")) {
-
- return arg1.getVersion() - arg0.getVersion();
- } else if (sortingProperty.equals("owner")) {
-
- return arg1.getOwner().compareTo(arg0.getOwner());
- } else if (sortingProperty.equals("date")) {
-
- return arg1.getLastModified().compareTo(arg0.getLastModified());
- } else if (sortingProperty.equals("size")) {
- return (int) (arg1.getBytes() - arg0.getBytes());
- } else if (sortingProperty.equals("name")) {
-
- return arg1.getName().compareTo(arg0.getName());
- } else if (sortingProperty.equals("path")) {
-
- return arg1.getUri().compareTo(arg0.getUri());
- } else {
-
- return arg1.getName().compareTo(arg0.getName());
- }
- }
-
- });
- }
-
- final class FileValueUpdater implements ValueUpdater<String>{
- private String property;
- private SortableHeader header;
- /**
- *
- */
- public FileValueUpdater(SortableHeader header,String property) {
- this.property=property;
- this.header=header;
- }
- @Override
- public void update(@SuppressWarnings("unused") String value) {
- header.setSorted(true);
- header.toggleReverseSort();
-
- for (SortableHeader otherHeader : allHeaders) {
- if (otherHeader != header) {
- otherHeader.setSorted(false);
- otherHeader.setReverseSort(true);
- }
- }
- celltable.redrawHeaders();
- sortFiles(property, header.getReverseSort());
- FileList.this.update(true);
- }
-
- }
-
- /**
- * Shows the files in the cellTable
- */
- private void showCellTable(){
- provider.setList(files);
-
- provider.refresh();
-
- //celltable.redraw();
- celltable.redrawHeaders();
- }
-}
+++ /dev/null
-/*\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.foldertree.File;\r
-import gr.grnet.pithos.web.client.foldertree.FileVersions;\r
-import gr.grnet.pithos.web.client.foldertree.Resource;\r
-import gr.grnet.pithos.web.client.foldertree.Version;\r
-import gr.grnet.pithos.web.client.rest.GetRequest;\r
-import gr.grnet.pithos.web.client.rest.PostRequest;\r
-import gr.grnet.pithos.web.client.rest.PutRequest;\r
-import gr.grnet.pithos.web.client.rest.RestException;\r
-import gr.grnet.pithos.web.client.tagtree.Tag;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.core.client.Scheduler;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.http.client.Response;\r
-import com.google.gwt.http.client.URL;\r
-import com.google.gwt.i18n.client.DateTimeFormat;\r
-import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.Window;\r
-import com.google.gwt.user.client.ui.Anchor;\r
-import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.CheckBox;\r
-import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
-import com.google.gwt.user.client.ui.DisclosurePanel;\r
-import com.google.gwt.user.client.ui.FlexTable;\r
-import com.google.gwt.user.client.ui.FlowPanel;\r
-import com.google.gwt.user.client.ui.FocusPanel;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.Label;\r
-import com.google.gwt.user.client.ui.TextBox;\r
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-\r
-/**\r
- * The 'File properties' dialog box implementation.\r
- *\r
- */\r
-public class FilePropertiesDialog extends AbstractPropertiesDialog {\r
-\r
- protected PermissionsList permList;\r
-\r
- protected CheckBox readForAll;\r
-\r
- /**\r
- * An image bundle for this widgets images.\r
- */\r
- public interface Images extends MessagePanel.Images {\r
-\r
- @Source("gr/grnet/pithos/resources/edit_user.png")\r
- ImageResource permUser();\r
-\r
- @Source("gr/grnet/pithos/resources/groups22.png")\r
- ImageResource permGroup();\r
-\r
- @Source("gr/grnet/pithos/resources/editdelete.png")\r
- ImageResource delete();\r
-\r
- @Source("gr/grnet/pithos/resources/db_update.png")\r
- ImageResource restore();\r
-\r
- @Source("gr/grnet/pithos/resources/folder_inbox.png")\r
- ImageResource download();\r
- }\r
-\r
- /**\r
- * The widget that holds the name of the file.\r
- */\r
- private TextBox name = new TextBox();\r
-\r
- final File file;\r
-\r
- Images images = GWT.create(Images.class);\r
-\r
- /**\r
- * The widget's constructor.\r
- */\r
- public FilePropertiesDialog(Pithos _app, File _file) {\r
- super(_app);\r
- file = _file;\r
-\r
- Anchor close = new Anchor();\r
- close.addStyleName("close");\r
- close.addClickHandler(new ClickHandler() {\r
- \r
- @Override\r
- public void onClick(ClickEvent event) {\r
- hide();\r
- }\r
- });\r
- // Set the dialog's caption.\r
- setText("File properties");\r
- setAnimationEnabled(true);\r
- setGlassEnabled(true);\r
- setStyleName("pithos-DialogBox");\r
-\r
- // Outer contains inner and buttons.\r
- final VerticalPanel outer = new VerticalPanel();\r
- outer.add(close);\r
- final FocusPanel focusPanel = new FocusPanel(outer);\r
- // Inner contains generalPanel and permPanel.\r
- inner = new DecoratedTabPanel();\r
- inner.setAnimationEnabled(true);\r
- inner.addStyleName("inner");\r
- inner.getDeckPanel().addStyleName("pithos-TabPanelBottom");\r
-\r
-\r
- inner.add(createGeneralPanel(), "General");\r
-\r
- inner.add(createSharingPanel(), "Sharing");\r
-\r
- fetchVersions();\r
- \r
- inner.selectTab(0);\r
-\r
- outer.add(inner);\r
-\r
- // Create the 'OK' button, along with a listener that hides the dialog\r
- // when the button is clicked.\r
- final Button ok = new Button("OK", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- accept();\r
- closeDialog();\r
- }\r
- });\r
- ok.addStyleName("button");\r
-\r
- outer.add(ok);\r
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- focusPanel.setFocus(true);\r
- setWidget(outer);\r
- }\r
-\r
- protected void fetchVersions() {\r
- String path = file.getUri() + "?format=json&version=list";\r
- GetRequest<FileVersions> getVersions = new GetRequest<FileVersions>(FileVersions.class, app.getApiPath(), file.getOwner(), path) {\r
-\r
- @Override\r
- public void onSuccess(FileVersions _result) {\r
- inner.add(createVersionPanel(_result.getVersions()), "Versions");\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if (t instanceof RestException) {\r
- app.displayError("Unable to fetch versions: " + ((RestException) t).getHttpStatusText());\r
- }\r
- else\r
- app.displayError("System error unable to fetch versions: "+t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- getVersions.setHeader("X-Auth-Token", app.getToken());\r
- Scheduler.get().scheduleDeferred(getVersions);\r
- }\r
-\r
- private VerticalPanel createGeneralPanel() {\r
- final VerticalPanel generalPanel = new VerticalPanel();\r
- final FlexTable generalTable = new FlexTable();\r
- generalTable.setText(0, 0, "Name");\r
- generalTable.setText(1, 0, "Folder");\r
- generalTable.setText(2, 0, "Owner");\r
- generalTable.setText(3, 0, "Last modified");\r
- generalTable.setText(4, 0, "Tags");\r
-\r
- name.setWidth("100%");\r
- name.setText(file.getName());\r
- generalTable.setWidget(0, 1, name);\r
- if(file.getParent() != null)\r
- generalTable.setText(1, 1, file.getParent().getName());\r
- else\r
- generalTable.setText(1, 1, "-");\r
- generalTable.setText(2, 1, file.getOwner());\r
-\r
- final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
- generalTable.setText(3, 1, file.getLastModified() != null ? formatter.format(file.getLastModified()) : "");\r
-\r
- StringBuffer tagsBuffer = new StringBuffer();\r
- for (String t : file.getTags())\r
- tagsBuffer.append(t).append(", ");\r
- if (tagsBuffer.length() > 1)\r
- tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1);\r
- initialTagText = tagsBuffer.toString();\r
- tags.setWidth("100%");\r
- tags.setText(initialTagText);\r
- generalTable.setWidget(4, 1, tags);\r
-\r
- generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values");\r
- generalTable.setCellSpacing(4);\r
-\r
- generalPanel.add(generalTable);\r
-\r
- DisclosurePanel allTags = new DisclosurePanel("All tags");\r
- allTagsContent = new FlowPanel();\r
- allTagsContent.setWidth("100%");\r
- for (Tag t : app.getAllTags()) {\r
- final Anchor tagAnchor = new Anchor(t.getName(), false);\r
- tagAnchor.addStyleName("pithos-tag");\r
- allTagsContent.add(tagAnchor);\r
- Label separator = new Label(", ");\r
- separator.addStyleName("pithos-tag");\r
- allTagsContent.add(separator);\r
- tagAnchor.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- String existing = tags.getText().trim();\r
- if (MULTIPLE_VALUES_TEXT.equals(existing))\r
- existing = "";\r
- String newTag = tagAnchor.getText().trim();\r
- // insert the new tag only if it is not in the list\r
- // already\r
- if (existing.indexOf(newTag) == -1)\r
- tags.setText(existing + (existing.length() > 0 ? ", " : "") + newTag);\r
- }\r
- });\r
- }\r
- allTags.setContent(allTagsContent);\r
- generalPanel.add(allTags);\r
- generalPanel.setSpacing(4);\r
- return generalPanel;\r
- }\r
-\r
- private VerticalPanel createSharingPanel() {\r
- VerticalPanel permPanel = new VerticalPanel();\r
-\r
- permList = new PermissionsList(images, file.getPermissions(), file.getOwner(), file.getInheritedPermissionsFrom() != null);\r
- permPanel.add(permList);\r
-\r
- if (file.getInheritedPermissionsFrom() == null) {\r
- HorizontalPanel permButtons = new HorizontalPanel();\r
- Button add = new Button("Add Group", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);\r
- dlg.center();\r
- permList.updatePermissionTable();\r
- }\r
- });\r
- add.addStyleName("button");\r
- permButtons.add(add);\r
- permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- final Button addUser = new Button("Add User", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true);\r
- dlg.center();\r
- permList.updatePermissionTable();\r
- }\r
- });\r
- addUser.addStyleName("button");\r
- permButtons.add(addUser);\r
- permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- permButtons.setSpacing(8);\r
- permButtons.addStyleName("pithos-TabPanelBottom");\r
- permPanel.add(permButtons);\r
- }\r
-\r
- final Label readForAllNote = new Label("When this option is enabled, the file will be readable" +\r
- " by everyone. By checking this option, you are certifying that you have the right to " +\r
- "distribute this file and that it does not violate the Terms of Use.", true);\r
- readForAllNote.setVisible(false);\r
- readForAllNote.setStylePrimaryName("pithos-readForAllNote");\r
-\r
- readForAll = new CheckBox();\r
- readForAll.setValue(file.isPublished());\r
- readForAll.addClickHandler(new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- readForAllNote.setVisible(readForAll.getValue());\r
- }\r
- });\r
-\r
- // Only show the read for all permission if the user is the owner.\r
- if (file.getOwner().equals(app.getUsername())) {\r
- final HorizontalPanel permForAll = new HorizontalPanel();\r
- permForAll.add(new Label("Public"));\r
- permForAll.add(readForAll);\r
- permForAll.setSpacing(8);\r
- permForAll.addStyleName("pithos-TabPanelBottom");\r
- permForAll.add(readForAllNote);\r
- permPanel.add(permForAll);\r
- }\r
-\r
- if (file.isPublished()) {\r
- final HorizontalPanel pathPanel = new HorizontalPanel();\r
- pathPanel.setWidth("100%");\r
- pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\r
- pathPanel.add(new Label("Link"));\r
- pathPanel.setSpacing(8);\r
- pathPanel.addStyleName("pithos-TabPanelBottom");\r
-\r
- TextBox path = new TextBox();\r
- path.setWidth("100%");\r
- path.addClickHandler(new ClickHandler() {\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- Pithos.enableIESelection();\r
- ((TextBox) event.getSource()).selectAll();\r
- Pithos.preventIESelection();\r
- }\r
- });\r
- path.setText(Window.Location.getHost() + file.getPublicUri());\r
- path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");\r
- path.setWidth("100%");\r
- path.setReadOnly(true);\r
- pathPanel.add(path);\r
- permPanel.add(pathPanel);\r
- }\r
-\r
- return permPanel;\r
- }\r
-\r
- VerticalPanel createVersionPanel(List<Version> versions) {\r
- VerticalPanel versionPanel = new VerticalPanel();\r
- VersionsList verList = new VersionsList(app, this, images, file, versions);\r
- versionPanel.add(verList);\r
- return versionPanel;\r
- }\r
-\r
- /**\r
- * Accepts any change and updates the file\r
- *\r
- */\r
- @Override\r
- protected void accept() {\r
- String newFilename = null;\r
-\r
- final Map<String, Boolean[]> perms = (permList.hasChanges() ? permList.getPermissions() : null);\r
-\r
- if (!name.getText().trim().equals(file.getName())) {\r
- newFilename = name.getText().trim();\r
- }\r
-\r
- //only update the read for all perm if the user is the owner\r
- Boolean published = null;\r
- if (readForAll.getValue() != file.isPublished())\r
- if (file.getOwner().equals(app.getUsername()))\r
- published = readForAll.getValue();\r
- final Boolean finalPublished = published;\r
-\r
- String[] tagset = null;\r
- if (!tags.getText().equals(initialTagText))\r
- tagset = tags.getText().trim().split(",");\r
- final String[] newTags = tagset;\r
-\r
- if (newFilename != null) {\r
- final String path = file.getParent().getUri() + "/" + newFilename;\r
- PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- updateMetaData(app.getApiPath(), file.getOwner(), path + "?update=", newTags, finalPublished, perms);\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- app.displayError("System error modifying file:" + t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- updateFile.setHeader("X-Auth-Token", app.getToken());\r
- updateFile.setHeader("X-Move-From", file.getUri());\r
- updateFile.setHeader("Content-Type", file.getContentType());\r
- Scheduler.get().scheduleDeferred(updateFile);\r
- }\r
- else\r
- updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", newTags, finalPublished, perms);\r
- }\r
-\r
- protected void updateMetaData(String api, String owner, String path, String[] newTags, Boolean published, Map<String, Boolean[]> newPermissions) {\r
- if (newTags != null || published != null || newPermissions != null) {\r
- PostRequest updateFile = new PostRequest(api, owner, path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- app.updateFolder(file.getParent(), true, null);\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- app.displayError("System error modifying file:" + t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- updateFile.setHeader("X-Auth-Token", app.getToken());\r
- for (String t : file.getTags()) {\r
- updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(t.trim()), "~");\r
- }\r
- if (newTags != null)\r
- for (String t : newTags)\r
- if (t.length() > 0)\r
- updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(t.trim()), "true");\r
- if (published != null)\r
- updateFile.setHeader("X-Object-Public", published.toString());\r
- if (newPermissions != null) {\r
- String readPermHeader = "read=";\r
- String writePermHeader = "write=";\r
- for (String u : newPermissions.keySet()) {\r
- Boolean[] p = newPermissions.get(u);\r
- if (p[0] != null && p[0])\r
- readPermHeader += u + ",";\r
- if (p[1] != null && p[1])\r
- writePermHeader += u + ",";\r
- }\r
- if (readPermHeader.endsWith("="))\r
- readPermHeader = "";\r
- else if (readPermHeader.endsWith(","))\r
- readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
- if (writePermHeader.endsWith("="))\r
- writePermHeader = "";\r
- else if (writePermHeader.endsWith(","))\r
- writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
- String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader;\r
- if (permHeader.length() == 0)\r
- permHeader="~";\r
- updateFile.setHeader("X-Object-Sharing", permHeader);\r
- }\r
- Scheduler.get().scheduleDeferred(updateFile);\r
- }\r
- else\r
- app.updateFolder(file.getParent(), true, null);\r
- }\r
-}\r
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FileUpload;
-import com.google.gwt.user.client.ui.FormPanel;
-import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
-import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
-import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
-import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.Hidden;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-/**
- * The 'File upload' dialog box implementation.
- */
-public class FileUploadDialog extends DialogBox {
-
- public static final boolean DONE = true;
-
- /**
- * The Form element that performs the file upload.
- */
- protected final FormPanel form = new FormPanel();
-
- private final FileUpload upload = new FileUpload();
-
- private final Label filenameLabel = new Label();
-
- private final Label foldernameLabel = new Label();
-
- private Button submit;
-
- protected Folder folder;
-
- protected Pithos app;
-
- /**
- * The widget's constructor.
- */
- public FileUploadDialog() {
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- // Set the dialog's caption.
- setText("File upload");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
- // Since we're going to add a FileUpload widget, we'll need to set the
- // form to use the POST method, and multipart MIME encoding.
- form.setEncoding(FormPanel.ENCODING_MULTIPART);
- form.setMethod(FormPanel.METHOD_POST);
-
- // Create a panel to hold all of the form widgets.
- VerticalPanel panel = new VerticalPanel();
- panel.add(close);
- form.setWidget(panel);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
-
- final Hidden auth = new Hidden("X-Auth-Token");
- inner.add(auth);
- upload.setName("X-Object-Data");
- filenameLabel.setText("");
- filenameLabel.setVisible(false);
- filenameLabel.setStyleName("props-labels");
- HorizontalPanel fileUploadPanel = new HorizontalPanel();
- fileUploadPanel.add(filenameLabel);
- fileUploadPanel.add(upload);
- Grid generalTable = new Grid(2, 2);
- generalTable.setText(0, 0, "Folder");
- generalTable.setWidget(0, 1, foldernameLabel);
- generalTable.setText(1, 0, "File");
- generalTable.setWidget(1, 1, fileUploadPanel);
- generalTable.getCellFormatter().setStyleName(0, 0, "props-labels");
- generalTable.getCellFormatter().setStyleName(0, 1, "props-values");
- generalTable.getCellFormatter().setStyleName(1, 0, "props-labels");
- generalTable.getCellFormatter().setStyleName(1, 1, "props-values");
- generalTable.setCellSpacing(4);
-
- inner.add(generalTable);
-
- // Create the 'upload' button, along with a listener that submits the
- // form.
- submit = new Button("Upload", new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- prepareAndSubmit();
- }
- });
- submit.addStyleName("button");
- inner.add(submit);
-
- // Add an event handler to the form.
- form.addSubmitHandler(new SubmitHandler() {
-
- @Override
- public void onSubmit(@SuppressWarnings("unused") SubmitEvent event) {
- auth.setValue(app.getToken()); //This is done here because the app object is not available in the constructor
- Cookies.setCookie("X-Auth-Token", app.getToken(), null, "", "/", false);
- }
- });
- form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
-
- @Override
- public void onSubmitComplete(SubmitCompleteEvent event) {
- // When the form submission is successfully completed, this
- // event is fired. Assuming the service returned a response
- // of type text/html, we can get the result text here (see
- // the FormPanel documentation for further explanation).
- String results = event.getResults();
-
- // Unfortunately the results are never empty, even in
- // the absense of errors, so we have to check for '<pre></pre>'.
- if (results != null && results.length() > 0 && !results.equalsIgnoreCase("<pre></pre>")) {
- GWT.log(results, null);
- app.displayError(results);
- }
- if (app.getSelectedTree().equals(app.getFolderTreeView()))
- app.updateFolder(folder, true, new Command() {
-
- @Override
- public void execute() {
- app.updateStatistics();
- }
- });
- else
- app.updateOtherSharedFolder(folder, true);
- hide();
- }
- });
-
- panel.add(inner);
- panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
-
- setWidget(form);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
-
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- prepareAndSubmit();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
- /**
- * Make any last minute checks and start the upload.
- */
- protected void prepareAndSubmit() {
- if (upload.getFilename().length() == 0) {
- app.displayError("You must select a file!");
- return;
- }
- final String fname = getFilename(upload.getFilename());
- String apath = app.getApiPath() + folder.getOwner() + folder.getUri() + "/" + fname + "?X-Auth-Token=" + app.getToken();
- form.setAction(apath);
- submit.setEnabled(false);
- upload.setVisible(false);
- filenameLabel.setText(fname);
- filenameLabel.setVisible(true);
-
- if (getFileForName(fname) == null) {
- form.submit();
- }
- else {
- // We are going to update an existing file, so show a confirmation dialog.
- ConfirmationDialog confirm = new ConfirmationDialog("Are you sure " +
- "you want to update " + fname + "?", "Update") {
-
- @Override
- public void cancel() {
- FileUploadDialog.this.hide();
- }
-
- @Override
- public void confirm() {
- form.submit();
- }
-
- };
- confirm.center();
- }
- }
-
- /**
- * Returns the file name from a potential full path argument. Apparently IE
- * insists on sending the full path name of a file when uploading, forcing
- * us to trim the extra path info. Since this is only observed on Windows we
- * get to check for a single path separator value.
- *
- * @param name the potentially full path name of a file
- * @return the file name without extra path information
- */
- protected String getFilename(String name) {
- int pathSepIndex = name.lastIndexOf("\\");
- if (pathSepIndex == -1) {
- pathSepIndex = name.lastIndexOf("/");
- if (pathSepIndex == -1)
- return name;
- }
- return name.substring(pathSepIndex + 1);
- }
-
- protected File getFileForName(String name){
- for (File f : folder.getFiles())
- if (f.getName().equals(name))
- return f;
- return null;
- }
-
- public void setApp(Pithos app) {
- this.app = app;
- }
-
- public void setFolder(Folder folder) {
- this.folder = folder;
- foldernameLabel.setText(folder.getName());
- }
-}
+++ /dev/null
-/*\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.foldertree.File;\r
-import gr.grnet.pithos.web.client.foldertree.Folder;\r
-\r
-import java.util.List;\r
-\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
-import com.google.gwt.user.client.ui.DisclosurePanel;\r
-import com.google.gwt.user.client.ui.FlexTable;\r
-import com.google.gwt.user.client.ui.FlowPanel;\r
-import com.google.gwt.user.client.ui.FocusPanel;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-\r
-/**\r
- * The 'Multiple file properties' dialog box implementation.\r
- *\r
- */\r
-public class FilesPropertiesDialog extends AbstractPropertiesDialog {\r
-\r
-// private final TristateCheckBox versionedCheck;\r
-\r
- private final List<File> files;\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- * @param _files\r
- */\r
- public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
- super(_app);\r
-\r
- files = _files;\r
-\r
- // Set the dialog's caption.\r
- setText("Files properties");\r
-\r
- // Outer contains inner and buttons.\r
- final VerticalPanel outer = new VerticalPanel();\r
- final FocusPanel focusPanel = new FocusPanel(outer);\r
- // Inner contains generalPanel and permPanel.\r
- inner = new DecoratedTabPanel();\r
- inner.setAnimationEnabled(true);\r
-\r
- inner.add(createGeneralPanel(), "General");\r
-\r
- inner.selectTab(0);\r
- outer.add(inner);\r
-\r
- final HorizontalPanel buttons = new HorizontalPanel();\r
- // Create the 'OK' button, along with a listener that hides the dialog\r
- // when the button is clicked.\r
- final Button ok = new Button("OK", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- accept();\r
- closeDialog();\r
- }\r
- });\r
- buttons.add(ok);\r
- buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
- // Create the 'Cancel' button, along with a listener that hides the\r
- // dialog when the button is clicked.\r
- final Button cancel = new Button("Cancel", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- closeDialog();\r
- }\r
- });\r
- buttons.add(cancel);\r
- buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
- buttons.setSpacing(8);\r
- buttons.addStyleName("pithos-TabPanelBottom");\r
- outer.add(buttons);\r
- outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
- outer.addStyleName("pithos-TabPanelBottom");\r
-\r
- focusPanel.setFocus(true);\r
- setWidget(outer);\r
- }\r
-\r
- private VerticalPanel createGeneralPanel() {\r
- VerticalPanel generalPanel = new VerticalPanel();\r
-\r
- final FlexTable generalTable = new FlexTable();\r
- generalTable.setText(0, 0, String.valueOf(files.size())+" files selected");\r
- generalTable.setText(1, 0, "Folder");\r
- generalTable.setText(2, 0, "Tags");\r
- Folder parent = files.get(0).getParent();\r
- if(parent != null)\r
- generalTable.setText(1, 1, parent.getName());\r
- else\r
- generalTable.setText(1, 1, "-");\r
-\r
- generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setColSpan(0, 0, 2);\r
- generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
- generalTable.setCellSpacing(4);\r
-\r
- generalPanel.add(generalTable);\r
-\r
- DisclosurePanel allTags = new DisclosurePanel("All tags");\r
- allTagsContent = new FlowPanel();\r
- allTags.setContent(allTagsContent);\r
- generalPanel.add(allTags);\r
- generalPanel.setSpacing(4);\r
-\r
- return generalPanel;\r
- }\r
-\r
- /**\r
- * Accepts any change and updates the file\r
- *\r
- */\r
- @Override\r
- protected void accept() {\r
- }\r
-}\r
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.commands.CopyCommand;
-import gr.grnet.pithos.web.client.commands.CutCommand;
-import gr.grnet.pithos.web.client.commands.DeleteCommand;
-import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
-import gr.grnet.pithos.web.client.commands.NewFolderCommand;
-import gr.grnet.pithos.web.client.commands.PasteCommand;
-import gr.grnet.pithos.web.client.commands.PropertiesCommand;
-import gr.grnet.pithos.web.client.commands.RefreshCommand;
-import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
-import gr.grnet.pithos.web.client.commands.ToTrashCommand;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import java.util.List;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'Folder Context' menu implementation.
- */
-public class FolderContextMenu extends PopupPanel {
-
- /**
- * The widget's images.
- */
- private final Images images;
-
- /**
- * The image bundle for this widget's images that reuses images defined in
- * other menus.
- */
- public interface Images extends FileContextMenu.Images {
- }
-
- private MenuItem pasteItem;
-
- /**
- * The widget's constructor.
- *
- * @param newImages the image bundle passed on by the parent object
- */
- public FolderContextMenu(Pithos app, final Images newImages, TreeView selectedTree, Folder folder) {
- // The popup's constructor's argument is a boolean specifying that it
- // auto-close itself when the user clicks outside of it.
- super(true);
- setAnimationEnabled(true);
- images = newImages;
- MenuBar contextMenu = new MenuBar(true);
-
- Boolean[] permissions = folder.getPermissions().get(app.getUsername());
- boolean canWrite = folder.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
- boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView());
- boolean otherSharedTreeSelected = selectedTree.equals(app.getOtherSharedTreeView());
-
- if (isFolderTreeSelected || otherSharedTreeSelected) {
- MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(app, this, folder));
- contextMenu.addItem(refresh);
- }
-
- if (!folder.isInTrash()) {
- if (canWrite) {
- MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
- contextMenu.addItem(newFolder);
-
- if (isFolderTreeSelected && !folder.isContainer()) {
- MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(app, this, folder));
- contextMenu.addItem(cut);
- }
- }
-
- MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(app, this, folder));
- contextMenu.addItem(copy);
-
- if (canWrite) {
- if (!app.getClipboard().isEmpty()) {
- Object item = app.getClipboard().getItem();
- boolean showPaste = true;
- if (item instanceof Folder) {
- Folder f = (Folder) item;
- if (f.contains(folder))
- showPaste = false;
- }
- if (showPaste) {
- pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, folder));
- contextMenu.addItem(pasteItem);
- }
- }
-
- if (isFolderTreeSelected && !folder.isContainer()) {
- MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(app, this, folder));
- contextMenu.addItem(moveToTrash);
-
- MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
- contextMenu.addItem(delete);
-
- MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
- contextMenu.addItem(properties);
- }
- }
- }
- else {
- if (!folder.isTrash()) {
- MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(app, this, folder));
- contextMenu.addItem(restore);
-
- MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
- contextMenu.addItem(delete);
- }
- else {
- MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(app, this));
- contextMenu.addItem(emptyTrash);
- }
- }
- add(contextMenu);
- }
-}
+++ /dev/null
-/*\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 com.google.gwt.core.client.Scheduler;\r
-import com.google.gwt.event.dom.client.KeyDownEvent;\r
-import com.google.gwt.user.client.Command;\r
-import gr.grnet.pithos.web.client.foldertree.File;\r
-import gr.grnet.pithos.web.client.foldertree.Folder;\r
-import gr.grnet.pithos.web.client.foldertree.Resource;\r
-import gr.grnet.pithos.web.client.rest.PostRequest;\r
-import gr.grnet.pithos.web.client.rest.PutRequest;\r
-import gr.grnet.pithos.web.client.rest.RestException;\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.ChangeEvent;\r
-import com.google.gwt.event.dom.client.ChangeHandler;\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.http.client.Response;\r
-import com.google.gwt.i18n.client.DateTimeFormat;\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.Button;\r
-import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
-import com.google.gwt.user.client.ui.DialogBox;\r
-import com.google.gwt.user.client.ui.FlexTable;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\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
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-\r
-/**\r
- * The 'Folder properties' dialog box implementation.\r
- */\r
-public class FolderPropertiesDialog extends DialogBox {\r
-\r
- protected Pithos app;\r
-\r
- /**\r
- * The widget that holds the folderName of the folder.\r
- */\r
- TextBox folderName = new TextBox();\r
-\r
- /**\r
- * A flag that denotes whether the dialog will be used to create or modify a\r
- * folder.\r
- */\r
- private final boolean create;\r
-\r
- protected PermissionsList permList;\r
-\r
- final Folder folder;\r
-\r
- final TabPanel inner;\r
-\r
- /**\r
- * The widget's constructor.\r
- */\r
- public FolderPropertiesDialog(final Pithos app, boolean _create, Folder selected) {\r
- this.app = app;\r
- Anchor close = new Anchor();\r
- close.addStyleName("close");\r
- close.addClickHandler(new ClickHandler() {\r
- \r
- @Override\r
- public void onClick(ClickEvent event) {\r
- hide();\r
- }\r
- });\r
-\r
- setAnimationEnabled(true);\r
- setGlassEnabled(true);\r
- setStyleName("pithos-DialogBox");\r
-\r
- // Enable IE selection for the dialog (must disable it upon closing it)\r
- Pithos.enableIESelection();\r
-\r
- create = _create;\r
- \r
- folder = selected;\r
-\r
- // Use this opportunity to set the dialog's caption.\r
- if (create)\r
- setText("Create folder");\r
- else\r
- setText("Folder properties");\r
-\r
- // Outer contains inner and buttons\r
- VerticalPanel outer = new VerticalPanel();\r
- outer.add(close);\r
- // Inner contains generalPanel and permPanel\r
- inner = new DecoratedTabPanel();\r
- inner.setAnimationEnabled(true);\r
- inner.addStyleName("inner");\r
- inner.getDeckPanel().addStyleName("pithos-TabPanelBottom");\r
-\r
- VerticalPanel generalPanel = new VerticalPanel();\r
- FlexTable generalTable = new FlexTable();\r
- generalTable.setText(0, 0, "Name");\r
- generalTable.setText(1, 0, "Parent");\r
- generalTable.setText(2, 0, "Creator");\r
- generalTable.setText(3, 0, "Last modified");\r
-\r
- folderName.setText(create ? "" : folder.getName());\r
- folderName.setReadOnly(folder.isContainer() && !create);\r
- generalTable.setWidget(0, 1, folderName);\r
-\r
- final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true);\r
- folderNameNote.setVisible(false);\r
- folderNameNote.setStylePrimaryName("gss-readForAllNote");\r
- generalTable.setWidget(0, 2, folderNameNote);\r
- \r
- if (create)\r
- generalTable.setText(1, 1, folder.getName());\r
- else\r
- generalTable.setText(1, 1, folder.getPrefix());\r
- generalTable.setText(2, 1, "");\r
- DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
- if(folder.getLastModified() != null)\r
- generalTable.setText(3, 1, formatter.format(folder.getLastModified()));\r
- generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels");\r
- generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
- generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values");\r
- generalTable.setCellSpacing(4);\r
- generalPanel.add(generalTable);\r
- inner.add(generalPanel, "General");\r
-\r
- VerticalPanel permPanel = new VerticalPanel();\r
- FilePropertiesDialog.Images images = GWT.create(FilePropertiesDialog.Images.class);\r
- boolean permsReadonly = folder.getInheritedPermissionsFrom() != null || folder.existChildrenPermissions();\r
- permList = new PermissionsList(images, folder.getPermissions(), folder.getOwner(), permsReadonly);\r
- permPanel.add(permList);\r
-\r
- if (!permsReadonly) {\r
- HorizontalPanel permButtons = new HorizontalPanel();\r
- Button add = new Button("Add Group", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);\r
- dlg.center();\r
- }\r
- });\r
- add.addStyleName("button");\r
- permButtons.add(add);\r
- permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- Button addUser = new Button("Add User", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true);\r
- dlg.center();\r
- }\r
- });\r
- addUser.addStyleName("button");\r
- permButtons.add(addUser);\r
- permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER);\r
- permButtons.setSpacing(8);\r
- permPanel.add(permButtons);\r
- }\r
-\r
- if (!create)\r
- inner.add(permPanel, "Sharing");\r
- inner.selectTab(0);\r
-\r
- outer.add(inner);\r
-\r
- // Create the 'Create/Update' button, along with a listener that hides the dialog\r
- // when the button is clicked and quits the application.\r
- String okLabel;\r
- if (create)\r
- okLabel = "Create";\r
- else\r
- okLabel = "Update";\r
- final Button ok = new Button(okLabel, new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- createOrUpdateFolder();\r
- closeDialog();\r
- }\r
- });\r
- ok.addStyleName("button");\r
- outer.add(ok);\r
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
-\r
- folderName.addChangeHandler(new ChangeHandler() {\r
- \r
- @Override\r
- public void onChange(@SuppressWarnings("unused") ChangeEvent event) {\r
- if(folderName.getText().contains("/")) {\r
- folderNameNote.setVisible(true);\r
- ok.setEnabled(false);\r
- }\r
- else {\r
- folderNameNote.setVisible(false);\r
- ok.setEnabled(true);\r
- }\r
- }\r
- });\r
-\r
- setWidget(outer);\r
- }\r
-\r
- @Override\r
- public void center() {\r
- super.center();\r
- folderName.setFocus(true);\r
- }\r
-\r
- @Override\r
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
- super.onPreviewNativeEvent(preview);\r
-\r
- NativeEvent evt = preview.getNativeEvent();\r
- if (evt.getType().equals(KeyDownEvent.getType().getName()))\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (evt.getKeyCode()) {\r
- case KeyCodes.KEY_ENTER:\r
- createOrUpdateFolder();\r
- closeDialog();\r
- break;\r
- case KeyCodes.KEY_ESCAPE:\r
- closeDialog();\r
- break;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Enables IE selection prevention and hides the dialog\r
- * (we disable the prevention on creation of the dialog)\r
- */\r
- public void closeDialog() {\r
- Pithos.preventIESelection();\r
- hide();\r
- }\r
-\r
- /**\r
- * Generate an RPC request to create a new folder.\r
- */\r
- private void createFolder() {\r
- String name = folderName.getText().trim();\r
- String path = folder.getUri() + "/" + name;\r
- PutRequest createFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- app.updateFolder(folder, true, new Command() {\r
- \r
- @Override\r
- public void execute() {\r
- app.updateStatistics();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if (t instanceof RestException) {\r
- app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());\r
- }\r
- else\r
- app.displayError("System error creating folder:" + t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- createFolder.setHeader("X-Auth-Token", app.getToken());\r
- createFolder.setHeader("Accept", "*/*");\r
- createFolder.setHeader("Content-Length", "0");\r
- createFolder.setHeader("Content-Type", "application/directory");\r
- Scheduler.get().scheduleDeferred(createFolder);\r
- }\r
-\r
- /**\r
- * Upon closing the dialog by clicking OK or pressing ENTER this method does\r
- * the actual work of modifying folder properties or creating a new Folder\r
- * depending on the value of the create field\r
- */\r
- protected void createOrUpdateFolder() {\r
- if (create)\r
- createFolder();\r
- else\r
- updateFolder();\r
-\r
- }\r
-\r
- private void updateFolder() {\r
- final Map<String, Boolean[]> perms = (permList.hasChanges() ? permList.getPermissions() : null);\r
- final String newName = folderName.getText().trim();\r
- if (!folder.isContainer() && !folder.getName().equals(newName)) {\r
- final String path = folder.getParent().getUri() + "/" + newName;\r
- PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getParent().getOwner(), path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- Iterator<File> iter = folder.getFiles().iterator();\r
- app.copyFiles(iter, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {\r
- @Override\r
- public void execute() {\r
- Iterator<Folder> iterf = folder.getSubfolders().iterator();\r
- app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {\r
- @Override\r
- public void execute() {\r
- app.deleteFolder(folder);\r
- updateMetadata(path + "?update=", perms);\r
- }\r
- });\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if(t instanceof RestException){\r
- app.displayError("Unable to update folder: " + ((RestException) t).getHttpStatusText());\r
- }\r
- else\r
- app.displayError("System error modifying folder: " + t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- newFolder.setHeader("X-Auth-Token", app.getToken());\r
- newFolder.setHeader("Content-Type", "application/folder");\r
- newFolder.setHeader("Accept", "*/*");\r
- newFolder.setHeader("Content-Length", "0");\r
- Scheduler.get().scheduleDeferred(newFolder);\r
- }\r
- else\r
- updateMetadata(folder.getUri() + "?update=", perms);\r
- }\r
-\r
- protected void updateMetadata(final String path, final Map<String, Boolean[]> newPermissions) {\r
- if (newPermissions != null) {\r
- PostRequest updateFolder = new PostRequest(app.getApiPath(), folder.getOwner(), path) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- app.updateFolder(folder.getParent(), false, null);\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if (t instanceof RestException) {\r
- if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { //Probably a virtual folder\r
- final String path1 = folder.getUri();\r
- PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path1) {\r
- @Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
- updateMetadata(path, newPermissions);\r
- }\r
-\r
- @Override\r
- public void onError(Throwable _t) {\r
- GWT.log("", _t);\r
- if(_t instanceof RestException){\r
- app.displayError("Unable to update folder: " + ((RestException) _t).getHttpStatusText());\r
- }\r
- else\r
- app.displayError("System error modifying folder: " + _t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- newFolder.setHeader("X-Auth-Token", app.getToken());\r
- newFolder.setHeader("Content-Type", "application/folder");\r
- newFolder.setHeader("Accept", "*/*");\r
- newFolder.setHeader("Content-Length", "0");\r
- Scheduler.get().scheduleDeferred(newFolder);\r
- }\r
- else if (((RestException) t).getHttpStatusCode() == Response.SC_CONFLICT) {\r
- app.displayError("Cannot set permissions. Probably subfolders or files already have permissions set");\r
- }\r
- else\r
- app.displayError("Wrror modifying folder: " + t.getMessage());\r
- }\r
- else\r
- app.displayError("System error modifying folder: " + t.getMessage());\r
- }\r
-\r
- @Override\r
- protected void onUnauthorized(Response response) {\r
- app.sessionExpired();\r
- }\r
- };\r
- updateFolder.setHeader("X-Auth-Token", app.getToken());\r
- String readPermHeader = "read=";\r
- String writePermHeader = "write=";\r
- for (String u : newPermissions.keySet()) {\r
- Boolean[] p = newPermissions.get(u);\r
- if (p[0] != null && p[0])\r
- readPermHeader += u + ",";\r
- if (p[1] != null && p[1])\r
- writePermHeader += u + ",";\r
- }\r
- if (readPermHeader.endsWith("="))\r
- readPermHeader = "";\r
- else if (readPermHeader.endsWith(","))\r
- readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
- if (writePermHeader.endsWith("="))\r
- writePermHeader = "";\r
- else if (writePermHeader.endsWith(","))\r
- writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
- String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader;\r
- if (permHeader.length() == 0)\r
- permHeader="~";\r
- updateFolder.setHeader("X-Object-Sharing", permHeader);\r
- Scheduler.get().scheduleDeferred(updateFolder);\r
- }\r
- else\r
- app.updateFolder(folder.getParent(), false, null);\r
- }\r
-\r
- public void selectTab(int _tab) {\r
- inner.selectTab(_tab);\r
- }\r
-}\r
+++ /dev/null
-package gr.grnet.pithos.web.client;
-
-import java.util.Date;
-
-import com.google.gwt.http.client.Response;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONValue;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-public class Invitations extends Resource {
-
- private int invitationsLeft = 0;
-
- @Override
- public Date getLastModified() {
- return null;
- }
-
- public int getInvitationsLeft() {
- return invitationsLeft;
- }
-
- public void setInvitationsLeft(int invitationsLeft) {
- this.invitationsLeft = invitationsLeft;
- }
-
- public static Invitations createFromResponse(Response response) {
- Invitations result = new Invitations();
- result.populate(response);
- return result;
- }
-
- private void populate(Response response) {
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONObject o = json.isObject();
- if (o != null)
- invitationsLeft = unmarshallInt(o, "invitations");
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-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.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-/**
- * A dialog box that displays info about invitations
- */
-public class InvitationsDialog extends DialogBox {
-
- private final String WIDTH_FIELD = "35em";
- private final String WIDTH_TEXT = "42em";
-
- Pithos app;
- TextBox name;
- TextBox emailBox;
-
- /**
- * The widget constructor.
- */
- public InvitationsDialog(Pithos _app, Invitations inv) {
- this.app = _app;
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- // Set the dialog's caption.
- setText("Invite people (" + inv.getInvitationsLeft() + " invitations left)");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
- VerticalPanel outer = new VerticalPanel();
- outer.add(close);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("You have " + inv.getInvitationsLeft() + " invitations left in your account.");
- text.setStyleName("pithos-credentialsText");
- text.setWidth(WIDTH_TEXT);
- inner.add(text);
- FlexTable table = new FlexTable();
- if (inv.getInvitationsLeft() > 0) {
- table.setText(0, 0, "Name");
- table.setText(1, 0, "E-mail");
- }
- name = new TextBox();
- name.setWidth(WIDTH_FIELD);
- name.setVisible(inv.getInvitationsLeft() > 0);
- table.setWidget(0, 1, name);
-
- emailBox = new TextBox();
- emailBox.setWidth(WIDTH_FIELD);
- emailBox.setVisible(inv.getInvitationsLeft() > 0);
- table.setWidget(1, 1, emailBox);
-
- table.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(0, 1, "props-values");
- table.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(1, 1, "props-values");
- inner.add(table);
-
- Button confirm = new Button("Send", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- sendInvitation();
- }
- });
- confirm.addStyleName("button");
- confirm.setVisible(inv.getInvitationsLeft() > 0);
- inner.add(confirm);
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when
- // either enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- sendInvitation();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
- void sendInvitation() {
- PostRequest sendInvitation = new PostRequest("/im/", "", "invite", "uniq=" + emailBox.getText().trim() + "&realname=" + name.getText().trim()) {
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
-
- @Override
- public void onSuccess(Resource result) {
- app.displayInformation("Invitation sent");
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- }
- };
- sendInvitation.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(sendInvitation);
- hide();
- }
-}
+++ /dev/null
-/*\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.animation.FadeIn;\r
-import gr.grnet.pithos.web.client.animation.FadeOut;\r
-\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.resources.client.ClientBundle;\r
-import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.DOM;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.Composite;\r
-import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HasVerticalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.SimplePanel;\r
-\r
-/**\r
- * A panel that displays various system messages.\r
- */\r
-public class MessagePanel extends Composite {\r
- /**\r
- * An image bundle for this widget's images.\r
- */\r
- public interface Images extends ClientBundle {\r
- @Source("gr/grnet/pithos/resources/messagebox_info.png")\r
- ImageResource info();\r
-\r
- @Source("gr/grnet/pithos/resources/messagebox_warning.png")\r
- ImageResource warn();\r
-\r
- @Source("gr/grnet/pithos/resources/messagebox_critical.png")\r
- ImageResource error();\r
- }\r
-\r
- /**\r
- * The widget's images.\r
- */\r
- public static Images images;\r
-\r
- /**\r
- * The system message to be displayed.\r
- */\r
- private HTML message = new HTML(" ");\r
-\r
- /**\r
- * A link to clear the displayed message.\r
- */\r
- private HTML clearMessageLink = new HTML("<a class='pithos-clearMessage' href='javascript:;'>Clear</a>");\r
-\r
- /**\r
- * The panel that contains the messages.\r
- */\r
- private HorizontalPanel inner = new HorizontalPanel();\r
-\r
- /**\r
- * The panel that enables special effects for this widget.\r
- */\r
- protected SimplePanel simplePanel = new SimplePanel();\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- * @param newImages a bundle that provides the images for this widget\r
- */\r
- public MessagePanel(final Images newImages) {\r
- images = newImages;\r
- buildPanel();\r
- simplePanel.setStyleName("effectPanel");\r
- inner.setStyleName("effectPanel-inner");\r
- DOM.setStyleAttribute(simplePanel.getElement(), "zoom", "1");\r
- simplePanel.add(inner);\r
- initWidget(simplePanel);\r
- }\r
-\r
- /**\r
- * Build the panel that contains the icon, the message and the 'clear' link.\r
- */\r
- private void buildPanel() {\r
- inner.clear();\r
- inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\r
- inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);\r
-// inner.setSpacing(4);\r
- inner.add(message);\r
- inner.add(clearMessageLink);\r
- inner.setCellVerticalAlignment(message, HasVerticalAlignment.ALIGN_MIDDLE);\r
- clearMessageLink.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
- }\r
-\r
- /**\r
- * Display an error message.\r
- *\r
- * @param msg the message to display\r
- */\r
- public void displayError(final String msg) {\r
- GWT.log(msg, null);\r
- message = new HTML("<table class='pithos-errorMessage'><tr><td>" + AbstractImagePrototype.create(images.error()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
-\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
- buildPanel();\r
- setVisible(true);\r
- FadeIn anim = new FadeIn(simplePanel);\r
- anim.run(500);\r
- }\r
-\r
- /**\r
- * Display a warning message.\r
- *\r
- * @param msg the message to display\r
- */\r
- public void displayWarning(final String msg) {\r
- message = new HTML("<table class='pithos-warnMessage'><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
-\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
-\r
- buildPanel();\r
- setVisible(true);\r
- FadeIn anim = new FadeIn(simplePanel);\r
- anim.run(500);\r
- }\r
-\r
- /**\r
- * Display an informational message.\r
- *\r
- * @param msg the message to display\r
- */\r
- public void displayInformation(final String msg) {\r
- message = new HTML("<table class='pithos-infoMessage'><tr><td>" + AbstractImagePrototype.create(images.info()).getHTML() + "</td><td>" + msg + "</td></tr></table>");\r
- message.addClickHandler(new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- FadeOut anim = new FadeOut(simplePanel){\r
-\r
- @Override\r
- protected void onComplete() {\r
- super.onComplete();\r
- hideMessage();\r
- }\r
- };\r
- anim.run(500);\r
- }\r
- });\r
-\r
- buildPanel();\r
- setVisible(true);\r
- FadeIn anim = new FadeIn(simplePanel);\r
- anim.run(500);\r
- }\r
-\r
- /**\r
- * Clear the displayed message and hide the panel.\r
- */\r
- public void hideMessage() {\r
- inner.clear();\r
- message = new HTML(" ");\r
- this.setVisible(false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.user.client.ui.TextBox;
-
-import gr.grnet.pithos.web.client.grouptree.Group;
-
-import java.util.List;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class PermissionsAddDialog extends DialogBox {
-
- private TextBox userBox = new TextBox();
-
- private ListBox groupBox = new ListBox();
-
- private CheckBox read = new CheckBox();
-
- private CheckBox write = new CheckBox();
-
- private PermissionsList permList;
-
- boolean userAdd;
-
- private Pithos app;
-
- public PermissionsAddDialog(Pithos _app, List<Group> _groups, PermissionsList _permList, boolean _userAdd) {
- app = _app;
- userAdd = _userAdd;
- permList = _permList;
-
- Anchor close = new Anchor();
- close.addStyleName("close");
- close.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- setText("Add permission");
- setStyleName("pithos-DialogBox");
-
- final VerticalPanel panel = new VerticalPanel();
- panel.add(close);
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
-
- final FlexTable permTable = new FlexTable();
- permTable.setText(0, 0, "Users/Groups");
- permTable.setText(0, 1, "Read");
- permTable.setText(0, 2, "Write");
- permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
-
- if (userAdd) {
- permTable.setWidget(1, 0, userBox);
- }
- else {
- for (Group group : _groups)
- groupBox.addItem(group.getName(), group.getName());
- permTable.setWidget(1, 0, groupBox);
- }
-
- permTable.setWidget(1, 1, read);
- permTable.setWidget(1, 2, write);
-
- permTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
- permTable.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER);
- permTable.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_CENTER);
- inner.add(permTable);
-
- final Button ok = new Button("OK", new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- addPermission();
- hide();
- }
- });
-
- ok.addStyleName("button");
- inner.add(ok);
-
- panel.add(inner);
- panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
-
- setWidget(panel);
- }
-
- protected void addPermission() {
- String selected = null;
- if (userAdd) {
- selected = userBox.getText();
- } else {
- String groupName = groupBox.getValue(groupBox.getSelectedIndex());
- selected = app.getUsername() + ":" + groupName;
- }
- if (permList.getPermissions().get(selected) != null) {
- return;
- }
- boolean readValue = read.getValue();
- boolean writeValue = write.getValue();
-
- permList.addPermission(selected, readValue, writeValue);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
-
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- addPermission();
- hide();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
-
- @Override
- public void center() {
- super.center();
- if (userAdd)
- userBox.setFocus(true);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import gr.grnet.pithos.web.client.FilePropertiesDialog.Images;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-public class PermissionsList extends Composite {
-
- Map<String, Boolean[]> permissions = null;
-
- final Images images;
-
- final VerticalPanel permPanel = new VerticalPanel();
-
- final FlexTable permTable = new FlexTable();
-
- final String owner;
-
- protected boolean hasChanges = false;
-
- private boolean readonly = false;
-
- public PermissionsList(final Images theImages, Map<String, Boolean[]> thePermissions, String theOwner, boolean inheritsPermissions){
- images = theImages;
- owner = theOwner;
- permissions = new HashMap<String, Boolean[]>(thePermissions);
- readonly = inheritsPermissions;
- permTable.setText(0, 0, "Users/Groups");
- permTable.setText(0, 1, "Read");
- permTable.setText(0, 2, "Write");
- permTable.setText(0, 3, "");
- permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
- permPanel.add(permTable);
- permPanel.addStyleName("pithos-TabPanelBottom");
- initWidget(permPanel);
- updatePermissionTable();
- }
-
- public boolean hasChanges(){
- return hasChanges;
- }
-
- /**
- * Retrieve the permissions.
- *
- * @return the permissions
- */
- public Map<String, Boolean[]> getPermissions() {
- return permissions;
- }
-
- public void addPermission(String user, boolean read, boolean write){
- permissions.put(user, new Boolean[] {Boolean.valueOf(read), Boolean.valueOf(write)});
- hasChanges = true;
- updatePermissionTable();
- }
-
- /**
- * Shows the permission table
- *
- */
- void updatePermissionTable(){
- int i = 1;
- for (int j=1; j<permTable.getRowCount(); j++)
- permTable.removeRow(j);
- for(final String user : permissions.keySet()) {
- if (!user.contains(":")) //not a group
- permTable.setHTML(i, 0, "<span>" + AbstractImagePrototype.create(images.permUser()).getHTML() + " " + user + "</span>");
- else
- permTable.setHTML(i, 0, "<span>" + AbstractImagePrototype.create(images.permGroup()).getHTML() + " " + user.split(":")[1].trim() + "</span>");
- permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
-
- Boolean[] userPerms = permissions.get(user);
- Boolean readP = userPerms[0];
- Boolean writeP = userPerms[1];
-
- CheckBox read = new CheckBox();
- read.setValue(readP != null ? readP : false);
- permTable.setWidget(i, 1, read);
- permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
-
- CheckBox write = new CheckBox();
- write.setValue(writeP != null ? writeP : false);
- permTable.setWidget(i, 2, write);
- permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
-
- if (!readonly) {
- read.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
- Boolean[] ps = permissions.get(user);
- ps[0] = booleanValueChangeEvent.getValue();
- hasChanges = true;
- }
- });
- write.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
- Boolean[] ps = permissions.get(user);
- ps[1] = booleanValueChangeEvent.getValue();
- hasChanges = true;
- }
- });
- PushButton removeButton = new PushButton(AbstractImagePrototype.create(images.delete()).createImage(), new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- permissions.remove(user);
- updatePermissionTable();
- hasChanges = true;
- }
- });
- permTable.setWidget(i, 3, removeButton);
- permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
- }
- else {
- read.setEnabled(false);
- write.setEnabled(false);
- }
- i++;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.commands.UploadFileCommand;
-import gr.grnet.pithos.web.client.foldertree.AccountResource;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
-import gr.grnet.pithos.web.client.foldertree.FolderTreeViewModel;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeView;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeViewModel;
-import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeView;
-import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeViewModel;
-import gr.grnet.pithos.web.client.othersharedtree.OtherSharedTreeView;
-import gr.grnet.pithos.web.client.othersharedtree.OtherSharedTreeViewModel;
-import gr.grnet.pithos.web.client.rest.DeleteRequest;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.HeadRequest;
-import gr.grnet.pithos.web.client.rest.PutRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.tagtree.Tag;
-import gr.grnet.pithos.web.client.tagtree.TagTreeView;
-import gr.grnet.pithos.web.client.tagtree.TagTreeViewModel;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.logical.shared.ResizeEvent;
-import com.google.gwt.event.logical.shared.ResizeHandler;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONString;
-import com.google.gwt.json.client.JSONValue;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.HorizontalSplitPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SelectionChangeEvent.Handler;
-import com.google.gwt.view.client.SingleSelectionModel;
-
-/**
- * Entry point classes define <code>onModuleLoad()</code>.
- */
-public class Pithos implements EntryPoint, ResizeHandler {
-
- public static final String HOME_CONTAINER = "pithos";
-
- public static final String TRASH_CONTAINER = "trash";
-
- /**
- * Instantiate an application-level image bundle. This object will provide
- * programmatic access to all the images needed by widgets.
- */
- static Images images = (Images) GWT.create(Images.class);
-
- public String getUsername() {
- return username;
- }
-
- public void setAccount(AccountResource acct) {
- account = acct;
- }
-
- public AccountResource getAccount() {
- return account;
- }
-
- public void updateFolder(Folder f, boolean showfiles, Command callback) {
- folderTreeView.updateFolder(f, showfiles, callback);
- }
-
- public void updateGroupNode(Group group) {
- groupTreeView.updateGroupNode(group);
- }
-
- public void updateSharedFolder(Folder f, boolean showfiles) {
- mysharedTreeView.updateFolder(f, showfiles);
- }
-
- public void updateOtherSharedFolder(Folder f, boolean showfiles) {
- otherSharedTreeView.updateFolder(f, showfiles);
- }
-
- public List<Tag> getAllTags() {
- List<Tag> tagList = new ArrayList<Tag>();
- for (Folder f : account.getContainers()) {
- for (String t : f.getTags()) {
- tagList.add(new Tag(t));
- }
- }
- return tagList;
- }
-
- public MysharedTreeView getMySharedTreeView() {
- return mysharedTreeView;
- }
-
- /**
- * An aggregate image bundle that pulls together all the images for this
- * application into a single bundle.
- */
- public interface Images extends TopPanel.Images, FileList.Images, ToolsMenu.Images {
-
- @Source("gr/grnet/pithos/resources/document.png")
- ImageResource folders();
-
- @Source("gr/grnet/pithos/resources/advancedsettings.png")
- @ImageOptions(width=32, height=32)
- ImageResource tools();
- }
-
- /**
- * The Application Clipboard implementation;
- */
- private Clipboard clipboard = new Clipboard();
-
- /**
- * The top panel that contains the menu bar.
- */
- private TopPanel topPanel;
-
- /**
- * The panel that contains the various system messages.
- */
- private MessagePanel messagePanel = new MessagePanel(Pithos.images);
-
- /**
- * The bottom panel that contains the status bar.
- */
- private StatusPanel statusPanel = null;
-
- /**
- * The file list widget.
- */
- private FileList fileList;
-
- /**
- * The tab panel that occupies the right side of the screen.
- */
- private VerticalPanel inner = new VerticalPanel();
-
-
- /**
- * The split panel that will contain the left and right panels.
- */
- private HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
-
- /**
- * The currently selected item in the application, for use by the Edit menu
- * commands. Potential types are Folder, File, User and Group.
- */
- private Object currentSelection;
-
- public HashMap<String, String> userFullNameMap = new HashMap<String, String>();
-
- private String username = null;
-
- /**
- * The authentication token of the current user.
- */
- private String token;
-
- VerticalPanel trees;
-
- SingleSelectionModel<Folder> folderTreeSelectionModel;
- FolderTreeViewModel folderTreeViewModel;
- FolderTreeView folderTreeView;
-
- SingleSelectionModel<Folder> mysharedTreeSelectionModel;
- MysharedTreeViewModel mysharedTreeViewModel;
- MysharedTreeView mysharedTreeView = null;;
-
- protected SingleSelectionModel<Folder> otherSharedTreeSelectionModel;
- OtherSharedTreeViewModel otherSharedTreeViewModel;
- OtherSharedTreeView otherSharedTreeView = null;
-
- GroupTreeViewModel groupTreeViewModel;
- private GroupTreeView groupTreeView;
-
- private TreeView selectedTree;
- protected AccountResource account;
-
- Folder trash;
-
- List<Composite> treeViews = new ArrayList<Composite>();
-
- @SuppressWarnings("rawtypes") List<SingleSelectionModel> selectionModels = new ArrayList<SingleSelectionModel>();
-
- Button upload;
-
- private HTML usedBytes;
-
- private HTML totalBytes;
-
- private HTML usedPercent;
-
- private HTML numOfFiles;
-
- private Image toolsButton;
-
- @Override
- public void onModuleLoad() {
- if (parseUserCredentials())
- initialize();
- }
-
- private void initialize() {
- boolean bareContent = Window.Location.getParameter("noframe") != null;
- String contentWidth = bareContent ? "100%" : "75%";
-
- VerticalPanel outer = new VerticalPanel();
- outer.setWidth("100%");
- if (!bareContent) {
- outer.addStyleName("pithos-outer");
- }
-
- if (!bareContent) {
- topPanel = new TopPanel(this, Pithos.images);
- topPanel.setWidth("100%");
- outer.add(topPanel);
- outer.setCellHorizontalAlignment(topPanel, HasHorizontalAlignment.ALIGN_CENTER);
- }
-
- HorizontalPanel header = new HorizontalPanel();
- header.addStyleName("pithos-header");
- header.setWidth(contentWidth);
- if (bareContent)
- header.addStyleName("pithos-header-noframe");
- upload = new Button("Upload File", new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- new UploadFileCommand(Pithos.this, null, getSelection()).execute();
- }
- });
- upload.addStyleName("pithos-uploadButton");
- header.add(upload);
- header.setCellHorizontalAlignment(upload, HasHorizontalAlignment.ALIGN_LEFT);
- header.setCellVerticalAlignment(upload, HasVerticalAlignment.ALIGN_MIDDLE);
-// header.setCellWidth(upload, "146px");
-
- messagePanel.setVisible(false);
- header.add(messagePanel);
- header.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
- header.setCellVerticalAlignment(messagePanel, HasVerticalAlignment.ALIGN_MIDDLE);
-
- toolsButton = new Image(images.tools());
- toolsButton.addStyleName("pithos-toolsButton");
- toolsButton.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- ToolsMenu menu = new ToolsMenu(Pithos.this, images, getSelectedTree(), getSelectedTree().getSelection(), getFileList().getSelectedFiles());
- if (!menu.isEmpty()) {
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- });
- header.add(toolsButton);
- header.setCellHorizontalAlignment(toolsButton, HasHorizontalAlignment.ALIGN_CENTER);
- header.setCellVerticalAlignment(toolsButton, HasVerticalAlignment.ALIGN_MIDDLE);
- header.setCellWidth(toolsButton, "40px");
-
- HorizontalPanel folderStatistics = new HorizontalPanel();
- folderStatistics.addStyleName("pithos-folderStatistics");
- numOfFiles = new HTML();
- folderStatistics.add(numOfFiles);
- folderStatistics.setCellVerticalAlignment(numOfFiles, HasVerticalAlignment.ALIGN_MIDDLE);
- HTML numOfFilesLabel = new HTML(" Files");
- folderStatistics.add(numOfFilesLabel);
- folderStatistics.setCellVerticalAlignment(numOfFilesLabel, HasVerticalAlignment.ALIGN_MIDDLE);
- header.add(folderStatistics);
- header.setCellHorizontalAlignment(folderStatistics, HasHorizontalAlignment.ALIGN_RIGHT);
- header.setCellVerticalAlignment(folderStatistics, HasVerticalAlignment.ALIGN_MIDDLE);
- header.setCellWidth(folderStatistics, "40px");
- outer.add(header);
- outer.setCellHorizontalAlignment(header, HasHorizontalAlignment.ALIGN_CENTER);
- // Inner contains the various lists.nner
- inner.sinkEvents(Event.ONCONTEXTMENU);
- inner.setWidth("100%");
-
- folderTreeSelectionModel = new SingleSelectionModel<Folder>();
- folderTreeSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (folderTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(folderTreeView, folderTreeSelectionModel);
- applyPermissions(folderTreeSelectionModel.getSelectedObject());
- Folder f = folderTreeSelectionModel.getSelectedObject();
- showFiles(f);
- }
- }
- });
- selectionModels.add(folderTreeSelectionModel);
-
- folderTreeViewModel = new FolderTreeViewModel(this, folderTreeSelectionModel);
- folderTreeView = new FolderTreeView(folderTreeViewModel);
- treeViews.add(folderTreeView);
-
- fileList = new FileList(this, images, folderTreeView);
- inner.add(fileList);
-
- groupTreeViewModel = new GroupTreeViewModel(this);
- groupTreeView = new GroupTreeView(groupTreeViewModel);
- treeViews.add(groupTreeView);
-
- trees = new VerticalPanel();
- trees.setWidth("100%");
-
-
- HorizontalPanel treeHeader = new HorizontalPanel();
- treeHeader.addStyleName("pithos-treeHeader");
- treeHeader.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- treeHeader.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- HorizontalPanel statistics = new HorizontalPanel();
- statistics.addStyleName("pithos-statistics");
- statistics.add(new HTML("Used: "));
- usedBytes = new HTML();
- statistics.add(usedBytes);
- statistics.add(new HTML(" of "));
- totalBytes = new HTML();
- statistics.add(totalBytes);
- statistics.add(new HTML(" ("));
- usedPercent = new HTML();
- statistics.add(usedPercent);
- statistics.add(new HTML(")"));
- treeHeader.add(statistics);
- treeHeader.setCellHorizontalAlignment(statistics, HasHorizontalAlignment.ALIGN_LEFT);
- trees.add(treeHeader);
-
- trees.add(folderTreeView);
- trees.add(groupTreeView);
- // Add the left and right panels to the split panel.
- splitPanel.setLeftWidget(trees);
- splitPanel.setRightWidget(inner);
- splitPanel.setSplitPosition("35%");
- splitPanel.setSize("100%", "100%");
- splitPanel.addStyleName("pithos-splitPanel");
- splitPanel.setWidth(contentWidth);
- outer.add(splitPanel);
- outer.setCellHorizontalAlignment(splitPanel, HasHorizontalAlignment.ALIGN_CENTER);
-
- if (!bareContent) {
- statusPanel = new StatusPanel();
- statusPanel.setWidth("100%");
- outer.add(statusPanel);
- outer.setCellHorizontalAlignment(statusPanel, HasHorizontalAlignment.ALIGN_CENTER);
- }
- else
- splitPanel.addStyleName("pithos-splitPanel-noframe");
-
- // Hook the window resize event, so that we can adjust the UI.
- Window.addResizeHandler(this);
- // Clear out the window's built-in margin, because we want to take
- // advantage of the entire client area.
- Window.setMargin("0px");
- // Finally, add the outer panel to the RootPanel, so that it will be
- // displayed.
- RootPanel.get().add(outer);
- // Call the window resized handler to get the initial sizes setup. Doing
- // this in a deferred command causes it to occur after all widgets'
- // sizes have been computed by the browser.
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- onWindowResized(Window.getClientHeight());
- }
- });
-
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- fetchAccount(new Command() {
-
- @Override
- public void execute() {
- if (!account.hasHomeContainer())
- createHomeContainer(account, this);
- else if (!account.hasTrashContainer())
- createTrashContainer(this);
- else {
- for (Folder f : account.getContainers())
- if (f.getName().equals(Pithos.TRASH_CONTAINER)) {
- trash = f;
- break;
- }
- folderTreeViewModel.initialize(account, new Command() {
-
- @Override
- public void execute() {
- createMySharedTree();
- }
- });
- groupTreeViewModel.initialize();
- showStatistics();
- }
- }
- });
- }
- });
-
-// Scheduler.get().scheduleDeferred(new Command() {
-//
-// @Override
-// public void execute() {
-// displayError("lalala");
-//
-// }
-// });
- }
-
- public void applyPermissions(Folder f) {
- if (f != null) {
- if (f.isInTrash())
- upload.setEnabled(false);
- else {
- Boolean[] perms = f.getPermissions().get(username);
- if (f.getOwner().equals(username) || (perms != null && perms[1] != null && perms[1])) {
- upload.setEnabled(true);
- }
- else
- upload.setEnabled(false);
- }
- }
- else
- upload.setEnabled(false);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void deselectOthers(TreeView _selectedTree, SingleSelectionModel model) {
- selectedTree = _selectedTree;
-
- for (Composite c : treeViews)
- if (c.equals(selectedTree))
- c.addStyleName("cellTreeWidget-selectedTree");
- else
- c.removeStyleName("cellTreeWidget-selectedTree");
-
- for (SingleSelectionModel s : selectionModels)
- if (!s.equals(model))
- s.setSelected(s.getSelectedObject(), false);
- }
-
- public void showFiles(Folder f) {
- Set<File> files = f.getFiles();
- showFiles(files);
- }
-
- public void showFiles(Set<File> files) {
- //Iterator<File> iter = files.iterator();
- //fetchFile(iter, files);
- fileList.setFiles(new ArrayList<File>(files));
- }
-
- protected void fetchFile(final Iterator<File> iter, final Set<File> files) {
- if (iter.hasNext()) {
- File file = iter.next();
- String path = file.getUri() + "?format=json";
- GetRequest<File> getFile = new GetRequest<File>(File.class, getApiPath(), username, path, file) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") File _result) {
- fetchFile(iter, files);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting file", t);
- if (t instanceof RestException)
- displayError("Error getting file: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error fetching file: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- getFile.setHeader("X-Auth-Token", "0000");
- Scheduler.get().scheduleDeferred(getFile);
- }
- else
- fileList.setFiles(new ArrayList<File>(files));
- }
-
- /**
- * Parse and store the user credentials to the appropriate fields.
- */
- private boolean parseUserCredentials() {
- username = Window.Location.getParameter("user");
- token = Window.Location.getParameter("token");
- Configuration conf = (Configuration) GWT.create(Configuration.class);
- if (username == null || username.length() == 0 || token == null || token.length() == 0) {
- String cookie = conf.authCookie();
- String auth = Cookies.getCookie(cookie);
- if (auth == null) {
- authenticateUser();
- return false;
- }
- if (auth.startsWith("\""))
- auth = auth.substring(1);
- if (auth.endsWith("\""))
- auth = auth.substring(0, auth.length() - 1);
- String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2);
- if (authSplit.length != 2) {
- authenticateUser();
- return false;
- }
- username = authSplit[0];
- token = authSplit[1];
- return true;
- }
-
- Cookies.setCookie(conf.authCookie(), username + conf.cookieSeparator() + token, null, "", "/", false);
- return true;
- }
-
- /**
- * Redirect the user to the login page for authentication.
- */
- protected void authenticateUser() {
- Configuration conf = (Configuration) GWT.create(Configuration.class);
- Window.Location.assign(conf.loginUrl() + "?next=" + Window.Location.getHref());
- }
-
- protected void fetchAccount(final Command callback) {
- String path = "?format=json";
-
- GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, getApiPath(), username, path) {
- @Override
- public void onSuccess(AccountResource _result) {
- account = _result;
- if (callback != null)
- callback.execute();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting account", t);
- if (t instanceof RestException)
- displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error fetching user data: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- getAccount.setHeader("X-Auth-Token", token);
- Scheduler.get().scheduleDeferred(getAccount);
- }
-
- public void updateStatistics() {
- HeadRequest<AccountResource> headAccount = new HeadRequest<AccountResource>(AccountResource.class, getApiPath(), username, "", account) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") AccountResource _result) {
- showStatistics();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting account", t);
- if (t instanceof RestException)
- displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error fetching user data: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- headAccount.setHeader("X-Auth-Token", token);
- Scheduler.get().scheduleDeferred(headAccount);
- }
-
- protected void showStatistics() {
- usedBytes.setHTML(String.valueOf(account.getFileSizeAsString()));
- totalBytes.setHTML(String.valueOf(account.getQuotaAsString()));
- NumberFormat nf = NumberFormat.getPercentFormat();
- usedPercent.setHTML(nf.format(account.getUsedPercentage()));
- }
-
- protected void createHomeContainer(final AccountResource _account, final Command callback) {
- String path = "/" + Pithos.HOME_CONTAINER;
- PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- if (!_account.hasTrashContainer())
- createTrashContainer(callback);
- else
- fetchAccount(callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error creating pithos", t);
- if (t instanceof RestException)
- displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error Error creating pithos: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- createPithos.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(createPithos);
- }
-
- protected void createTrashContainer(final Command callback) {
- String path = "/" + Pithos.TRASH_CONTAINER;
- PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- fetchAccount(callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error creating pithos", t);
- if (t instanceof RestException)
- displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error Error creating pithos: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- createPithos.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(createPithos);
- }
-
- /**
- * Creates an HTML fragment that places an image & caption together, for use
- * in a group header.
- *
- * @param imageProto an image prototype for an image
- * @param caption the group caption
- * @return the header HTML fragment
- */
- private String createHeaderHTML(AbstractImagePrototype imageProto, String caption) {
- String captionHTML = "<table class='caption' cellpadding='0' "
- + "cellspacing='0'>" + "<tr><td class='lcaption'>" + imageProto.getHTML()
- + "</td><td id =" + caption +" class='rcaption'><b style='white-space:nowrap'> "
- + caption + "</b></td></tr></table>";
- return captionHTML;
- }
-
- protected void onWindowResized(int height) {
- // Adjust the split panel to take up the available room in the window.
- int newHeight = height - splitPanel.getAbsoluteTop();
- if (newHeight < 1)
- newHeight = 1;
- splitPanel.setHeight("" + newHeight);
- inner.setHeight("" + newHeight);
- }
-
- @Override
- public void onResize(ResizeEvent event) {
- int height = event.getHeight();
- onWindowResized(height);
- }
-
- /**
- * Display an error message.
- *
- * @param msg the message to display
- */
- public void displayError(String msg) {
- messagePanel.displayError(msg);
- }
-
- /**
- * Display a warning message.
- *
- * @param msg the message to display
- */
- public void displayWarning(String msg) {
- messagePanel.displayWarning(msg);
- }
-
- /**
- * Display an informational message.
- *
- * @param msg the message to display
- */
- public void displayInformation(String msg) {
- messagePanel.displayInformation(msg);
- }
-
- /**
- * Retrieve the fileList.
- *
- * @return the fileList
- */
- public FileList getFileList() {
- return fileList;
- }
-
- /**
- * Retrieve the topPanel.
- *
- * @return the topPanel
- */
- TopPanel getTopPanel() {
- return topPanel;
- }
-
- /**
- * Retrieve the clipboard.
- *
- * @return the clipboard
- */
- public Clipboard getClipboard() {
- return clipboard;
- }
-
- public StatusPanel getStatusPanel() {
- return statusPanel;
- }
-
- public String getToken() {
- return token;
- }
-
- public static native void preventIESelection() /*-{
- $doc.body.onselectstart = function () { return false; };
- }-*/;
-
- public static native void enableIESelection() /*-{
- if ($doc.body.onselectstart != null)
- $doc.body.onselectstart = null;
- }-*/;
-
- /**
- * @return the absolute path of the API root URL
- */
- public String getApiPath() {
- Configuration conf = (Configuration) GWT.create(Configuration.class);
- return conf.apiPath();
- }
-
- /**
- * History support for folder navigation
- * adds a new browser history entry
- *
- * @param key
- */
- public void updateHistory(String key){
-// Replace any whitespace of the initial string to "+"
-// String result = key.replaceAll("\\s","+");
-// Add a new browser history entry.
-// History.newItem(result);
- History.newItem(key);
- }
-
- public void deleteFolder(final Folder folder) {
- String path = getApiPath() + folder.getOwner() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(folder.getPrefix()) + "&t=" + System.currentTimeMillis();
- RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
- builder.setHeader("X-Auth-Token", getToken());
- try {
- builder.sendRequest("", new RequestCallback() {
- @Override
- public void onResponseReceived(@SuppressWarnings("unused") Request request, Response response) {
- if (response.getStatusCode() == Response.SC_OK) {
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array = json.isArray();
- int i = 0;
- if (array != null) {
- deleteObject(folder, i, array);
- }
- }
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable exception) {
- displayError("System error unable to delete folder: " + exception.getMessage());
- }
- });
- }
- catch (RequestException e) {
- }
- }
-
- void deleteObject(final Folder folder, final int i, final JSONArray array) {
- if (i < array.size()) {
- JSONObject o = array.get(i).isObject();
- if (o != null && !o.containsKey("subdir")) {
- JSONString name = o.get("name").isString();
- String path = "/" + folder.getContainer() + "/" + name.stringValue();
- DeleteRequest delete = new DeleteRequest(getApiPath(), folder.getOwner(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- deleteObject(folder, i + 1, array);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- displayError("System error unable to delete folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- delete.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(delete);
- }
- else if (o != null) {
- String subdir = o.get("subdir").isString().stringValue();
- subdir = subdir.substring(0, subdir.length() - 1);
- String path = getApiPath() + getUsername() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(subdir) + "&t=" + System.currentTimeMillis();
- RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
- builder.setHeader("X-Auth-Token", getToken());
- try {
- builder.sendRequest("", new RequestCallback() {
- @Override
- public void onResponseReceived(@SuppressWarnings("unused") Request request, Response response) {
- if (response.getStatusCode() == Response.SC_OK) {
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array2 = json.isArray();
- if (array2 != null) {
- int l = array.size();
- for (int j=0; j<array2.size(); j++) {
- array.set(l++, array2.get(j));
- }
- }
- deleteObject(folder, i + 1, array);
- }
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable exception) {
- displayError("System error unable to delete folder: " + exception.getMessage());
- }
- });
- }
- catch (RequestException e) {
- }
- }
- }
- else {
- String path = folder.getUri();
- DeleteRequest deleteFolder = new DeleteRequest(getApiPath(), getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- updateFolder(folder.getParent(), true, new Command() {
-
- @Override
- public void execute() {
- updateStatistics();
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- if (((RestException) t).getHttpStatusCode() != Response.SC_NOT_FOUND)
- displayError("Unable to delete folder: "+((RestException) t).getHttpStatusText());
- else
- onSuccess(null);
- }
- else
- displayError("System error unable to delete folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- deleteFolder.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(deleteFolder);
- }
- }
-
- public FolderTreeView getFolderTreeView() {
- return folderTreeView;
- }
-
- public void copyFiles(final Iterator<File> iter, final String targetUsername, final String targetUri, final Command callback) {
- if (iter.hasNext()) {
- File file = iter.next();
- String path = targetUri + "/" + file.getName();
- PutRequest copyFile = new PutRequest(getApiPath(), targetUsername, path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- copyFiles(iter, targetUsername, targetUri, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
- }
- else
- displayError("System error unable to copy file: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- copyFile.setHeader("X-Auth-Token", getToken());
- copyFile.setHeader("X-Copy-From", file.getUri());
- if (!file.getOwner().equals(targetUsername))
- copyFile.setHeader("X-Source-Account", file.getOwner());
- copyFile.setHeader("Content-Type", file.getContentType());
- Scheduler.get().scheduleDeferred(copyFile);
- }
- else if (callback != null) {
- callback.execute();
- }
- }
-
- public void copySubfolders(final Iterator<Folder> iter, final String targetUsername, final String targetUri, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
- copyFolder(f, targetUsername, targetUri, new Command() {
-
- @Override
- public void execute() {
- copySubfolders(iter, targetUsername, targetUri, callback);
- }
- });
- }
- else if (callback != null) {
- callback.execute();
- }
- }
-
- public void copyFolder(final Folder f, final String targetUsername, final String targetUri, final Command callback) {
- String path = targetUri + "/" + f.getName();
- PutRequest createFolder = new PutRequest(getApiPath(), targetUsername, path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
-
- @Override
- public void onSuccess(final Folder _f) {
- Iterator<File> iter = _f.getFiles().iterator();
- copyFiles(iter, targetUsername, targetUri + "/" + _f.getName(), new Command() {
- @Override
- public void execute() {
- Iterator<Folder> iterf = _f.getSubfolders().iterator();
- copySubfolders(iterf, targetUsername, targetUri + "/" + _f.getName(), callback);
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- displayError("System error getting folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- displayError("Unable to create folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- displayError("System error creating folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- createFolder.setHeader("X-Auth-Token", getToken());
- createFolder.setHeader("Accept", "*/*");
- createFolder.setHeader("Content-Length", "0");
- createFolder.setHeader("Content-Type", "application/folder");
- Scheduler.get().scheduleDeferred(createFolder);
- }
-
- public void addSelectionModel(@SuppressWarnings("rawtypes") SingleSelectionModel model) {
- selectionModels.add(model);
- }
-
- public OtherSharedTreeView getOtherSharedTreeView() {
- return otherSharedTreeView;
- }
-
- public void updateTrash(boolean showFiles, Command callback) {
- updateFolder(trash, showFiles, callback);
- }
-
- public void updateGroupsNode() {
- groupTreeView.updateGroupNode(null);
- }
-
- public void addGroup(String groupname) {
- Group newGroup = new Group(groupname);
- account.addGroup(newGroup);
- groupTreeView.updateGroupNode(null);
- }
-
- public void removeGroup(Group group) {
- account.removeGroup(group);
- updateGroupsNode();
- }
-
- public TreeView getSelectedTree() {
- return selectedTree;
- }
-
- public Folder getSelection() {
- return selectedTree.getSelection();
- }
-
- public void showFolderStatistics(int folderFileCount) {
- numOfFiles.setHTML(String.valueOf(folderFileCount));
- }
-
- public GroupTreeView getGroupTreeView() {
- return groupTreeView;
- }
-
- public void sessionExpired() {
- new SessionExpiredDialog(this).center();
- }
-
- public void updateRootFolder(Command callback) {
- updateFolder(account.getPithos(), false, callback);
- }
-
- void createMySharedTree() {
- mysharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (mysharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(mysharedTreeView, mysharedTreeSelectionModel);
- upload.setEnabled(false);
- updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true);
- }
- }
- });
- selectionModels.add(mysharedTreeSelectionModel);
- mysharedTreeViewModel = new MysharedTreeViewModel(Pithos.this, mysharedTreeSelectionModel);
- mysharedTreeViewModel.initialize(new Command() {
-
- @Override
- public void execute() {
- mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
- trees.insert(mysharedTreeView, 2);
- treeViews.add(mysharedTreeView);
- createOtherSharedTree();
- }
- });
- }
-
- void createOtherSharedTree() {
- otherSharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (otherSharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
- otherSharedTreeView.addStyleName("cellTreeWidget-selectedTree");
- applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
- updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true);
- }
- }
- });
- selectionModels.add(otherSharedTreeSelectionModel);
- otherSharedTreeViewModel = new OtherSharedTreeViewModel(Pithos.this, otherSharedTreeSelectionModel);
- otherSharedTreeViewModel.initialize(new Command() {
-
- @Override
- public void execute() {
- otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
- trees.insert(otherSharedTreeView, 3);
- treeViews.add(otherSharedTreeView);
- }
- });
- }
-
- public void logoff() {
- Configuration conf = (Configuration) GWT.create(Configuration.class);
- Cookies.removeCookie(conf.authCookie(), "/");
- Cookies.removeCookie(conf.authTokenCookie(), "/");
- for (String s: Cookies.getCookieNames())
- if (s.startsWith(conf.shibSessionCookiePrefix()))
- Cookies.removeCookie(s, "/");
- Window.Location.assign(Window.Location.getPath());
- }
-}
+++ /dev/null
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-/* Incremental changes from CellTable.css */
-.cellTableFooter {
- padding: 3px 9px;
-}
-
-.cellTableHeader {
- border:none;
- cursor: pointer;
- color: white;
- background-color: #74aec9;
- height: 25px;
- text-shadow: none;
- font-size: small;
- font-weight: normal;
-}
-
-.cellTableCell {
- padding: 4px 9px;
- border-width: 0;
-}
-
-.cellTableFirstColumn {
- padding: 0px;
- padding-left: 5px;
-}
-
-.cellTableLastColumn {
- padding: 0px;
-}
-
-.cellTableFirstColumnFooter {
- border: 0px;
- padding: 0px;
-}
-
-.cellTableFirstColumnHeader {
- border: 0px;
- padding: 0px;
-}
-
-.cellTableLastColumnFooter {
- border: 0px;
- padding: 0px;
-}
-
-.cellTableLastColumnHeader {
- border: 0px;
- padding: 0px;
-}
-
-.cellTableEvenRow {
- cursor: hand;
- cursor: pointer;
- background: none;
-}
-
-.cellTableOddRow {
- cursor: hand;
- cursor: pointer;
- background: none;
-}
-
-.cellTableSelectedRow {
- color: #d45500;
- height: auto;
- overflow: auto;
-}
-
-.cellTableHoveredRow {
- background: none;
- background-color: #A1C8DB;
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-.cellTreeWidget {
-}
-
-.cellTreeEmptyMessage {
- padding-left: 16px;
- font-style: italic;
- background: url(images/cellTreeLoadingBasic.gif) no-repeat;
- color: #4085A5;
-}
-
-.cellTreeItem {
- padding-top: 4px;
- padding-bottom: 4px;
- cursor: hand;
- cursor: pointer;
- zoom: 1;
-}
-
-.cellTreeItemImage {
- padding-top: 5px;
-}
-
-.cellTreeItemImageValue {
- zoom: 1;
-}
-
-.cellTreeItemValue {
- padding-left: 3px;
- padding-right: 3px;
- outline: none;
-}
-
-.cellTreeItemValue img {
- vertical-align: middle;
-}
-
-.cellTreeItem:HOVER {
- background-color: #A1C8DA;
-}
-
-.cellTreeOpenItem {
-}
-
-.cellTreeTopItem {
-
-}
-
-.cellTreeTopItemImage {
-
-}
-
-.cellTreeTopItemImageValue {
-
-}
-
-.cellTreeKeyboardSelectedItem {
- outline: none;
-}
-
-.cellTreeSelectedItem {
- color: #d45500;
- background-color: #BCD7E3;
- height: auto;
- overflow: visible;
-}
-
-.cellTreeShowMoreButton {
- padding-left: 16px;
- outline: none;
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.InputElement;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.view.client.CellPreviewEvent;
-import com.google.gwt.view.client.HasData;
-import com.google.gwt.view.client.MultiSelectionModel;
-import com.google.gwt.view.client.Range;
-import com.google.gwt.view.client.SelectionModel;
-
-/**
- * An implementation of {@link com.google.gwt.view.client.CellPreviewEvent.Handler} that adds selection
- * support via the spacebar and mouse clicks and handles the control key.
- *
- * <p>
- * If the {@link HasData} source of the selection event uses a
- * {@link MultiSelectionModel}, this manager additionally provides support for
- * shift key to select a range of values. For all other {@link SelectionModel}s,
- * only the control key is supported.
- * </p>
- *
- * @param <T> the data type of records in the list
- */
-public class PithosSelectionEventManager<T> implements
- CellPreviewEvent.Handler<T> {
-
- /**
- * Implementation of {@link gr.grnet.pithos.web.client.PithosSelectionEventManager.EventTranslator} that only triggers selection when
- * any checkbox is selected.
- *
- * @param <T> the data type
- */
- public static class CheckboxEventTranslator<T> implements EventTranslator<T> {
-
- /**
- * The column index of the checkbox. Other columns are ignored.
- */
- private final int column;
-
- /**
- * Construct a new {@link gr.grnet.pithos.web.client.PithosSelectionEventManager.CheckboxEventTranslator} that will trigger
- * selection when any checkbox in any column is selected.
- */
- public CheckboxEventTranslator() {
- this(-1);
- }
-
- /**
- * Construct a new {@link gr.grnet.pithos.web.client.PithosSelectionEventManager.CheckboxEventTranslator} that will trigger
- * selection when a checkbox in the specified column is selected.
- *
- * @param column the column index, or -1 for all columns
- */
- public CheckboxEventTranslator(int column) {
- this.column = column;
- }
-
- @Override
- public boolean clearCurrentSelection(@SuppressWarnings("unused") CellPreviewEvent<T> event) {
- return false;
- }
-
- @Override
- public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
- // Handle the event.
- NativeEvent nativeEvent = event.getNativeEvent();
- if ("click".equals(nativeEvent.getType())) {
- // Ignore if the event didn't occur in the correct column.
- if (column > -1 && column != event.getColumn()) {
- return SelectAction.IGNORE;
- }
-
- // Determine if we clicked on a checkbox.
- Element target = nativeEvent.getEventTarget().cast();
- if ("input".equals(target.getTagName().toLowerCase())) {
- final InputElement input = target.cast();
- if ("checkbox".equals(input.getType().toLowerCase())) {
- // Synchronize the checkbox with the current selection state.
- input.setChecked(event.getDisplay().getSelectionModel().isSelected(
- event.getValue()));
- return SelectAction.TOGGLE;
- }
- }
- return SelectAction.IGNORE;
- }
-
- // For keyboard events, do the default action.
- return SelectAction.DEFAULT;
- }
- }
-
- /**
- * Translates {@link CellPreviewEvent}s into {@link SelectAction}s.
- */
- public static interface EventTranslator<T> {
- /**
- * Check whether a user selection event should clear all currently selected
- * values.
- *
- * @param event the {@link CellPreviewEvent} to translate
- */
- boolean clearCurrentSelection(CellPreviewEvent<T> event);
-
- /**
- * Translate the user selection event into a {@link SelectAction}.
- *
- * @param event the {@link CellPreviewEvent} to translate
- */
- SelectAction translateSelectionEvent(CellPreviewEvent<T> event);
- }
-
- /**
- * The action that controls how selection is handled.
- */
- public static enum SelectAction {
- DEFAULT, // Perform the default action.
- SELECT, // Select the value.
- DESELECT, // Deselect the value.
- TOGGLE, // Toggle the selected state of the value.
- IGNORE; // Ignore the event.
- }
-
- /**
- * Construct a new {@link PithosSelectionEventManager} that triggers
- * selection when any checkbox in any column is clicked.
- *
- * @param <T> the data type of the display
- * @return a {@link PithosSelectionEventManager} instance
- */
- public static <T> PithosSelectionEventManager<T> createCheckboxManager() {
- return new PithosSelectionEventManager<T>(new CheckboxEventTranslator<T>());
- }
-
- /**
- * Construct a new {@link PithosSelectionEventManager} that triggers
- * selection when a checkbox in the specified column is clicked.
- *
- * @param <T> the data type of the display
- * @param column the column to handle
- * @return a {@link PithosSelectionEventManager} instance
- */
- public static <T> PithosSelectionEventManager<T> createCheckboxManager(
- int column) {
- return new PithosSelectionEventManager<T>(new CheckboxEventTranslator<T>(
- column));
- }
-
- /**
- * Create a new {@link PithosSelectionEventManager} using the specified
- * {@link EventTranslator} to control which {@link SelectAction} to take for
- * each event.
- *
- * @param <T> the data type of the display
- * @param translator the {@link EventTranslator} to use
- * @return a {@link PithosSelectionEventManager} instance
- */
- public static <T> PithosSelectionEventManager<T> createCustomManager(
- EventTranslator<T> translator) {
- return new PithosSelectionEventManager<T>(translator);
- }
-
- /**
- * Create a new {@link PithosSelectionEventManager} that handles selection
- * via user interactions.
- *
- * @param <T> the data type of the display
- * @return a new {@link PithosSelectionEventManager} instance
- */
- public static <T> PithosSelectionEventManager<T> createDefaultManager() {
- return new PithosSelectionEventManager<T>(null);
- }
-
- /**
- * The last {@link HasData} that was handled.
- */
- private HasData<T> lastDisplay;
-
- /**
- * The last page start.
- */
- private int lastPageStart;
-
- /**
- * The last selected row index.
- */
- private int lastSelectedIndex = -1;
-
- /**
- * A boolean indicating that the last shift selection was additive.
- */
- private boolean shiftAdditive;
-
- /**
- * The last place where the user clicked without holding shift. Multi
- * selections that use the shift key are rooted at the anchor.
- */
- private int shiftAnchor = -1;
-
- /**
- * The {@link EventTranslator} that controls how selection is handled.
- */
- private final EventTranslator<T> translator;
-
- /**
- * Construct a new {@link PithosSelectionEventManager} using the specified
- * {@link EventTranslator} to control which {@link SelectAction} to take for
- * each event.
- *
- * @param translator the {@link EventTranslator} to use
- */
- protected PithosSelectionEventManager(EventTranslator<T> translator) {
- this.translator = translator;
- }
-
- /**
- * Update the selection model based on a user selection event.
- *
- * @param selectionModel the selection model to update
- * @param row the selected row index relative to the page start
- * @param rowValue the selected row value
- * @param action the {@link SelectAction} to apply
- * @param selectRange true to select the range from the last selected row
- * @param clearOthers true to clear the current selection
- */
- public void doMultiSelection(MultiSelectionModel<? super T> selectionModel,
- HasData<T> display, int row, T rowValue, SelectAction action,
- boolean selectRange, boolean clearOthers) {
- // Determine if we will add or remove selection.
- boolean addToSelection = true;
- if (action != null) {
- switch (action) {
- case IGNORE:
- // Ignore selection.
- return;
- case SELECT:
- addToSelection = true;
- break;
- case DESELECT:
- addToSelection = false;
- break;
- case TOGGLE:
- addToSelection = !selectionModel.isSelected(rowValue);
- break;
- case DEFAULT:
- break;
- }
- }
-
- // Determine which rows will be newly selected.
- int pageStart = display.getVisibleRange().getStart();
- if (selectRange && pageStart == lastPageStart && lastSelectedIndex > -1
- && shiftAnchor > -1 && display == lastDisplay) {
- /*
- * Get the new shift bounds based on the existing shift anchor and the
- * selected row.
- */
- int start = Math.min(shiftAnchor, row); // Inclusive.
- int end = Math.max(shiftAnchor, row); // Inclusive.
-
- if (lastSelectedIndex < start) {
- // Revert previous selection if the user reselects a smaller range.
- setRangeSelection(selectionModel, display, new Range(lastSelectedIndex,
- start - lastSelectedIndex), !shiftAdditive, false);
- } else if (lastSelectedIndex > end) {
- // Revert previous selection if the user reselects a smaller range.
- setRangeSelection(selectionModel, display, new Range(end + 1,
- lastSelectedIndex - end), !shiftAdditive, false);
- } else {
- // Remember if we are adding or removing rows.
- shiftAdditive = addToSelection;
- }
-
- // Update the last selected row, but do not move the shift anchor.
- lastSelectedIndex = row;
-
- // Select the range.
- setRangeSelection(selectionModel, display, new Range(start, end - start
- + 1), shiftAdditive, clearOthers);
- } else {
- /*
- * If we are not selecting a range, save the last row and set the shift
- * anchor.
- */
- lastDisplay = display;
- lastPageStart = pageStart;
- lastSelectedIndex = row;
- shiftAnchor = row;
- selectOne(selectionModel, rowValue, addToSelection, clearOthers);
- }
- }
-
- @Override
-public void onCellPreview(CellPreviewEvent<T> event) {
- // Early exit if selection is already handled or we are editing.
- if (event.isCellEditing() || event.isSelectionHandled()) {
- return;
- }
-
- // Early exit if we do not have a SelectionModel.
- HasData<T> display = event.getDisplay();
- SelectionModel<? super T> selectionModel = display.getSelectionModel();
- if (selectionModel == null) {
- return;
- }
-
- // Check for user defined actions.
- SelectAction action = (translator == null) ? SelectAction.DEFAULT
- : translator.translateSelectionEvent(event);
-
- // Handle the event based on the SelectionModel type.
- if (selectionModel instanceof MultiSelectionModel) {
- // Add shift key support for MultiSelectionModel.
- handleMultiSelectionEvent(event, action,
- (MultiSelectionModel<? super T>) selectionModel);
- } else {
- // Use the standard handler.
- handleSelectionEvent(event, action, selectionModel);
- }
- }
-
- /**
- * Removes all items from the selection.
- *
- * @param selectionModel the {@link MultiSelectionModel} to clear
- */
- protected void clearSelection(MultiSelectionModel<? super T> selectionModel) {
- selectionModel.clear();
- }
-
- /**
- * Handle an event that could cause a value to be selected for a
- * {@link MultiSelectionModel}. This overloaded method adds support for both
- * the control and shift keys. If the shift key is held down, all rows between
- * the previous selected row and the current row are selected.
- *
- * @param event the {@link CellPreviewEvent} that triggered selection
- * @param action the action to handle
- * @param selectionModel the {@link SelectionModel} to update
- */
- protected void handleMultiSelectionEvent(CellPreviewEvent<T> event,
- SelectAction action, MultiSelectionModel<? super T> selectionModel) {
- NativeEvent nativeEvent = event.getNativeEvent();
- String type = nativeEvent.getType();
- boolean rightclick = "mousedown".equals(type) && nativeEvent.getButton()==NativeEvent.BUTTON_RIGHT;
- SelectAction action1 = action;
- if(rightclick){
- boolean shift = nativeEvent.getShiftKey();
- boolean ctrlOrMeta = nativeEvent.getCtrlKey() || nativeEvent.getMetaKey();
- boolean clearOthers = (translator == null) ? !ctrlOrMeta
- : translator.clearCurrentSelection(event);
- if (action == null || action == SelectAction.DEFAULT) {
- action1 = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
- }
- //if the row is selected then do nothing
- if(selectionModel.isSelected(event.getValue())){
- return;
- }
- doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action1, shift, clearOthers);
- }
- else if ("click".equals(type)) {
- /*
- * Update selection on click. Selection is toggled only if the user
- * presses the ctrl key. If the user does not press the control key,
- * selection is additive.
- */
- boolean shift = nativeEvent.getShiftKey();
- boolean ctrlOrMeta = nativeEvent.getCtrlKey() || nativeEvent.getMetaKey();
- boolean clearOthers = (translator == null) ? !ctrlOrMeta
- : translator.clearCurrentSelection(event);
- if (action == null || action == SelectAction.DEFAULT) {
- action1 = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
- }
- doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action1, shift, clearOthers);
- if(ctrlOrMeta){
- event.setCanceled(true);
- }
- } else if ("keyup".equals(type)) {
- int keyCode = nativeEvent.getKeyCode();
- if (keyCode == 32) {
- /*
- * Update selection when the space bar is pressed. The spacebar always
- * toggles selection, regardless of whether the control key is pressed.
- */
- boolean shift = nativeEvent.getShiftKey();
- boolean clearOthers = (translator == null) ? false
- : translator.clearCurrentSelection(event);
- if (action == null || action == SelectAction.DEFAULT) {
- action1 = SelectAction.TOGGLE;
- }
- doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action1, shift, clearOthers);
- }
- }
- }
-
- /**
- * Handle an event that could cause a value to be selected. This method works
- * for any {@link SelectionModel}. Pressing the space bar or ctrl+click will
- * toggle the selection state. Clicking selects the row if it is not selected.
- *
- * @param event the {@link CellPreviewEvent} that triggered selection
- * @param action the action to handle
- * @param selectionModel the {@link SelectionModel} to update
- */
- protected void handleSelectionEvent(CellPreviewEvent<T> event,
- SelectAction action, SelectionModel<? super T> selectionModel) {
- // Handle selection overrides.
- T value = event.getValue();
- if (action != null) {
- switch (action) {
- case IGNORE:
- return;
- case SELECT:
- selectionModel.setSelected(value, true);
- return;
- case DESELECT:
- selectionModel.setSelected(value, false);
- return;
- case TOGGLE:
- selectionModel.setSelected(value, !selectionModel.isSelected(value));
- return;
- case DEFAULT:
- break;
- }
- }
-
- // Handle default selection.
- NativeEvent nativeEvent = event.getNativeEvent();
- String type = nativeEvent.getType();
- if ("click".equals(type)) {
- if (nativeEvent.getCtrlKey() || nativeEvent.getMetaKey()) {
- // Toggle selection on ctrl+click.
- selectionModel.setSelected(value, !selectionModel.isSelected(value));
- } else {
- // Select on click.
- selectionModel.setSelected(value, true);
- }
- } else if ("keyup".equals(type)) {
- // Toggle selection on space.
- int keyCode = nativeEvent.getKeyCode();
- if (keyCode == 32) {
- selectionModel.setSelected(value, !selectionModel.isSelected(value));
- }
- }
- }
-
- /**
- * Selects the given item, optionally clearing any prior selection.
- *
- * @param selectionModel the {@link MultiSelectionModel} to update
- * @param target the item to select
- * @param selected true to select, false to deselect
- * @param clearOthers true to clear all other selected items
- */
- protected void selectOne(MultiSelectionModel<? super T> selectionModel,
- T target, boolean selected, boolean clearOthers) {
- if (clearOthers) {
- clearSelection(selectionModel);
- }
- selectionModel.setSelected(target, selected);
- }
-
- /**
- * Select or deselect a range of row indexes, optionally deselecting all other
- * values.
- *
- * @param selectionModel the {@link MultiSelectionModel} to update
- * @param display the {@link HasData} source of the selection event
- * @param range the {@link Range} of rows to select or deselect
- * @param addToSelection true to select, false to deselect the range
- * @param clearOthers true to deselect rows not in the range
- */
- protected void setRangeSelection(
- MultiSelectionModel<? super T> selectionModel, HasData<T> display,
- Range range, boolean addToSelection, boolean clearOthers) {
- // Get the list of values to select.
- List<T> toUpdate = new ArrayList<T>();
- int start = range.getStart();
- int end = start + range.getLength();
- for (int i = start; i < end ; i++) {
- toUpdate.add(display.getVisibleItem(i-display.getVisibleRange().getStart()));
- }
- // Clear all other values.
- if (clearOthers) {
- clearSelection(selectionModel);
- }
-
- // Update the state of the values.
- for (T value : toUpdate) {
- selectionModel.setSelected(value, addToSelection);
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-public class SessionExpiredDialog extends DialogBox {
- protected Pithos app;
- /**
- * The widget constructor.
- */
- public SessionExpiredDialog(Pithos _app) {
- app = _app;
- // Set the dialog's caption.
- setText("Session Expired");
- setAnimationEnabled(true);
- setGlassEnabled(true);
- setStyleName("pithos-DialogBox");
-
- VerticalPanel outer = new VerticalPanel();
-
- VerticalPanel inner = new VerticalPanel();
- inner.addStyleName("inner");
-
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("<p>Your session has expired. You will have to reauthenticate with your Identity Provider.</p> ");
- text.setStyleName("pithos-sessionExpired");
- inner.add(text);
-
- // Create the 'OK' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button confirm = new Button("Proceed", new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- app.authenticateUser();
- hide();
- }
- });
- confirm.addStyleName("button");
- inner.add(confirm);
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- outer.setSpacing(8);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
-
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- app.authenticateUser();
- hide();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
-
-
-}
+++ /dev/null
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.http.client.Response;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONValue;
-
-public class SharingUsers extends Resource {
- private List<String> users;
-
- public static SharingUsers createFromResponse(Response response, SharingUsers result) {
- SharingUsers u;
- if (result == null)
- u = new SharingUsers();
- else
- u = result;
- u.populate(response);
- return u;
- }
-
- private void populate(Response response) {
- users = new ArrayList<String>();
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array = json.isArray();
- if (array != null) {
- for (int i=0; i<array.size(); i++) {
- JSONObject o = array.get(i).isObject();
- if (o != null) {
- users.add(unmarshallString(o, "name"));
- }
- }
- }
- }
-
- public List<String> getUsers() {
- return users;
- }
-
- @Override
- public Date getLastModified() {
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.cell.client.Cell.Context;
-import com.google.gwt.cell.client.ClickableTextCell;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-import com.google.gwt.user.cellview.client.Header;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-
-/**
- * A {@link Header} subclass that maintains sorting state and displays an icon
- * to indicate the sort direction.
- */
-public class SortableHeader extends Header<String> {
-
- interface Template extends SafeHtmlTemplates {
- @Template("<div style=\"position:relative;cursor:hand;cursor:pointer;"
- + "padding-right:{0}px;\">{1}<div>{2}</div></div>")
- SafeHtml sorted(int imageWidth, SafeHtml arrow, String text);
-
- @Template("<div style=\"position:relative;cursor:hand;cursor:pointer;"
- + "padding-right:{0}px;\"><div style=\"position:absolute;display:none;"
- + "\"></div><div>{1}</div></div>")
- SafeHtml unsorted(int imageWidth, String text);
- }
-
- private static Template template;
-
- /**
- * Image resources.
- */
- public static interface Resources extends ClientBundle {
-
- ImageResource downArrow();
-
- ImageResource upArrow();
- }
-
- private static final Resources RESOURCES = GWT.create(Resources.class);
- private static final int IMAGE_WIDTH = 16;
- private static final SafeHtml DOWN_ARROW = makeImage(RESOURCES.downArrow());
- private static final SafeHtml UP_ARROW = makeImage(RESOURCES.upArrow());
-
- private static SafeHtml makeImage(ImageResource resource) {
- AbstractImagePrototype proto = AbstractImagePrototype.create(resource);
- String html = proto.getHTML().replace("style='",
- "style='position:absolute;right:0px;top:0px;");
- return SafeHtmlUtils.fromTrustedString(html);
- }
-
- private boolean reverseSort = false;
- private boolean sorted = false;
- private String text;
-
- SortableHeader(String text) {
- super(new ClickableTextCell());
- if (template == null) {
- template = GWT.create(Template.class);
- }
- this.text = text;
- }
-
- public boolean getReverseSort() {
- return reverseSort;
- }
-
- @Override
- public String getValue() {
- return text;
- }
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, SafeHtmlBuilder sb) {
- if (sorted) {
- sb.append(template.sorted(IMAGE_WIDTH, reverseSort ? DOWN_ARROW : UP_ARROW, text));
- } else {
- sb.append(template.unsorted(IMAGE_WIDTH, text));
- }
- }
-
- public void setReverseSort(boolean reverseSort) {
- this.reverseSort = reverseSort;
- }
-
- public void setSorted(boolean sorted) {
- this.sorted = sorted;
- }
-
- public void toggleReverseSort() {
- this.reverseSort = !this.reverseSort;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Composite;
-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.VerticalPanel;
-
-/**
- * The panel that displays a status bar with quota information.
- */
-public class StatusPanel extends Composite {
-
- /**
- * The constructor of the status panel.
- */
- public StatusPanel() {
- HorizontalPanel outer = new HorizontalPanel();
- outer.setWidth("100%");
- outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
-
- VerticalPanel inner = new VerticalPanel();
- inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- HorizontalPanel firstLine = new HorizontalPanel();
- firstLine.setSpacing(8);
-// firstLine.addStyleName("pithos-statusbar");
- firstLine.add(new Anchor("About"));
- firstLine.add(new HTML("|"));
- firstLine.add(new Anchor("Help"));
- firstLine.add(new HTML("|"));
- firstLine.add(new Anchor("Contact"));
- firstLine.add(new HTML("|"));
- firstLine.add(new Anchor("Terms"));
- firstLine.add(new HTML("|"));
- firstLine.add(new Anchor("Privacy"));
- inner.add(firstLine);
-
- HorizontalPanel secondLine = new HorizontalPanel();
- secondLine.add(new HTML("<a class='grnet-sign' href='http://www.grnet.gr'>Copyright (C) 2011 Greek Research and Technology Network</a>"));
- inner.add(secondLine);
- outer.add(inner);
- outer.addStyleName("pithos-statusbar");
-
- initWidget(outer);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.commands.AddUserCommand;
-import gr.grnet.pithos.web.client.commands.CopyCommand;
-import gr.grnet.pithos.web.client.commands.CreateGroupCommand;
-import gr.grnet.pithos.web.client.commands.CutCommand;
-import gr.grnet.pithos.web.client.commands.DeleteCommand;
-import gr.grnet.pithos.web.client.commands.DeleteGroupCommand;
-import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
-import gr.grnet.pithos.web.client.commands.NewFolderCommand;
-import gr.grnet.pithos.web.client.commands.PasteCommand;
-import gr.grnet.pithos.web.client.commands.PropertiesCommand;
-import gr.grnet.pithos.web.client.commands.RefreshCommand;
-import gr.grnet.pithos.web.client.commands.RemoveUserCommand;
-import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
-import gr.grnet.pithos.web.client.commands.ToTrashCommand;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeView;
-import gr.grnet.pithos.web.client.grouptree.User;
-
-import java.util.List;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'Folder Context' menu implementation.
- */
-public class ToolsMenu extends PopupPanel {
-
- /**
- * The widget's images.
- */
- private final Images images;
-
- /**
- * The image bundle for this widget's images that reuses images defined in
- * other menus.
- */
- public interface Images extends GroupTreeView.Images {
- }
-
- private MenuItem pasteItem;
-
- private boolean empty = false;;
-
- /**
- * The widget's constructor.
- *
- * @param newImages the image bundle passed on by the parent object
- */
- public ToolsMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder folder, final List<File> files) {
- // The popup's constructor's argument is a boolean specifying that it
- // auto-close itself when the user clicks outside of it.
- super(true);
- setAnimationEnabled(true);
- images = newImages;
- MenuBar contextMenu = new MenuBar(true);
-
- if (folder != null) {
- Boolean[] permissions = folder.getPermissions().get(app.getUsername());
- boolean canWrite = folder.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
- boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView());
- boolean otherSharedTreeSelected = selectedTree.equals(app.getOtherSharedTreeView());
-
- if (isFolderTreeSelected || otherSharedTreeSelected) {
- MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(app, this, folder));
- contextMenu.addItem(refresh);
- }
-
- if (!folder.isInTrash()) {
- if (canWrite) {
- MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
- contextMenu.addItem(newFolder);
-
- if (isFolderTreeSelected) {
- MenuItem cut = null;
- if (files != null && !files.isEmpty()) {
- cut = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut files</span>", true, new CutCommand(app, this, files));
- }
- else if (!folder.isContainer()) {
- cut = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut folder</span>", true, new CutCommand(app, this, folder));
- }
- if (cut != null)
- contextMenu.addItem(cut);
- }
- }
-
- MenuItem copy = null;
- if (files != null && !files.isEmpty())
- copy = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy files</span>", true, new CopyCommand(app, this, files));
- else
- copy = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy folder</span>", true, new CopyCommand(app, this, folder));
- contextMenu.addItem(copy);
-
- if (canWrite) {
- if (!app.getClipboard().isEmpty()) {
- Object item = app.getClipboard().getItem();
- boolean showPaste = false;
- if (item instanceof List) {
- List<File> _files = (List<File>) item;
- if (_files.get(0).getOwner().equals(folder.getOwner()))
- showPaste = true;
- }
- else {
- Folder f = (Folder) item;
- if (f.getOwner().equals(folder.getOwner()))
- showPaste = true;
- }
- if (showPaste) {
- pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, folder));
- contextMenu.addItem(pasteItem);
- }
- }
-
- if (isFolderTreeSelected) {
- MenuItem moveToTrash = null;
- if (files != null && !files.isEmpty()) {
- moveToTrash = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move files to Trash</span>", true, new ToTrashCommand(app, this, files));
- }
- else if (!folder.isContainer()) {
- moveToTrash = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move folder to Trash</span>", true, new ToTrashCommand(app, this, folder));
- }
- if (moveToTrash != null)
- contextMenu.addItem(moveToTrash);
-
- MenuItem delete = null;
- if (files != null && !files.isEmpty()) {
- delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete files</span>", true, new DeleteCommand(app, this, files, MessagePanel.images));
- }
- else if (!folder.isContainer())
- delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete folder</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
- if (delete != null)
- contextMenu.addItem(delete);
-
- MenuItem properties = null;
- if (files != null && files.size() == 1)
- properties = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " File properties</span>", true, new PropertiesCommand(app, this, files, images, 0));
- else if (!folder.isContainer())
- properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Folder properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
- if (properties != null)
- contextMenu.addItem(properties);
- }
- if (files != null) {
- contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</span>", true, new Command() {
-
- @Override
- public void execute() {
- for (File f: files)
- Window.open(app.getApiPath() + files.get(0).getOwner() + files.get(0).getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
- }
- }));
- }
- }
- }
- else {
- if (!folder.isTrash()) {
- MenuItem restore = null;
- if (files != null && !files.isEmpty())
- restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(app, this, files));
- else
- restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(app, this, folder));
- contextMenu.addItem(restore);
-
- MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
- contextMenu.addItem(delete);
- }
- else {
- MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(app, this));
- contextMenu.addItem(emptyTrash);
- }
- }
- }
- else {
- Object o = app.getGroupTreeView().getSelected();
- if (o != null) {
- if (o instanceof User) {
- MenuItem removeUser = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Remove User</span>", true, new RemoveUserCommand(app, this, (User) o));
- contextMenu.addItem(removeUser);
- }
- else if (o instanceof Group) {
- MenuItem addUser = new MenuItem("<span>" + AbstractImagePrototype.create(images.user()).getHTML() + " Add User</span>", true, new AddUserCommand(app, this, (Group) o));
- contextMenu.addItem(addUser);
-
- MenuItem deleteGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete Group</span>", true, new DeleteGroupCommand(app, this, (Group) o));
- contextMenu.addItem(deleteGroup);
- }
- else {
- MenuItem createGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.group()).getHTML() + " Create Group</span>", true, new CreateGroupCommand(app, this));
- contextMenu.addItem(createGroup);
- }
- }
- else
- empty = true;
- }
- add(contextMenu);
- }
-
- public boolean isEmpty() {
- return empty;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-
-/**
- * The top panel, which contains the menu bar icons and the user name.
- */
-public class TopPanel extends Composite {
-
- /**
- * A constant that denotes the completion of an IncrementalCommand.
- */
- public static final boolean DONE = false;
-
- Pithos app;
-
- /**
- * An image bundle for this widgets images.
- */
- public interface Images extends FilePropertiesDialog.Images {
-
- @Source("gr/grnet/pithos/resources/pithos2-logo.png")
- ImageResource pithosLogo();
-
- @Source("gr/grnet/pithos/resources/desc.png")
- ImageResource downArrow();
- }
-
- /**
- * The constructor for the top panel.
- *
- * @param images the supplied images
- */
- public TopPanel(Pithos _app, final Images images) {
- this.app = _app;
- HorizontalPanel outer = new HorizontalPanel();
- outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
-
- outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- outer.setStyleName("pithos-topPanel");
-
- HorizontalPanel inner = new HorizontalPanel();
- inner.setWidth("75%");
- inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
-
- HTML logos = new HTML("<table><tr><td><a href='/'>" + AbstractImagePrototype.create(images.pithosLogo()).getHTML() + "</a></td></tr></table>");
- logos.addStyleName("pithos-logo");
- inner.add(logos);
-
- MenuBar username = new MenuBar();
- username.setStyleName("pithos-usernameMenu");
-
- MenuBar userItemMenu = new MenuBar(true);
- userItemMenu.addStyleName("pithos-userItemMenu");
- userItemMenu.addItem(new MenuItem("invite friends...", new Command() {
-
- @Override
- public void execute() {
- GetRequest<Invitations> getInvitations = new GetRequest<Invitations> (Invitations.class, "/im/", "", "invite?format=json") {
-
- @Override
- public void onSuccess(Invitations _result) {
- new InvitationsDialog(app, _result).center();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException)
- app.displayError("Error getting invitations: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error getting invitations: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getInvitations.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getInvitations);
- }
- }));
- userItemMenu.addItem(new MenuItem("send feedback...", new Command() {
-
- @Override
- public void execute() {
- new FeedbackDialog(app).center();
- }
- }));
- userItemMenu.addItem(new MenuItem("API access", new Command() {
-
- @Override
- public void execute() {
- new CredentialsDialog(app, images).center();
- }
- }));
- userItemMenu.addItem(new MenuItem("logout", new Command() {
-
- @Override
- public void execute() {
- app.logoff();
- }
- }));
-
- MenuItem userItem = new MenuItem(_app.getUsername(), userItemMenu);
- userItem.addStyleName("pithos-usernameMenuItem");
- username.addItem(userItem);
- username.addSeparator();
-
- MenuItem langItem = new MenuItem("en", (Command) null);
- langItem.addStyleName("pithos-langMenuItem");
- username.addItem(langItem);
-
- inner.add(username);
- inner.setCellHorizontalAlignment(username, HasHorizontalAlignment.ALIGN_RIGHT);
-
- outer.add(inner);
- outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- outer.setCellVerticalAlignment(inner, HasVerticalAlignment.ALIGN_BOTTOM);
- initWidget(outer);
- }
-}
+++ /dev/null
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-public interface TreeView {
- public Folder getSelection();
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.FilePropertiesDialog.Images;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.foldertree.Version;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.List;
-
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class VersionsList extends Composite {
-
- Pithos app;
-
- File file;
-
- private List<Version> versions = null;
-
- private Images images;
-
- private VerticalPanel permPanel = new VerticalPanel();
-
- private FlexTable permTable = new FlexTable();
-
- FilePropertiesDialog container;
-
- public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, File _file, List<Version> theVersions) {
- app = _app;
- images = theImages;
- container = aContainer;
- file = _file;
- versions = theVersions;
- permTable.setText(0, 0, "Version");
- permTable.setText(0, 1, "Date");
- permTable.setText(0, 2, "");
- permTable.setText(0, 3, "");
- permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
- permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
- permTable.getFlexCellFormatter().setColSpan(0, 1, 2);
- permTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
- permTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
- permPanel.add(permTable);
- permPanel.addStyleName("pithos-TabPanelBottom");
- permTable.addStyleName("pithos-permList");
- initWidget(permPanel);
- showVersionsTable();
- }
-
- public void showVersionsTable(){
- DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
- int i = 1;
- for (final Version v : versions) {
- HTML restoreVersion = new HTML("<a href='#' class='hidden-link info'><span>" + AbstractImagePrototype.create(images.restore()).getHTML() + "</span><div>Restore this Version</div></a>");
- restoreVersion.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- restoreVersion(v.getVersion());
- }
- });
-
- permTable.setHTML(i, 0, "<span>" + v.getVersion() + "</span>");
- if (v.getDate() != null)
- permTable.setHTML(i, 1, "<span>" + formatter.format(v.getDate()) + "</span>");
- else
- permTable.setHTML(i, 1, "<span></span>");
- HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>" + AbstractImagePrototype.create(images.download()).getHTML()+"</span><div>View this Version</div></a>");
- downloadHtml.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- String fileUrl = app.getApiPath() + file.getOwner() + file.getUri() + "?X-Auth-Token=" + app.getToken() + "&version=" + v.getVersion();
- Window.open(fileUrl, "_BLANK", "");
- }
- });
- permTable.setWidget(i, 2, downloadHtml);
- permTable.setWidget(i, 3, restoreVersion);
- permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
- permTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);
- permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
- permTable.getFlexCellFormatter().setColSpan(i, 1, 2);
- i++;
- }
- }
-
- void restoreVersion(int version) {
- String path = file.getUri() + "?update=";
- PostRequest restoreVersion = new PostRequest(app.getApiPath(), file.getOwner(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- container.hide();
- }
-
- @Override
- public void onError(Throwable t) {
- if (t instanceof RestException) {
- if (((RestException) t).getHttpStatusCode() == Response.SC_NO_CONTENT)
- onSuccess(null);
- else
- app.displayError("Unable to restore version: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to restore versions: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- restoreVersion.setHeader("X-Auth-Token", app.getToken());
- restoreVersion.setHeader("X-Source-Object", file.getUri());
- restoreVersion.setHeader("X-Source-Version", String.valueOf(version));
- restoreVersion.setHeader("Content-Range", "bytes 0-/*");
- Scheduler.get().scheduleDeferred(restoreVersion);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.animation;
-
-import com.google.gwt.animation.client.Animation;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.Widget;
-
-
-public class FadeIn extends Animation {
- Widget widget;
- int initialOpacity = 100;
- double currOpacity = 100;
-
- public FadeIn(Widget aWidget){
- widget = aWidget;
- }
-
- @Override
- protected void onUpdate(double progress) {
- if(currOpacity > 0.0){
- double progress1 = 1.0 - progress;
- currOpacity = initialOpacity * progress1;
- DOM.setStyleAttribute(widget.getElement(), "opacity", ""+new Double(1d - currOpacity / 100d));
- //required for ie to work
- //Disabled because IE has bugs rendering non-opaque objects
- //int opacityToSet = new Double(currOpacity).intValue();
- //DOM.setStyleAttribute(widget.getElement(), "filter", "alpha(opacity=" + (initialOpacity - opacityToSet) + ")");
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.animation;
-
-import com.google.gwt.animation.client.Animation;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.Widget;
-
-
-public class FadeOut extends Animation {
- Widget widget;
-
- int initialOpacity = 100;
- double currOpacity = 100;
-
- public FadeOut(Widget aWidget){
- widget = aWidget;
- }
-
- @Override
- protected void onUpdate(double progress) {
- if(currOpacity>0.0){
- double progress1 = 1.0 - progress;
- currOpacity = initialOpacity*progress1;
- DOM.setStyleAttribute(widget.getElement(), "opacity", ""+new Double(currOpacity/100d));
- //required for ie to work
- //Disabled because IE has bugs rendering non-opaque objects
- //int opacityToSet = new Double(currOpacity).intValue();
- //DOM.setStyleAttribute(widget.getElement(), "filter", "alpha(opacity="+currOpacity+")");
- }
- }
-
- /*
- protected void onComplete() {
- super.onComplete();
- hpanel.clear();
- html = new HTML(" ");
- hpanel.getParent().setVisible(false);
- }
- */
-
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Display the 'new folder' dialog for creating a new folder.
- *
- */
-public class AddUserCommand implements Command {
- private PopupPanel containerPanel;
-
- Group group;
-
- Pithos app;
-
- /**
- * @param aContainerPanel
- */
- public AddUserCommand(Pithos _app, PopupPanel aContainerPanel, Group _group){
- app = _app;
- containerPanel = aContainerPanel;
- group = _group;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- String username = Window.prompt("Enter username:", "");
- if (username != null && username.length() > 0) {
- group.addMember(username);
- String path = "?update=";
- PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUsername(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- app.updateGroupNode(group);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to update group:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error updating group:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- updateGroup.setHeader("X-Auth-Token", app.getToken());
- String groupMembers = "";
- for (String u : group.getMembers())
- groupMembers += (u + ",");
- updateGroup.setHeader("X-Account-Group-" + URL.encodePathSegment(group.getName()), groupMembers);
- Scheduler.get().scheduleDeferred(updateGroup);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Clipboard;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import java.util.List;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-/**
- *
- * Command for copying a file, folder or user to Pithos Clipboard
- *
- */
-public class CopyCommand implements Command{
- private Pithos app;
- private PopupPanel containerPanel;
- private Object resource;
-
- public CopyCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
- app = _app;
- containerPanel = _containerPanel;
- resource = _resource;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- if (resource instanceof Folder) {
- app.getClipboard().setItem(Clipboard.COPY, (Folder) resource);
- } else if (resource instanceof List) {
- app.getClipboard().setItem(Clipboard.COPY, (List<File>) resource);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Display the 'new folder' dialog for creating a new folder.
- *
- */
-public class CreateGroupCommand implements Command {
- private PopupPanel containerPanel;
-
- Pithos app;
-
- /**
- * @param aContainerPanel
- */
- public CreateGroupCommand(Pithos _app, PopupPanel aContainerPanel){
- app = _app;
- containerPanel = aContainerPanel;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- String groupname = Window.prompt("Enter group name:", "");
- if (groupname != null && groupname.length() > 0) {
- app.addGroup(groupname);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Clipboard;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import java.util.List;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Command for cutting a file, folder or user to Pithos Clipboard
- *
- */
-public class CutCommand implements Command {
- private Pithos app;
-
- private PopupPanel containerPanel;
-
- private Object resource;
-
- public CutCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
- app = _app;
- containerPanel = _containerPanel;
- resource = _resource;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- if (resource instanceof Folder) {
- app.getClipboard().setItem(Clipboard.CUT, (Folder) resource);
- } else if (resource instanceof List) {
- app.getClipboard().setItem(Clipboard.CUT, (List<File>) resource);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.DeleteFileDialog;
-import gr.grnet.pithos.web.client.DeleteFolderDialog;
-import gr.grnet.pithos.web.client.MessagePanel.Images;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import java.util.List;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-/**
- * Delete selected object command
- *
- */
-public class DeleteCommand implements Command{
- private PopupPanel containerPanel;
- final Images newImages;
-
- private Object resource;
-
- private Pithos app;
- /**
- * @param _containerPanel
- * @param _newImages the images of all the possible delete dialogs
- */
- public DeleteCommand(Pithos _app, PopupPanel _containerPanel, Object resource, final Images _newImages ){
- app = _app;
- containerPanel = _containerPanel;
- newImages = _newImages;
- this.resource = resource;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- if (resource instanceof Folder) {
- DeleteFolderDialog dlg = new DeleteFolderDialog(app, newImages, (Folder) resource);
- dlg.center();
- } else if (resource instanceof List) {
- @SuppressWarnings("unchecked")
- DeleteFileDialog dlg = new DeleteFileDialog(app, newImages, (List<File>) resource);
- dlg.center();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-/**
- * Delete selected object command
- *
- */
-public class DeleteGroupCommand implements Command {
- private PopupPanel containerPanel;
-
- Group group;
-
- Pithos app;
-
- /**
- * @param _containerPanel
- */
- public DeleteGroupCommand(Pithos _app, PopupPanel _containerPanel, Group _group){
- app = _app;
- containerPanel = _containerPanel;
- group = _group;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- if (Window.confirm("Are you sure you want to delete group " + group.getName())) {
- String path = "?update=";
- PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUsername(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- app.removeGroup(group);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to delete group:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error deleting group:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- updateGroup.setHeader("X-Auth-Token", app.getToken());
- updateGroup.setHeader("X-Account-Group-" + URL.encodePathSegment(group.getName()), "~");
- Scheduler.get().scheduleDeferred(updateGroup);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import java.util.Iterator;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.DeleteRequest;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-/**
- * Command to empty trash bin.
- */
-public class EmptyTrashCommand implements Command{
- private PopupPanel containerPanel;
-
- Pithos app;
-
- public EmptyTrashCommand(Pithos _app, PopupPanel _containerPanel){
- app = _app;
- containerPanel = _containerPanel;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- final Folder trash = app.getAccount().getTrash();
- if (trash != null) {
- Iterator<File> iter = trash.getFiles().iterator();
- deleteFile(iter, new Command() {
-
- @Override
- public void execute() {
- Iterator<Folder> iter2 = trash.getSubfolders().iterator();
- deleteSubfolder(iter2, new Command() {
-
- @Override
- public void execute() {
- app.updateTrash(true, new Command() {
-
- @Override
- public void execute() {
- app.updateStatistics();
- }
- });
- }
- });
- }
- });
- }
- }
-
- protected void deleteSubfolder(final Iterator<Folder> iter2, final Command callback) {
- if (iter2.hasNext()) {
- final Folder f = iter2.next();
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
-
- @Override
- public void onSuccess(final Folder _f) {
- Iterator<File> iter3 = _f.getFiles().iterator();
- deleteFile(iter3, new Command() {
-
- @Override
- public void execute() {
- Iterator<Folder> iter4 = _f.getSubfolders().iterator();
- deleteSubfolder(iter4, new Command() {
-
- @Override
- public void execute() {
- String path = _f.getUri();
- DeleteRequest deleteF = new DeleteRequest(app.getApiPath(), _f.getOwner(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- deleteSubfolder(iter2, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to delete file:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error deleting file:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- deleteF.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(deleteF);
- }
- });
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error getting folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
- else {
- if (callback != null)
- callback.execute();
- }
- }
-
- void deleteFile(final Iterator<File> iter, final Command callback) {
- if (iter.hasNext()) {
- File f = iter.next();
- String path = f.getUri();
- DeleteRequest deleteF = new DeleteRequest(app.getApiPath(), f.getOwner(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- deleteFile(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to delete file:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error deleting file:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- deleteF.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(deleteF);
- }
- else {
- if (callback != null)
- callback.execute();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.FileContextMenu.Images;
-import gr.grnet.pithos.web.client.FolderPropertiesDialog;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Display the 'new folder' dialog for creating a new folder.
- *
- */
-public class NewFolderCommand implements Command{
- private PopupPanel containerPanel;
-
- private Folder folder;
- final Images images;
-
- private Pithos app;
-
- /**
- * @param aContainerPanel
- * @param newImages the images of the new folder dialog
- */
- public NewFolderCommand(Pithos _app, PopupPanel aContainerPanel, Folder folder, final Images newImages){
- app = _app;
- containerPanel = aContainerPanel;
- images=newImages;
- this.folder = folder;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- displayNewFolderDialog();
- }
-
- void displayNewFolderDialog() {
- if (folder != null) {
- FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, true, folder);
- dlg.center();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import com.google.gwt.core.client.Scheduler;
-import gr.grnet.pithos.web.client.Clipboard;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.PutRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-public class PasteCommand implements Command {
-
- protected Pithos app;
- private PopupPanel containerPanel;
- protected Folder folder;
-
- public PasteCommand(Pithos _app, PopupPanel _containerPanel, Folder _folder) {
- app = _app;
- containerPanel = _containerPanel;
- folder = _folder;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- Object clipboardItem = app.getClipboard().getItem();
- if (clipboardItem == null)
- return;
- int operation = app.getClipboard().getOperation();
- if (clipboardItem instanceof Folder) {
- final Folder tobeCopied = (Folder) clipboardItem;
- if (operation == Clipboard.COPY) {
- app.copyFolder(tobeCopied, folder.getOwner(), folder.getUri(), new Command() {
- @Override
- public void execute() {
- app.getClipboard().clear();
- app.updateFolder(folder, true, new Command() {
-
- @Override
- public void execute() {
- app.updateStatistics();
- }
- });
- }
- });
- }
- else {
- app.copyFolder(tobeCopied, folder.getOwner(), folder.getUri(), new Command() {
- @Override
- public void execute() {
- app.getClipboard().clear();
- app.deleteFolder(tobeCopied);
- app.updateFolder(folder, true, null);
- }
- });
- }
- }
- else {
- @SuppressWarnings("unchecked")
- List<File> tobeCopied = (List<File>) clipboardItem;
- Iterator<File> iter = tobeCopied.iterator();
- if (operation == Clipboard.COPY) {
- app.copyFiles(iter, folder.getOwner(), folder.getUri(), new Command() {
- @Override
- public void execute() {
- app.getClipboard().clear();
- app.updateFolder(folder, true, new Command() {
-
- @Override
- public void execute() {
- app.updateStatistics();
- }
- });
- }
- });
- }
- else {
- moveFiles(iter, new Command() {
- @Override
- public void execute() {
- app.getClipboard().clear();
- app.updateFolder(folder, true, null);
- }
- });
- }
- }
- }
-
- protected void moveFiles(final Iterator<File> iter, final Command callback) {
- if (iter.hasNext()) {
- File file = iter.next();
- String path = folder.getUri() + "/" + file.getName();
- PutRequest copyFile = new PutRequest(app.getApiPath(), folder.getOwner(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- moveFiles(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to copy file: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- copyFile.setHeader("X-Auth-Token", app.getToken());
- copyFile.setHeader("X-Move-From", file.getUri());
- copyFile.setHeader("Content-Type", file.getContentType());
- Scheduler.get().scheduleDeferred(copyFile);
- }
- else if (callback != null) {
- callback.execute();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.FileContextMenu;
-import gr.grnet.pithos.web.client.FilePropertiesDialog;
-import gr.grnet.pithos.web.client.FilesPropertiesDialog;
-import gr.grnet.pithos.web.client.FolderPropertiesDialog;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import java.util.List;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The command that displays the appropriate Properties dialog, according to the
- * selected object in the application.
- *
- */
-public class PropertiesCommand implements Command {
-
- final FileContextMenu.Images newImages;
-
- private PopupPanel containerPanel;
-
- private int tabToShow = 0;
-
- private Object resource;
-
- private Pithos app;
-
- /**
- * @param _containerPanel
- * @param _newImages the images of all the possible delete dialogs
- * @param _tab the tab to switch to
- */
- public PropertiesCommand(Pithos _app, PopupPanel _containerPanel, Object _resource, final FileContextMenu.Images _newImages, int _tab) {
- containerPanel = _containerPanel;
- newImages = _newImages;
- tabToShow = _tab;
- resource = _resource;
- app = _app;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
-
- if (resource instanceof Folder) {
- Folder folder = (Folder) resource;
- FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, false, folder);
- dlg.selectTab(tabToShow);
- dlg.center();
- }
- else if (resource instanceof List) {
- @SuppressWarnings("unchecked")
- List<File> files = (List<File>) resource;
- if (files.size() > 1) {
- FilesPropertiesDialog dlg = new FilesPropertiesDialog(app, files);
- dlg.selectTab(tabToShow);
- dlg.center();
- }
- else {
- FilePropertiesDialog dlg = new FilePropertiesDialog(app, files.get(0));
- dlg.selectTab(tabToShow);
- dlg.center();
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-public class RefreshCommand implements Command {
-
- private PopupPanel containerPanel;
-
- private Pithos app;
-
- private Folder folder;
-
- /**
- * @param _containerPanel
- */
- public RefreshCommand(Pithos _app, PopupPanel _containerPanel, Folder _folder) {
- app = _app;
- containerPanel = _containerPanel;
- folder = _folder;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- app.updateFolder(folder, true, null);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.grouptree.User;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Display the 'new folder' dialog for creating a new folder.
- *
- */
-public class RemoveUserCommand implements Command {
- private PopupPanel containerPanel;
-
- User user;
-
- Pithos app;
-
- /**
- * @param aContainerPanel
- */
- public RemoveUserCommand(Pithos _app, PopupPanel aContainerPanel, User _user){
- app = _app;
- containerPanel = aContainerPanel;
- user = _user;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- final Group group = user.getGroup();
- group.removeMember(user.getName());
- String path = "?update=";
- PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUsername(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- app.updateGroupNode(group);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to update group:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error updating group:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- updateGroup.setHeader("X-Auth-Token", app.getToken());
- String groupMembers = "";
- if (!group.getMembers().isEmpty()) {
- for (String u : group.getMembers())
- groupMembers += (u + ",");
- }
- else
- groupMembers = "~";
- updateGroup.setHeader("X-Account-Group-" + URL.encodePathSegment(group.getName()), groupMembers);
- Scheduler.get().scheduleDeferred(updateGroup);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-public class ResreshOthersSharesCommand implements Command{
- private PopupPanel containerPanel;
-
- public ResreshOthersSharesCommand(PopupPanel _containerPanel){
- containerPanel = _containerPanel;
- }
-
- @Override
- public void execute() {
- containerPanel.hide();
- //TODO:CELLTREE
- //app.getFolders().update( app.getFolders().getCurrent());
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import java.util.Iterator;
-import java.util.List;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.DeleteRequest;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.PutRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-/**
- *
- * Restore trashed files and folders.
- *
- */
-public class RestoreTrashCommand implements Command {
- private PopupPanel containerPanel;
- protected Pithos app;
- protected Object resource;
-
- public RestoreTrashCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
- containerPanel = _containerPanel;
- app = _app;
- resource = _resource;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- if (resource instanceof List) {
- @SuppressWarnings("unchecked")
- Iterator<File> iter = ((List<File>) resource).iterator();
- untrashFiles(iter, new Command() {
- @SuppressWarnings("unchecked")
- @Override
- public void execute() {
- app.updateFolder(((List<File>) resource).get(0).getParent(), true, null);
- }
- });
- }
- else if (resource instanceof Folder) {
- final Folder toBeUnTrashed = (Folder) resource;
- untrashFolder(toBeUnTrashed, new Command() {
- @Override
- public void execute() {
- app.updateFolder(toBeUnTrashed.getParent(), true, null);
- }
- });
-
- }
- }
-
- private void untrashFolder(final Folder f, final Command callback) {
- String path = "/" + Pithos.HOME_CONTAINER + "/" + f.getPrefix();
- PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
-
- @Override
- public void onSuccess(final Folder _f) {
- Iterator<File> iter = _f.getFiles().iterator();
- untrashFiles(iter, new Command() {
- @Override
- public void execute() {
- Iterator<Folder> iterf = _f.getSubfolders().iterator();
- untrashSubfolders(iterf, new Command() {
-
- @Override
- public void execute() {
- DeleteRequest deleteFolder = new DeleteRequest(app.getApiPath(), _f.getOwner(), _f.getUri()) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource _result) {
- app.updateRootFolder(callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND)
- onSuccess(null);
- else
- app.displayError("Unable to delete folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to delete folder: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- deleteFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(deleteFolder);
- }
- });
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error getting folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error creating folder:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- createFolder.setHeader("X-Auth-Token", app.getToken());
- createFolder.setHeader("Accept", "*/*");
- createFolder.setHeader("Content-Length", "0");
- createFolder.setHeader("Content-Type", "application/folder");
- Scheduler.get().scheduleDeferred(createFolder);
- }
-
- protected void untrashFiles(final Iterator<File> iter, final Command callback) {
- if (iter.hasNext()) {
- File file = iter.next();
- String path = "/" + Pithos.HOME_CONTAINER + "/" + file.getPath();
- PutRequest untrashFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- untrashFiles(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to copy file: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- untrashFile.setHeader("X-Auth-Token", app.getToken());
- untrashFile.setHeader("X-Move-From", file.getUri());
- Scheduler.get().scheduleDeferred(untrashFile);
- }
- else if (callback != null) {
- callback.execute();
- }
- }
-
- protected void untrashSubfolders(final Iterator<Folder> iter, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
- untrashFolder(f, new Command() {
-
- @Override
- public void execute() {
- untrashSubfolders(iter, callback);
- }
- });
- }
- else {
- if (callback != null)
- callback.execute();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import gr.grnet.pithos.web.client.rest.DeleteRequest;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.PutRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- *
- * Move file or folder to trash.
- *
- *
- */
-public class ToTrashCommand implements Command{
- private PopupPanel containerPanel;
- protected Pithos app;
- protected Object resource;
-
- public ToTrashCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
- containerPanel = _containerPanel;
- app = _app;
- resource = _resource;
- }
-
- @Override
- public void execute() {
- if (containerPanel != null)
- containerPanel.hide();
- if (resource instanceof List) {
- @SuppressWarnings("unchecked")
- Iterator<File> iter = ((List<File>) resource).iterator();
- trashFiles(iter, new Command() {
- @SuppressWarnings("unchecked")
- @Override
- public void execute() {
- app.updateFolder(((List<File>) resource).get(0).getParent(), true, null);
- }
- });
- }
- else if (resource instanceof Folder) {
- final Folder toBeTrashed = (Folder) resource;
- trashFolder(toBeTrashed, new Command() {
- @Override
- public void execute() {
- app.updateFolder(toBeTrashed.getParent(), true, null);
- }
- });
-
- }
- }
-
- private void trashFolder(final Folder f, final Command callback) {
- String path = "/" + Pithos.TRASH_CONTAINER + "/" + f.getPrefix();
- PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
-
- @Override
- public void onSuccess(final Folder _f) {
- Iterator<File> iter = _f.getFiles().iterator();
- trashFiles(iter, new Command() {
- @Override
- public void execute() {
- Iterator<Folder> iterf = _f.getSubfolders().iterator();
- trashSubfolders(iterf, new Command() {
-
- @Override
- public void execute() {
- DeleteRequest deleteFolder = new DeleteRequest(app.getApiPath(), _f.getOwner(), _f.getUri()) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource _result) {
- if (callback != null)
- callback.execute();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND)
- onSuccess(null);
- else
- app.displayError("Unable to delete folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to delete folder: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- deleteFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(deleteFolder);
- }
- });
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error getting folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error creating folder:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- createFolder.setHeader("X-Auth-Token", app.getToken());
- createFolder.setHeader("Accept", "*/*");
- createFolder.setHeader("Content-Length", "0");
- createFolder.setHeader("Content-Type", "application/folder");
- Scheduler.get().scheduleDeferred(createFolder);
- }
-
-
-
- protected void trashFiles(final Iterator<File> iter, final Command callback) {
- if (iter.hasNext()) {
- File file = iter.next();
- String path = "/" + Pithos.TRASH_CONTAINER + "/" + file.getPath();
- PutRequest trashFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- trashFiles(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error unable to copy file: "+t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- trashFile.setHeader("X-Auth-Token", app.getToken());
- trashFile.setHeader("X-Move-From", file.getUri());
- Scheduler.get().scheduleDeferred(trashFile);
- }
- else if (callback != null) {
- callback.execute();
- }
- }
-
- protected void trashSubfolders(final Iterator<Folder> iter, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
- trashFolder(f, new Command() {
-
- @Override
- public void execute() {
- trashSubfolders(iter, callback);
- }
- });
- }
- else {
- app.updateTrash(false, callback);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.FileUploadDialog;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * Upload a file command
- *
- */
-public class UploadFileCommand implements Command {
-
- private PopupPanel containerPanel;
-
- private Pithos app;
-
- /*
- * The folder that is the target of the upload
- */
- private Folder folder;
-
- public UploadFileCommand(Pithos _app, PopupPanel _containerPanel, Folder _folder) {
- app = _app;
- containerPanel = _containerPanel;
- folder = _folder;
- }
-
- @Override
- public void execute() {
- if(containerPanel!=null)
- containerPanel.hide();
- displayNewFile();
- }
-
- /**
- * Display the 'new file' dialog for uploading a new file to the system.
- */
- private void displayNewFile() {
- FileUploadDialog dlg = GWT.create(FileUploadDialog.class);
- dlg.setApp(app);
- dlg.setFolder(folder);
- dlg.center();
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.components;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.FocusWidget;
-import com.google.gwt.user.client.ui.HasValue;
-
-/**
- * Checkbox with three states (checked, unchecked and undefined).
- *
- */
-public class TristateCheckBox extends FocusWidget implements HasValue<Boolean> {
-
- private static final String UNCHECKED_IMG = "images/tristate_unchecked.gif";
-
- private static final String UNKNOWN_IMG = "images/tristate_intermediate.gif";
-
- private static final String CHECKED_IMG = "images/tristate_checked.gif";
-
- protected final Element buttonElement = DOM.createElement("input");
-
- private boolean valueChangeHandlerInitialized;
-
- private Boolean value;
-
- protected Boolean initialValue;
-
- public TristateCheckBox(final Boolean state) {
- DOM.setElementProperty(buttonElement, "type", "image");
- setElement(buttonElement);
- setStyleName("tristateCheckbox");
- DOM.setElementAttribute(buttonElement, "src", UNCHECKED_IMG);
-
- addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- final String img = DOM.getElementAttribute(buttonElement, "src");
- String newImg;
- if (img.endsWith(UNCHECKED_IMG))
- newImg = CHECKED_IMG;
- else if (img.endsWith(UNKNOWN_IMG))
- newImg = UNCHECKED_IMG;
- else if (img.endsWith(CHECKED_IMG))
- if (initialValue==null) // Only show unknown choice if there is a reason for it
- newImg = UNKNOWN_IMG;
- else
- newImg = UNCHECKED_IMG;
- else
- throw new IllegalArgumentException("unknown checkbox state");
-
- DOM.setElementAttribute(buttonElement, "src", newImg);
- }
-
- });
-
- setState(state);
- initialValue = state;
- }
-
- public void setState(final Boolean state) {
- DOM.setElementAttribute(buttonElement, "src", state == null ?
- UNKNOWN_IMG : state.booleanValue() ? CHECKED_IMG : UNCHECKED_IMG);
- }
-
- public Boolean getState() {
- final String img = DOM.getElementAttribute(buttonElement, "src");
- if (img.endsWith(UNCHECKED_IMG))
- return Boolean.FALSE;
- else if (img.endsWith(UNKNOWN_IMG))
- return null;
- else if (img.endsWith(CHECKED_IMG))
- return Boolean.TRUE;
- else
- throw new IllegalArgumentException("unknown checkbox state");
- }
-
- @Override
- public Boolean getValue() {
- return value;
- }
-
- @Override
- public void setValue(final Boolean _value) {
- value = _value;
- }
-
- @Override
- public HandlerRegistration addValueChangeHandler(
- ValueChangeHandler<Boolean> handler) {
- // Is this the first value change handler? If so, time to add handlers
- if (!valueChangeHandlerInitialized) {
- ensureDomEventHandlers();
- valueChangeHandlerInitialized = true;
- }
- return addHandler(handler, ValueChangeEvent.getType());
- }
-
- protected void ensureDomEventHandlers() {
- addClickHandler(new ClickHandler() {
- @Override
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {
- ValueChangeEvent.fire(TristateCheckBox.this, getValue());
- }
- });
- }
-
- @Override
- public void setValue(Boolean _value, boolean fireEvents) {
- Boolean oldValue = getValue();
- setValue(_value);
- if (_value.equals(oldValue))
- return;
- if (fireEvents)
- ValueChangeEvent.fire(this, _value);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.grouptree.Group;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.http.client.Header;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONValue;
-
-/**
- * Created by IntelliJ IDEA. User: chstath Date: 5/19/11 Time: 2:55 PM To change this template use File | Settings |
- * File Templates.
- */
-public class AccountResource extends Resource {
-
- private long numberOfContainers = 0;
-
- private long numberOfObjects = 0;
-
- private long bytesUsed = 0;
-
- private long quota = 0;
-
- private Date lastLogin = null;
-
- private Date lastModified = null;
-
- private List<Folder> containers = new ArrayList<Folder>();
-
- private Date currentLogin = null;
-
- private List<Group> groups = new ArrayList<Group>();
-
- public long getQuota() {
- return quota;
- }
-
- public void setQuota(long quota) {
- this.quota = quota;
- }
-
- public long getBytesUsed() {
- return bytesUsed;
- }
-
- public void setBytesUsed(long bytesUsed) {
- this.bytesUsed = bytesUsed;
- }
-
- public Date getLastLogin() {
- return lastLogin;
- }
-
- public void setLastLogin(Date lastLogin) {
- this.lastLogin = lastLogin;
- }
-
- @Override
- public Date getLastModified() {
- return lastModified;
- }
-
- public void setLastModified(Date lastModified) {
- this.lastModified = lastModified;
- }
-
- public long getNumberOfContainers() {
- return numberOfContainers;
- }
-
- public void setNumberOfContainers(long numberOfContainers) {
- this.numberOfContainers = numberOfContainers;
- }
-
- public long getNumberOfObjects() {
- return numberOfObjects;
- }
-
- public void setNumberOfObjects(long numberOfObjects) {
- this.numberOfObjects = numberOfObjects;
- }
-
- public List<Folder> getContainers() {
- return containers;
- }
-
- public Date getCurrentLogin() {
- return currentLogin;
- }
-
- public void setCurrentLogin(Date currentLogin) {
- this.currentLogin = currentLogin;
- }
-
- public void populate(String owner, Response response) {
- DateTimeFormat df = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822);
- for (Header h : response.getHeaders()) {
- if (h != null) {
- String name = h.getName();
- if (name.startsWith("X-Account-Group-")) {
- String groupName = URL.decodePathSegment(name.substring("X-Account-Group-".length())).trim().toLowerCase();
- Group g = new Group(groupName);
- String[] members = h.getValue().split(",");
- for (String s : members)
- g.addMember(s.trim());
- groups.add(g);
- }
- else if (name.equals("X-Account-Container-Count")) {
- numberOfContainers = Long.valueOf(h.getValue());
- }
- else if (name.equals("X-Account-Object-Count")) {
- numberOfObjects = Long.valueOf(h.getValue());
- }
- else if (name.equals("X-Account-Bytes-Used")) {
- bytesUsed = Long.valueOf(h.getValue());
- }
- else if (name.equals("X-Account-Policy-Quota")) {
- quota = Long.valueOf(h.getValue());
- }
- else if (name.equals("X-Account-Last-Login")) {
- lastLogin = df.parse(h.getValue());
- }
- else if (name.equals("Last-Modified")) {
- lastModified = df.parse(h.getValue());
- }
- }
- }
-
- if (response.getText() != null && response.getText().length() > 0) {
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array = json.isArray();
- if (array != null) {
- for (int i=0; i<array.size(); i++) {
- JSONObject o = array.get(i).isObject();
- if (o != null) {
- Folder f = new Folder();
- f.populate(null, o, owner, null);
- containers.add(f);
- }
- }
- }
- }
- }
-
- public static AccountResource createFromResponse(String owner, Response response, AccountResource result) {
- AccountResource a;
- if (result == null)
- a = new AccountResource();
- else
- a = result;
- a.populate(owner, response);
- return a;
- }
-
- private String getSize(Long size, Double division){
- Double res = Double.valueOf(size.toString())/division;
- NumberFormat nf = NumberFormat.getFormat("######.#");
- return nf.format(res);
- }
-
- public String getFileSizeAsString() {
- if (bytesUsed < 1024)
- return String.valueOf(bytesUsed) + "B";
- else if (bytesUsed < 1024*1024)
- return getSize(bytesUsed, 1024D) + "KB";
- else if (bytesUsed < 1024*1024*1024)
- return getSize(bytesUsed,(1024D*1024D)) + "MB";
- return getSize(bytesUsed , (1024D*1024D*1024D)) + "GB";
- }
-
- public String getQuotaAsString() {
- if (quota < 1024)
- return String.valueOf(quota) + "B";
- else if (quota < 1024 * 1024)
- return getSize(quota, 1024D) + "KB";
- else if (quota < 1024 * 1024 * 1024)
- return getSize(quota,(1024D * 1024D)) + "MB";
- return getSize(quota , (1024D * 1024D * 1024D)) + "GB";
- }
-
- public List<Group> getGroups() {
- return groups;
- }
-
- public boolean hasHomeContainer() {
- for (Folder f : containers)
- if (f.getName().equals(Pithos.HOME_CONTAINER))
- return true;
- return false;
- }
-
- public boolean hasTrashContainer() {
- for (Folder f : containers)
- if (f.getName().equals(Pithos.TRASH_CONTAINER))
- return true;
- return false;
- }
-
- public void addGroup(Group newGroup) {
- groups.add(newGroup);
- }
-
- public void removeGroup(Group group) {
- groups.remove(group);
- }
-
- public Folder getTrash() {
- for (Folder c : containers) {
- if (c.getName().equals(Pithos.TRASH_CONTAINER))
- return c;
- }
- return null;
- }
-
- public double getUsedPercentage() {
- if (quota == 0)
- return 0;
- return ((double) bytesUsed) / quota;
- }
-
- public Folder getPithos() {
- for (Folder f : containers)
- if (f.getName().equals(Pithos.HOME_CONTAINER))
- return f;
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.http.client.Header;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.json.client.JSONObject;
-
-public class File extends Resource {
- private String name;
-
- private String hash;
-
- private int version;
-
- private long bytes;
-
- private String contentType;
-
- private Date lastModified;
-
- private String modifiedBy;
-
- private Date versionTimestamp;
-
- private String path;
-
- private String owner;
-
- private String container;
-
- private Folder parent;
-
- private Set<String> tags = new HashSet<String>();
-
- private boolean published;
-
- private String publicUri;
-
- private Map<String, Boolean[]> permissions = new HashMap<String, Boolean[]>();
-
- private String inheritedPermissionsFrom;
-
- public String getContentType() {
- return contentType;
- }
-
- public String getHash() {
- return hash;
- }
-
- @Override
- public Date getLastModified() {
- return lastModified;
- }
-
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- public String getName() {
- return name;
- }
-
- public int getVersion() {
- return version;
- }
-
- public Date getVersionTimestamp() {
- return versionTimestamp;
- }
-
- public String getUri() {
- return "/" + container + "/" + path;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public String getPath() {
- return path;
- }
-
- public long getBytes() {
- return bytes;
- }
-
- public String getSizeAsString() {
- NumberFormat nf = NumberFormat.getFormat("######.#");
- if (bytes < 1024)
- return String.valueOf(bytes) + " B";
- else if (bytes < 1024 * 1024)
- return nf.format(Double.valueOf(bytes)/(1024)) + " KB";
- else if (bytes < 1024 * 1024 * 1024)
- return nf.format(Double.valueOf(bytes)/(1024 * 1024)) + " MB";
- return nf.format(Double.valueOf(bytes)/(1024 * 1024 * 1024)) + " GB";
- }
-
- public boolean isShared() {
- return !permissions.isEmpty();
- }
-
- public void populate(Folder _parent, JSONObject o, String _owner, String _container) {
- this.parent = _parent;
- path = unmarshallString(o, "name");
- if (path.contains("/"))
- name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
- else
- name = path;
- this.owner = _owner;
- hash = unmarshallString(o, "hash");
- bytes = unmarshallLong(o, "bytes");
- version = unmarshallInt(o, "version");
- contentType = unmarshallString(o, "content_type");
- lastModified = unmarshallDate(o, "last_modified");
- modifiedBy = unmarshallString(o, "modified_by");
- versionTimestamp = unmarshallDate(o, "version_timestamp");
- published = o.containsKey("x_object_public") ? true : false;
- publicUri = unmarshallString(o, "x_object_public");
- this.container = _container;
-
- inheritedPermissionsFrom = unmarshallString(o, "x_object_shared_by");
- String rawPermissions = unmarshallString(o, "x_object_sharing");
- if (rawPermissions != null)
- parsePermissions(rawPermissions);
-
- for (String key : o.keySet())
- if (key.startsWith("x_object_meta_"))
- tags.add(URL.decodePathSegment(key.substring("x_object_meta_".length())).trim().toLowerCase());
-
-
- }
-
- private void parsePermissions(String rawPermissions) {
- String[] readwrite = rawPermissions.split(";");
- for (String s : readwrite) {
- String[] part = s.split("=");
- String perm = part[0].trim();
- String[] users = part[1].split(",");
- for (String u : users) {
- String user = u.trim();
- Boolean[] userPerm = permissions.get(u);
- if (userPerm == null) {
- userPerm = new Boolean[2];
- permissions.put(user, userPerm);
- }
- if (perm.equals("read")) {
- userPerm[0] = Boolean.TRUE;
- }
- else if (perm.equals("write")) {
- userPerm[1] = Boolean.TRUE;
- }
- }
- }
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof File) {
- File o = (File) other;
- return name.equals(o.getName());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
- public String getContainer() {
- return container;
- }
-
- public static File createFromResponse(String owner, Response response, File result) {
- result.populate(owner, response);
- return result;
- }
-
- private void populate(String _owner, Response response) {
- this.owner = _owner;
- for (Header h : response.getHeaders()) {
- String header = h.getName();
- if (header.startsWith("X-Object-Meta-"))
- tags.add(URL.decodePathSegment(header.substring("X-Object-Meta-".length())).trim().toLowerCase());
- else if (header.equals("X-Object-Sharing")) {
- String rawPermissions = h.getValue();
- parsePermissions(rawPermissions);
- }
- else if (header.equals("X-Object-Shared-By")) {
- inheritedPermissionsFrom = h.getValue().trim();
- }
- }
- }
-
- public Folder getParent() {
- return parent;
- }
-
- public Set<String> getTags() {
- return tags;
- }
-
- public boolean isPublished() {
- return published;
- }
-
- public String getPublicUri() {
- return publicUri;
- }
-
- public Map<String, Boolean[]> getPermissions() {
- return permissions;
- }
-
- public String getInheritedPermissionsFrom() {
- return inheritedPermissionsFrom;
- }
-}
+++ /dev/null
-package gr.grnet.pithos.web.client.foldertree;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.http.client.Response;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONNumber;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONString;
-import com.google.gwt.json.client.JSONValue;
-
-public class FileVersions extends Resource {
- private List<Version> versions;
-
- public List<Version> getVersions() {
- return versions;
- }
-
- public static FileVersions createFromResponse(Response response) {
- FileVersions res = new FileVersions();
- res.populate(response);
- return res;
- }
-
- private void populate(Response response) {
- versions = new ArrayList<Version>();
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array = json.isObject().get("versions").isArray();
- if (array != null) {
- for (int i=0; i<array.size(); i++) {
- JSONArray o = array.get(i).isArray();
- if (o != null) {
- int num = (int) o.get(0).isNumber().doubleValue();
- Date date = null;
- JSONNumber n = o.get(1).isNumber();
- if (n != null)
- date = new Date((long) (n.doubleValue() * 1000)); //Convert to millis
- else {
- JSONString s = o.get(1).isString();
- if (s != null)
- date = new Date((long) (Double.parseDouble(s.stringValue()) * 1000));
- }
- Version v = new Version(num, date);
- versions.add(v);
- }
- }
- }
- }
-
- @Override
- public Date getLastModified() {
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import gr.grnet.pithos.web.client.Pithos;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONValue;
-
-public class Folder extends Resource {
- /*
- * The name of the folder. If the folder is a container this is its name. If it is a virtual folder this is the
- * last part of its path
- */
- private String name = null;
-
- private Date lastModified = null;
-
- private long bytesUsed = 0;
-
- private Folder parent = null;
-
- private Set<Folder> subfolders = new LinkedHashSet<Folder>();
- /*
- * The name of the container that this folder belongs to. If this folder is container, this field equals name
- */
- private String container = null;
-
- /*
- * This is the full path of the folder (prefix is a misnomer but it was named so because this is used as a prefix=
- * parameter in the request that fetches its children). If the folder is a cointainer this is empty string
- */
- private String prefix = "";
-
- private Set<File> files = new LinkedHashSet<File>();
-
- private Set<String> tags = new LinkedHashSet<String>();
-
- private String owner;
-
- private Map<String, Boolean[]> permissions = new HashMap<String, Boolean[]>();
-
- private String inheritedPermissionsFrom;
-
- public Folder() {};
-
- public Folder(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public Date getLastModified() {
- return lastModified;
- }
-
- public long getBytesUsed() {
- return bytesUsed;
- }
-
- public Set<Folder> getSubfolders() {
- return subfolders;
- }
-
- public void setSubfolders(Set<Folder> subfolders) {
- this.subfolders = subfolders;
- }
-
- public String getContainer() {
- return container;
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- private void parsePermissions(String rawPermissions) {
- String[] readwrite = rawPermissions.split(";");
- for (String s : readwrite) {
- String[] part = s.split("=");
- String perm = part[0].trim();
- String[] users = part[1].split(",");
- for (String u : users) {
- String user = u.trim();
- Boolean[] userPerm = permissions.get(u);
- if (userPerm == null) {
- userPerm = new Boolean[2];
- permissions.put(user, userPerm);
- }
- if (perm.equals("read")) {
- userPerm[0] = Boolean.TRUE;
- }
- else if (perm.equals("write")) {
- userPerm[1] = Boolean.TRUE;
- }
- }
- }
- }
-
- public void populate(String _owner, Response response) {
- this.owner = _owner;
- String header = response.getHeader("Last-Modified");
- if (header != null)
- try {
- lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header);
- } catch (IllegalArgumentException e) {
- GWT.log("Last-Modified will be set to null", e);
- lastModified = null;
- }
-
- header = response.getHeader("X-Container-Bytes-Used");
- if (header != null && header.length() > 0)
- bytesUsed = Long.valueOf(header);
-
- header = response.getHeader("X-Container-Object-Meta");
- if (header != null && header.length() > 0) {
- for (String t : header.split(",")) {
- tags.add(URL.decodePathSegment(t.toLowerCase()).trim());
- }
- }
-
- subfolders.clear(); //This is necessary in case we update a pre-existing Folder so that stale subfolders won't show up
- files.clear();
- JSONValue json = JSONParser.parseStrict(response.getText());
- JSONArray array = json.isArray();
- if (array != null) {
- for (int i=0; i<array.size(); i++) {
- JSONObject o = array.get(i).isObject();
- if (o != null) {
- String contentType = unmarshallString(o, "content_type");
- if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
- Folder f = new Folder();
- f.populate(this, o, _owner, container);
- subfolders.add(f);
- }
- else {
- File file = new File();
- file.populate(this, o, _owner, container);
- files.add(file);
- }
- }
- }
- }
- }
-
- public void populate(Folder _parent, JSONObject o, String _owner, String aContainer) {
- this.parent = _parent;
- String path = null;
- if (o.containsKey("subdir")) {
- path = unmarshallString(o, "subdir");
- }
- else {
- path = unmarshallString(o, "name");
- lastModified = unmarshallDate(o, "last_modified");
- }
- //Strip the last / if exists in order to determine the name, but remember to put it back
- boolean endsWithSlash = false;
- if (path.endsWith("/")) {
- path = path.substring(0, path.length() - 1);
- endsWithSlash = true;
- }
- if (path.contains("/"))
- name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
- else
- name = path;
- if (endsWithSlash) {
- path += "/";
- name += "/";
- }
- if (aContainer != null) {
- container = aContainer;
- prefix = path;
- }
- else {
- container = name;
- prefix = "";
- }
- this.owner = _owner;
-
- inheritedPermissionsFrom = unmarshallString(o, "x_object_shared_by");
- String rawPermissions = unmarshallString(o, "x_object_sharing");
- if (rawPermissions != null)
- parsePermissions(rawPermissions);
- }
-
- public static Folder createFromResponse(String owner, Response response, Folder result) {
- Folder f = null;
- if (result == null)
- f = new Folder();
- else
- f = result;
-
- f.populate(owner, response);
- return f;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof Folder) {
- Folder o = (Folder) other;
- return getUri().equals(o.getUri());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return getUri().hashCode();
- }
-
- public Set<File> getFiles() {
- return files;
- }
-
- public Folder getParent() {
- return parent;
- }
-
- public String getUri() {
- return "/" + container + (prefix.length() == 0 ? "" : "/" + prefix);
- }
-
- public boolean isContainer() {
- return parent == null;
- }
-
- public void setContainer(String container) {
- this.container = container;
- }
-
- public Set<String> getTags() {
- return tags;
- }
-
- public String getInheritedPermissionsFrom() {
- return inheritedPermissionsFrom;
- }
-
- public Map<String, Boolean[]> getPermissions() {
- return permissions;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public boolean existChildrenPermissions() {
- for (File f : files)
- if (!f.getPermissions().isEmpty() && f.getInheritedPermissionsFrom() == null)
- return true;
-
- for (Folder fo : subfolders)
- if ((!fo.getPermissions().isEmpty() && fo.getInheritedPermissionsFrom() == null) || fo.existChildrenPermissions())
- return true;
- return false;
- }
-
- public boolean isShared() {
- return !permissions.isEmpty();
- }
-
- /**
- * I am THE trash
- *
- * @return
- */
- public boolean isTrash() {
- return isContainer() && name.equals(Pithos.TRASH_CONTAINER);
- }
-
- /**
- * I am IN THE trash
- *
- * @return
- */
- public boolean isInTrash() {
- return container.equals(Pithos.TRASH_CONTAINER);
- }
-
- public boolean isHome() {
- return isContainer() && name.equals(Pithos.HOME_CONTAINER);
- }
-
- public boolean contains(Folder folder) {
- for (Folder f : subfolders)
- if (f.equals(folder) || f.contains(folder))
- return true;
- return false;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.TreeView;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.cellview.client.TreeNode;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Tree;
-
-public class FolderTreeView extends Composite implements TreeView {
-
- public boolean isFolderOpen(Folder folder) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
- return isFolderOpen(root, folder);
- }
-
- private boolean isFolderOpen(TreeNode node, Folder folder) {
- for (int i=0; i<node.getChildCount(); i++) {
- if (folder.equals(node.getChildValue(i))) {
- return node.isChildOpen(i);
- }
- else {
- if (node.isChildOpen(i)) {
- TreeNode n = node.setChildOpen(i, true);
- return isFolderOpen(n, folder);
- }
- }
- }
- return false;
- }
-
- public void openFolder(Folder folder) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
- openFolder(root, folder);
- }
-
- private void openFolder(TreeNode node, Folder folder) {
- for (int i=0; i<node.getChildCount(); i++) {
- if (folder.equals(node.getChildValue(i))) {
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- break;
- }
- else {
- if (node.isChildOpen(i)) {
- TreeNode n = node.setChildOpen(i, true);
- openFolder(n, folder);
- break;
- }
- }
- }
- }
-
- static interface BasicResources extends CellTree.Resources {
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
- ImageResource cellTreeClosedItem();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
- ImageResource cellTreeLoading();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
- ImageResource cellTreeOpenItem();
-
- @Override
- @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
- CellTree.Style cellTreeStyle();
- }
-
- public static interface Images extends Tree.Resources, FolderContextMenu.Images {
-
- @Source("gr/grnet/pithos/resources/home22.png")
- ImageResource home();
-
- @Source("gr/grnet/pithos/resources/folder22.png")
- public ImageResource folderYellow();
-
- @Source("gr/grnet/pithos/resources/mimetypes/document.png")
- ImageResource document();
-
- @Source("gr/grnet/pithos/resources/othersshared.png")
- ImageResource othersShared();
-
- @Source("gr/grnet/pithos/resources/myshared22.png")
- ImageResource myShared();
-
- @Source("gr/grnet/pithos/resources/folder_user.png")
- ImageResource sharedFolder();
-
- @Source("gr/grnet/pithos/resources/trash.png")
- ImageResource trash();
- }
-
- static Images images = GWT.create(Images.class);
-
- static interface Templates extends SafeHtmlTemplates {
- public Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<span style='vertical-align: middle;'>{0}</span>")
- public SafeHtml nameSpan(String name);
-
- @Template("<span class='pithos-folderLabel'>{0}</span>")
- public SafeHtml imageSpan(String name);
- }
-
- private FolderTreeViewModel model;
-
- public FolderTreeView(FolderTreeViewModel viewModel) {
- this.model = viewModel;
- /*
- * Create the tree using the model. We use <code>null</code> as the default
- * value of the root node. The default value will be passed to
- * CustomTreeModel#getNodeInfo();
- */
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
- tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
-
-
- @Override
- public Folder getSelection() {
- return model.getSelection();
- }
-
- public void updateFolder(Folder folder, boolean showfiles, Command callback) {
- model.updateFolder(folder, showfiles, callback);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.FolderTreeView.Templates;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.UIObject;
-import com.google.gwt.view.client.AsyncDataProvider;
-import com.google.gwt.view.client.HasData;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel;
-
-public class FolderTreeViewModel implements TreeViewModel {
-
- protected Pithos app;
-
- private Cell<Folder> folderCell = new AbstractCell<Folder>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) {
- String html;
- SafeHtml name;
- if (folder.isHome()) {
- html = AbstractImagePrototype.create(FolderTreeView.images.home()).getHTML();
- name = Templates.INSTANCE.nameSpan("Home");
- }
- else if (folder.isTrash()) {
- html = AbstractImagePrototype.create(FolderTreeView.images.trash()).getHTML();
- name = Templates.INSTANCE.nameSpan("Trash");
- }
- else {
- html = AbstractImagePrototype.create(FolderTreeView.images.folderYellow()).getHTML();
- name = Templates.INSTANCE.nameSpan(folder.getName());
- }
- safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant(" ");
- safeHtmlBuilder.append(name);
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Cell.Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Folder folder, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<Folder> valueUpdater) {
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- FolderTreeViewModel.this.selectionModel.setSelected(folder, true);
- FolderContextMenu menu = new FolderContextMenu(app, FolderTreeView.images, app.getSelectedTree(), folder);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- protected ListDataProvider<Folder> rootDataProvider = new ListDataProvider<Folder>();
-
- private Map<Folder, ListDataProvider<Folder>> dataProviderMap = new HashMap<Folder, ListDataProvider<Folder>>();
-
- protected SingleSelectionModel<Folder> selectionModel;
-
- public FolderTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
- app = _app;
- this.selectionModel = selectionModel;
- }
-
- @Override
- public <T> NodeInfo<?> getNodeInfo(T value) {
- if (value == null) {
- Folder f = new Folder("Loading ...");
- rootDataProvider.getList().add(f);
- return new DefaultNodeInfo<Folder>(rootDataProvider, folderCell, selectionModel, null);
- }
- final Folder f = (Folder) value;
- if (dataProviderMap.get(f) == null) {
- dataProviderMap.put(f, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f);
- //This prevents the loading indicator
-// dataProvider.getList().clear();
-// dataProvider.getList().addAll(f.getSubfolders());
- fetchFolder(f, dataProvider, false, null);
- return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
- }
-
- @Override
- public boolean isLeaf(Object o) {
- if (o instanceof Folder) {
- Folder f = (Folder) o;
- return f.getSubfolders().isEmpty();
- }
- return false;
- }
-
- protected void fetchFolder(final Iterator<Folder> iter, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
-
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
- @Override
- public void onSuccess(@SuppressWarnings("unused") Folder _result) {
- fetchFolder(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
- else if (callback != null)
- callback.execute();
- }
-
- public void initialize(final AccountResource account, final Command callback) {
- Iterator<Folder> iter = account.getContainers().iterator();
- fetchFolder(iter, new Command() {
- @Override
- public void execute() {
- rootDataProvider.getList().clear();
- rootDataProvider.getList().addAll(account.getContainers());
- selectionModel.setSelected(rootDataProvider.getList().get(0), true);
- if (callback != null)
- callback.execute();
- }
- });
- }
-
- public Folder getSelection() {
- return selectionModel.getSelectedObject();
- }
-
- public void updateFolder(final Folder folder, boolean showfiles, final Command callback) {
- if (dataProviderMap.get(folder) == null) {
- dataProviderMap.put(folder, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder);
- fetchFolder(folder, dataProvider, showfiles, new Command() {
-
- @Override
- public void execute() {
- app.getFolderTreeView().openFolder(folder);
- if (callback != null)
- callback.execute();
- }
- });
- }
-
- public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles, final Command callback) {
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
- @Override
- public void onSuccess(final Folder _result) {
- if (showfiles)
- app.showFiles(_result);
- Iterator<Folder> iter = _result.getSubfolders().iterator();
- fetchFolder(iter, new Command() {
- @Override
- public void execute() {
- dataProvider.getList().clear();
- dataProvider.getList().addAll(_result.getSubfolders());
-// app.getFolderTreeView().updateChildren(f);
- if (callback != null)
- callback.execute();
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-public class ObjectResource {
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.google.gwt.json.client.JSONNumber;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONString;
-
-import gr.grnet.pithos.web.client.Invitations;
-import gr.grnet.pithos.web.client.SharingUsers;
-
-import java.util.Date;
-
-public abstract class Resource {
-
- protected static String unmarshallString(JSONObject obj, String key){
- if(obj.get(key) != null) {
- JSONString s = obj.get(key).isString();
- if(s != null)
- return s.stringValue();
- }
- return null;
- }
-
- protected static int unmarshallInt(JSONObject obj, String key){
- if(obj.get(key) != null)
- if(obj.get(key).isNumber() != null)
- return (int) obj.get(key).isNumber().doubleValue();
- return -1;
- }
-
- protected static long unmarshallLong(JSONObject obj, String key){
- if(obj.get(key) != null) {
- JSONNumber value = obj.get(key).isNumber();
- if(value != null)
- return (long) value.doubleValue();
- }
- return -1;
- }
-
- protected static boolean unmarshallBoolean(JSONObject obj, String key){
- if(obj.get(key) != null)
- if(obj.get(key).isBoolean() != null)
- return obj.get(key).isBoolean().booleanValue();
- return false;
- }
-
- protected static Date unmarshallDate(JSONObject obj, String key){
- if(obj.get(key) != null) {
- JSONString s = obj.get(key).isString();
- if (s != null)
- try {
- return DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(s.stringValue());
- } catch (IllegalArgumentException e) {
- GWT.log("", e);
- }
- }
- return null;
- }
-
- public static native String getDate(Long ms)/*-{
- return (new Date(ms)).toUTCString();
- }-*/;
-
- @SuppressWarnings("unchecked")
- public static <T> T createFromResponse(Class<T> aClass, String owner, Response response, T result) {
- T result1 = null;
- if (aClass.equals(AccountResource.class)) {
- result1 = (T) AccountResource.createFromResponse(owner, response, (AccountResource) result);
- }
- else if (aClass.equals(Folder.class)) {
- result1 = (T) Folder.createFromResponse(owner, response, (Folder) result);
- }
- else if (aClass.equals(File.class)) {
- result1 = (T) File.createFromResponse(owner, response, (File) result);
- }
- else if (aClass.equals(SharingUsers.class)) {
- result1 = (T) SharingUsers.createFromResponse(response, (SharingUsers) result);
- }
- else if (aClass.equals(FileVersions.class)) {
- result1 = (T) FileVersions.createFromResponse(response);
- }
- else if (aClass.equals(Invitations.class)) {
- result1 = (T) Invitations.createFromResponse(response);
- }
- return result1;
- }
-
- public abstract Date getLastModified();
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.foldertree;
-
-public class SubDirResource {
-}
+++ /dev/null
-package gr.grnet.pithos.web.client.foldertree;
-
-import java.util.Date;
-
-public class Version {
- private int version;
-
- private Date date;
-
- public Version(int v, Date d) {
- version = v;
- date = d;
- }
-
- public int getVersion() {
- return version;
- }
-
- public Date getDate() {
- return date;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.grouptree;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Group {
- private String name;
-
- private List<String> members = new ArrayList<String>();
-
- public Group(String _name) {
- name = _name;
- }
-
- public List<String> getMembers() {
- return members;
- }
-
- public String getName() {
- return name;
- }
-
- public void addMember(String user) {
- members.add(user);
- }
-
- public void removeMember(String username) {
- members.remove(username);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.grouptree;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.commands.AddUserCommand;
-import gr.grnet.pithos.web.client.commands.CreateGroupCommand;
-import gr.grnet.pithos.web.client.commands.DeleteGroupCommand;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeView.Images;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'Folder Context' menu implementation.
- */
-public class GroupContextMenu extends PopupPanel {
-
- /**
- * The widget's images.
- */
- private final GroupTreeView.Images images;
-
- /**
- * The widget's constructor.
- *
- * @param newImages the image bundle passed on by the parent object
- */
- public GroupContextMenu(Pithos app, final Images newImages, Group group) {
- // The popup's constructor's argument is a boolean specifying that it
- // auto-close itself when the user clicks outside of it.
- super(true);
- setAnimationEnabled(true);
- images = newImages;
- MenuBar contextMenu = new MenuBar(true);
-
- if (group != null) {
- MenuItem addUser = new MenuItem("<span>" + AbstractImagePrototype.create(images.user()).getHTML() + " Add User</span>", true, new AddUserCommand(app, this, group));
- contextMenu.addItem(addUser);
-
- MenuItem deleteGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete Group</span>", true, new DeleteGroupCommand(app, this, group));
- contextMenu.addItem(deleteGroup);
- }
- else {
- MenuItem createGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.group()).getHTML() + " Create Group</span>", true, new CreateGroupCommand(app, this));
- contextMenu.addItem(createGroup);
- }
-
- add(contextMenu);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.grouptree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.TreeView;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.cellview.client.TreeNode;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Tree;
-
-public class GroupTreeView extends Composite implements TreeView {
-
- public void updateChildren(Group group) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
- if (group != null)
- updateChildren(root, group);
- else {
- root.setChildOpen(0, false, true);
- root.setChildOpen(0, true, true);
- }
- }
-
- private void updateChildren(TreeNode node, Group group) {
- for (int i=0; i<node.getChildCount(); i++) {
- if (group.equals(node.getChildValue(i))) {
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- }
- else {
- if (node.isChildOpen(i)) {
- TreeNode n = node.setChildOpen(i, true);
- updateChildren(n, group);
- }
- }
- }
- }
-
- static interface BasicResources extends CellTree.Resources {
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
- ImageResource cellTreeClosedItem();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
- ImageResource cellTreeLoading();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
- ImageResource cellTreeOpenItem();
-
- @Override
- @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
- CellTree.Style cellTreeStyle();
- }
-
- public static interface Images extends Tree.Resources, FolderContextMenu.Images {
-
- @Source("gr/grnet/pithos/resources/groups22.png")
- ImageResource groups();
-
- @Source("gr/grnet/pithos/resources/groups22.png")
- public ImageResource group();
-
- @Source("gr/grnet/pithos/resources/edit_user.png")
- ImageResource user();
- }
-
- static Images images = GWT.create(Images.class);
-
- static interface Templates extends SafeHtmlTemplates {
- public Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<span>{0}</span>")
- public SafeHtml nameSpan(String name);
- }
-
- private GroupTreeViewModel model;
-
- public GroupTreeView(GroupTreeViewModel viewModel) {
- this.model = viewModel;
- /*
- * Create the tree using the model. We use <code>null</code> as the default
- * value of the root node. The default value will be passed to
- * CustomTreeModel#getNodeInfo();
- */
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
- tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
-
- public void updateGroupNode(Group group) {
- model.updateGroupNode(group);
- updateChildren(group);
- }
-
- @Override
- public Folder getSelection() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getSelected() {
- return model.getSelectedObject();
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.grouptree;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeView.Templates;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel;
-
-public class GroupTreeViewModel implements TreeViewModel {
-
- protected Pithos app;
-
- private ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
-
- private Cell<String> rootCell = new AbstractCell<String>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, String value, SafeHtmlBuilder sb) {
- String html = AbstractImagePrototype.create(GroupTreeView.images.groups()).getHTML();
- sb.appendHtmlConstant(html).appendHtmlConstant(" ");
- sb.append(Templates.INSTANCE.nameSpan(value));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Cell.Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, String s, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<String> valueUpdater) {
- GroupTreeViewModel.this.rootSelectionModel.setSelected(s, true);
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- GroupContextMenu menu = new GroupContextMenu(app, GroupTreeView.images, null);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- private Cell<Group> groupCell = new AbstractCell<Group>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, Group value, SafeHtmlBuilder sb) {
- String html = AbstractImagePrototype.create(GroupTreeView.images.group()).getHTML();
- sb.appendHtmlConstant(html).appendHtmlConstant(" ");
- sb.append(Templates.INSTANCE.nameSpan(value.getName()));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Cell.Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Group group, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<Group> valueUpdater) {
- GroupTreeViewModel.this.groupSelectionModel.setSelected(group, true);
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- GroupContextMenu menu = new GroupContextMenu(app, GroupTreeView.images, group);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- private Cell<User> userCell = new AbstractCell<User>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, User value, SafeHtmlBuilder sb) {
- String html = AbstractImagePrototype.create(GroupTreeView.images.user()).getHTML();
- sb.appendHtmlConstant(html).appendHtmlConstant(" ");
- sb.append(Templates.INSTANCE.nameSpan(value.getName()));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Cell.Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, User user, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<User> valueUpdater) {
- GroupTreeViewModel.this.userSelectionModel.setSelected(user, true);
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- UserContextMenu menu = new UserContextMenu(app, GroupTreeView.images, user);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- protected ListDataProvider<Group> groupsDataProvider = new ListDataProvider<Group>();
-
- protected Map<Group, ListDataProvider<User>> userDataProviderMap = new HashMap<Group, ListDataProvider<User>>();
-
- protected Map<String, Set<File>> sharedFiles = new HashMap<String, Set<File>>();
-
- SingleSelectionModel<String> rootSelectionModel;
- SingleSelectionModel<Group> groupSelectionModel;
- SingleSelectionModel<User> userSelectionModel;
-
- public GroupTreeViewModel(Pithos _app) {
- app = _app;
- rootSelectionModel = new SingleSelectionModel<String>();
- app.addSelectionModel(rootSelectionModel);
- rootSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
-
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if (rootSelectionModel.getSelectedObject() != null) {
- app.deselectOthers(app.getGroupTreeView(), rootSelectionModel);
- app.showFiles(new HashSet<File>());
- }
- }
- });
-
- groupSelectionModel = new SingleSelectionModel<Group>();
- app.addSelectionModel(groupSelectionModel);
- groupSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
-
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if (groupSelectionModel.getSelectedObject() != null) {
- app.deselectOthers(app.getGroupTreeView(), groupSelectionModel);
- app.showFiles(new HashSet<File>());
- }
- }
- });
-
- userSelectionModel = new SingleSelectionModel<User>();
- app.addSelectionModel(userSelectionModel);
- userSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
-
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if (userSelectionModel.getSelectedObject() != null) {
- app.deselectOthers(app.getGroupTreeView(), userSelectionModel);
- app.showFiles(new HashSet<File>());
- }
- }
- });
-}
-
- @Override
- public <T> NodeInfo<?> getNodeInfo(T value) {
- if (value == null) {
- rootDataProvider.getList().add("");
- return new DefaultNodeInfo<String>(rootDataProvider, rootCell, rootSelectionModel, null);
- }
- else if (value instanceof String) {
- groupsDataProvider.getList().clear();
- groupsDataProvider.getList().addAll(app.getAccount().getGroups());
- return new DefaultNodeInfo<Group>(groupsDataProvider, groupCell, groupSelectionModel, null);
- }
- else { //Group
- Group g = (Group) value;
- if (userDataProviderMap.get(g) == null) {
- userDataProviderMap.put(g, new ListDataProvider<User>());
- }
- final ListDataProvider<User> dataProvider = userDataProviderMap.get(g);
- dataProvider.getList().clear();
- for (String u : g.getMembers())
- dataProvider.getList().add(new User(u, g));
- return new DefaultNodeInfo<User>(dataProvider, userCell, userSelectionModel, null);
- }
- }
-
- @Override
- public boolean isLeaf(Object o) {
- if (o instanceof String) {
- return ((String) o).length() == 0 || app.getAccount().getGroups().isEmpty();
- }
- else if (o instanceof Group)
- return ((Group) o).getMembers().isEmpty();
- else if (o != null)
- return true;
- return false;
- }
-
- public void initialize() {
- rootDataProvider.getList().clear();
- rootDataProvider.getList().add("Groups");
- }
-
- public void updateGroupNode(Group group) {
- if (group == null) {
- groupsDataProvider.getList().clear();
- groupsDataProvider.getList().addAll(app.getAccount().getGroups());
- }
- else {
- if (userDataProviderMap.get(group) == null) {
- userDataProviderMap.put(group, new ListDataProvider<User>());
- }
- final ListDataProvider<User> dataProvider = userDataProviderMap.get(group);
- dataProvider.getList().clear();
- for (String u : group.getMembers())
- dataProvider.getList().add(new User(u, group));
- }
- }
-
- public Object getSelectedObject() {
- if (rootSelectionModel.getSelectedObject() != null)
- return rootSelectionModel.getSelectedObject();
- if (groupSelectionModel.getSelectedObject() != null)
- return groupSelectionModel.getSelectedObject();
- if (userSelectionModel.getSelectedObject() != null)
- return userSelectionModel.getSelectedObject();
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.grouptree;
-
-
-public class User {
- private String name;
-
- private Group group;
-
- public User(String _name, Group _group) {
- name = _name;
- group = _group;
- }
-
- public String getName() {
- return name;
- }
-
- public Group getGroup() {
- return group;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.grouptree;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.commands.RemoveUserCommand;
-import gr.grnet.pithos.web.client.grouptree.GroupTreeView.Images;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'Folder Context' menu implementation.
- */
-public class UserContextMenu extends PopupPanel {
-
- /**
- * The widget's images.
- */
- private final GroupTreeView.Images images;
-
- /**
- * The widget's constructor.
- *
- * @param newImages the image bundle passed on by the parent object
- */
- public UserContextMenu(Pithos app, final Images newImages, User user) {
- // The popup's constructor's argument is a boolean specifying that it
- // auto-close itself when the user clicks outside of it.
- super(true);
- setAnimationEnabled(true);
- images = newImages;
- MenuBar contextMenu = new MenuBar(true);
-
- MenuItem removeUser = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Remove User</span>", true, new RemoveUserCommand(app, this, user));
- contextMenu.addItem(removeUser);
-
- add(contextMenu);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.mysharedtree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.TreeView;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.cellview.client.TreeNode;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Tree;
-
-public class MysharedTreeView extends Composite implements TreeView {
-
- public void updateChildren(Folder folder) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
- updateChildren(root, folder);
- }
-
- private void updateChildren(TreeNode node, Folder folder) {
- for (int i=0; i<node.getChildCount(); i++) {
- if (node.isChildOpen(i)) {
- if (folder.equals(node.getChildValue(i))) {
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- }
- else {
- TreeNode n = node.setChildOpen(i, true);
- updateChildren(n, folder);
- }
- }
- }
- }
-
- static interface BasicResources extends CellTree.Resources {
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
- ImageResource cellTreeClosedItem();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
- ImageResource cellTreeLoading();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
- ImageResource cellTreeOpenItem();
-
- @Override
- @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
- CellTree.Style cellTreeStyle();
- }
-
- public static interface Images extends Tree.Resources, FolderContextMenu.Images {
-
- @Source("gr/grnet/pithos/resources/home22.png")
- ImageResource home();
-
- @Source("gr/grnet/pithos/resources/folder22.png")
- public ImageResource folderYellow();
-
- @Source("gr/grnet/pithos/resources/mimetypes/document.png")
- ImageResource document();
-
- @Source("gr/grnet/pithos/resources/othersshared.png")
- ImageResource othersShared();
-
- @Source("gr/grnet/pithos/resources/myshared22.png")
- ImageResource myShared();
-
- @Source("gr/grnet/pithos/resources/folder_user.png")
- ImageResource sharedFolder();
- }
-
- static Images images = GWT.create(Images.class);
-
- static interface Templates extends SafeHtmlTemplates {
- public Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<span>{0}</span>")
- public SafeHtml nameSpan(String name);
- }
-
- private MysharedTreeViewModel model;
-
- public MysharedTreeView(MysharedTreeViewModel viewModel) {
- this.model = viewModel;
- /*
- * Create the tree using the model. We use <code>null</code> as the default
- * value of the root node. The default value will be passed to
- * CustomTreeModel#getNodeInfo();
- */
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
- tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
-
-
- @Override
- public Folder getSelection() {
- return model.getSelection();
- }
-
- public void updateFolder(Folder folder, boolean showfiles) {
- model.updateFolder(folder, showfiles);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.mysharedtree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeView.Templates;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.cell.client.TextCell;
-import com.google.gwt.cell.client.ValueUpdater;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.text.shared.SafeHtmlRenderer;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SelectionChangeEvent.Handler;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel;
-
-public class MysharedTreeViewModel implements TreeViewModel {
-
- protected Pithos app;
-
- private Cell<Folder> folderCell = new AbstractCell<Folder>() {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) {
- String html = AbstractImagePrototype.create(MysharedTreeView.images.folderYellow()).getHTML();
- safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant(" ");
- safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName()));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Folder folder, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") ValueUpdater<Folder> valueUpdater) {
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- MysharedTreeViewModel.this.selectionModel.setSelected(folder, true);
- FolderContextMenu menu = new FolderContextMenu(app, MysharedTreeView.images, app.getSelectedTree(), folder);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- protected ListDataProvider<Folder> firstLevelDataProvider = new ListDataProvider<Folder>();
-
- private Map<Folder, ListDataProvider<Folder>> dataProviderMap = new HashMap<Folder, ListDataProvider<Folder>>();
-
- protected Set<File> sharedFiles = new HashSet<File>();
-
- protected SingleSelectionModel<Folder> selectionModel;
-
- public MysharedTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
- app = _app;
- this.selectionModel = selectionModel;
- }
-
- @Override
- public <T> NodeInfo<?> getNodeInfo(T value) {
- if (value == null) {
- ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
- rootDataProvider.getList().add("My Shared");
- final SingleSelectionModel<String> selectionModel2 = new SingleSelectionModel<String>();
- selectionModel2.addSelectionChangeHandler(new Handler() {
-
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (selectionModel2.getSelectedObject() != null) {
- app.deselectOthers(app.getMySharedTreeView(), selectionModel2);
- app.applyPermissions(null);
- fetchSharedFiles();
- }
- }
- });
- app.addSelectionModel(selectionModel2);
- return new DefaultNodeInfo<String>(rootDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
- @Override
- public SafeHtml render(String object) {
- SafeHtmlBuilder builder = new SafeHtmlBuilder();
- render(object, builder);
- return builder.toSafeHtml();
- }
-
- @Override
- public void render(String object, SafeHtmlBuilder builder) {
- String html = AbstractImagePrototype.create(MysharedTreeView.images.myShared()).getHTML();
- builder.appendHtmlConstant(html).appendHtmlConstant(" ");
- builder.append(MysharedTreeView.Templates.INSTANCE.nameSpan(object));
- }
- }), selectionModel2, null);
- }
- else if (value instanceof String) {
- fetchSharedContainers(null);
- return new DefaultNodeInfo<Folder>(firstLevelDataProvider, folderCell, selectionModel, null);
- }
- else {
- final Folder f = (Folder) value;
- if (dataProviderMap.get(f) == null) {
- dataProviderMap.put(f, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f);
- fetchFolder(f, dataProvider, false);
- return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
- }
- }
-
- protected void fetchSharedFiles() {
- final List<Folder> containers = app.getAccount().getContainers();
- final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
- Iterator<Folder> iter = containers.iterator();
- fetchFolder(iter, tempProvider, new Command() {
-
- @Override
- public void execute() {
- firstLevelDataProvider.getList().clear();
- firstLevelDataProvider.getList().addAll(tempProvider.getList());
- app.showFiles(sharedFiles);
- }
- });
- }
-
- private void fetchSharedContainers(final Command callback) {
- final List<Folder> containers = app.getAccount().getContainers();
- final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
- Iterator<Folder> iter = containers.iterator();
- fetchFolder(iter, tempProvider, new Command() {
-
- @Override
- public void execute() {
- firstLevelDataProvider.getList().clear();
- firstLevelDataProvider.getList().addAll(tempProvider.getList());
- if (callback != null)
- callback.execute();
- }
- });
- }
-
- @Override
- public boolean isLeaf(Object o) {
- if (o == null)
- return false;
- else if (o instanceof Folder) {
- Folder f = (Folder) o;
- return f.getSubfolders().isEmpty();
- }
- else {
- return firstLevelDataProvider.getList().isEmpty();
- }
- }
-
- protected void fetchFolder(final Iterator<Folder> iter, final ListDataProvider<Folder> dataProvider, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
-
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
- @Override
- public void onSuccess(Folder _result) {
- if (!_result.isShared()) {
- for (File file : _result.getFiles()) {
- if (file.isShared())
- sharedFiles.add(file);
- }
- Iterator<Folder> iter2 = _result.getSubfolders().iterator();
- fetchFolder(iter2, dataProvider, new Command() {
-
- @Override
- public void execute() {
- fetchFolder(iter, dataProvider, callback);
- }
- });
- }
- else {
- dataProvider.getList().add(_result);
- fetchFolder(iter, dataProvider, callback);
- }
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
- else if (callback != null)
- callback.execute();
- }
-
- public Folder getSelection() {
- return selectionModel.getSelectedObject();
- }
-
- public void updateFolder(Folder folder, boolean showfiles) {
- if (dataProviderMap.get(folder) == null) {
- dataProviderMap.put(folder, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder);
- fetchFolder(folder, dataProvider, showfiles);
- }
-
- public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles) {
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
- @Override
- public void onSuccess(final Folder _result) {
- if (showfiles)
- app.showFiles(_result);
- Iterator<Folder> iter = _result.getSubfolders().iterator();
- fetchFolder(iter, dataProvider, new Command() {
- @Override
- public void execute() {
- dataProvider.getList().clear();
- dataProvider.getList().addAll(_result.getSubfolders());
- app.getMySharedTreeView().updateChildren(f);
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-
- public void initialize(Command callback) {
- fetchSharedContainers(callback);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.othersharedtree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.TreeView;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.cellview.client.TreeNode;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Tree;
-
-public class OtherSharedTreeView extends Composite implements TreeView {
-
- public void updateChildren(Folder folder) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
- updateChildren(root, folder);
- }
-
- private void updateChildren(TreeNode node, Folder folder) {
- for (int i=0; i<node.getChildCount(); i++) {
- if (node.isChildOpen(i)) {
- if (folder.equals(node.getChildValue(i))) {
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- }
- else {
- TreeNode n = node.setChildOpen(i, true);
- updateChildren(n, folder);
- }
- }
- }
- }
-
- static interface BasicResources extends CellTree.Resources {
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
- ImageResource cellTreeClosedItem();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
- ImageResource cellTreeLoading();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
- ImageResource cellTreeOpenItem();
-
- @Override
- @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
- CellTree.Style cellTreeStyle();
- }
-
- public static interface Images extends Tree.Resources, FolderContextMenu.Images {
-
- @Source("gr/grnet/pithos/resources/home22.png")
- ImageResource home();
-
- @Source("gr/grnet/pithos/resources/folder22.png")
- public ImageResource folderYellow();
-
- @Source("gr/grnet/pithos/resources/mimetypes/document.png")
- ImageResource document();
-
- @Source("gr/grnet/pithos/resources/othersshared.png")
- ImageResource othersShared();
-
- @Source("gr/grnet/pithos/resources/myshared22.png")
- ImageResource myShared();
-
- @Source("gr/grnet/pithos/resources/folder_user.png")
- ImageResource sharedFolder();
-
- @Source("gr/grnet/pithos/resources/edit_user.png")
- ImageResource user();
- }
-
- static Images images = GWT.create(Images.class);
-
- static interface Templates extends SafeHtmlTemplates {
- public Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<span>{0}</span>")
- public SafeHtml nameSpan(String name);
- }
-
- private OtherSharedTreeViewModel model;
-
- public OtherSharedTreeView(OtherSharedTreeViewModel viewModel) {
- this.model = viewModel;
- /*
- * Create the tree using the model. We use <code>null</code> as the default
- * value of the root node. The default value will be passed to
- * CustomTreeModel#getNodeInfo();
- */
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
- tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
-
-
- @Override
- public Folder getSelection() {
- return model.getSelection();
- }
-
- public void updateFolder(Folder folder, boolean showfiles) {
- model.updateFolder(folder, showfiles);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.othersharedtree;
-
-import gr.grnet.pithos.web.client.FolderContextMenu;
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.SharingUsers;
-import gr.grnet.pithos.web.client.foldertree.AccountResource;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.othersharedtree.OtherSharedTreeView.Templates;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.cell.client.TextCell;
-import com.google.gwt.cell.client.ValueUpdater;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.text.shared.SafeHtmlRenderer;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SelectionChangeEvent.Handler;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel;
-
-public class OtherSharedTreeViewModel implements TreeViewModel {
-
- private static final String treeTitle = "Other 's shared";
- protected Pithos app;
-
- private Cell<Folder> folderCell = new AbstractCell<Folder>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) {
- String html = AbstractImagePrototype.create(OtherSharedTreeView.images.folderYellow()).getHTML();
- safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant(" ");
- safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName()));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Folder folder, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") ValueUpdater<Folder> valueUpdater) {
- if (event.getType().equals(ContextMenuEvent.getType().getName())) {
- OtherSharedTreeViewModel.this.selectionModel.setSelected(folder, true);
- FolderContextMenu menu = new FolderContextMenu(app, OtherSharedTreeView.images, app.getSelectedTree(), folder);
- menu.setPopupPosition(event.getClientX(), event.getClientY());
- menu.show();
- }
- }
- };
-
- private ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
- protected ListDataProvider<String> userLevelDataProvider = new ListDataProvider<String>();
-
- protected Map<String, ListDataProvider<Folder>> userDataProviderMap = new HashMap<String, ListDataProvider<Folder>>();
- private Map<Folder, ListDataProvider<Folder>> dataProviderMap = new HashMap<Folder, ListDataProvider<Folder>>();
-
- protected Map<String, Set<File>> sharedFiles = new HashMap<String, Set<File>>();
-
- protected SingleSelectionModel<Folder> selectionModel;
-
- public OtherSharedTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
- app = _app;
- this.selectionModel = selectionModel;
- }
-
- @Override
- public <T> NodeInfo<?> getNodeInfo(T value) {
- if (value == null) {
- rootDataProvider.getList().add(treeTitle);
- final SingleSelectionModel<String> selectionModel2 = new SingleSelectionModel<String>();
- selectionModel2.addSelectionChangeHandler(new Handler() {
-
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (selectionModel2.getSelectedObject() != null) {
- app.deselectOthers(app.getOtherSharedTreeView(), selectionModel2);
- app.applyPermissions(null);
- app.showFiles(new HashSet<File>());
- }
- }
- });
- app.addSelectionModel(selectionModel2);
- return new DefaultNodeInfo<String>(rootDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
- @Override
- public SafeHtml render(String object) {
- SafeHtmlBuilder builder = new SafeHtmlBuilder();
- render(object, builder);
- return builder.toSafeHtml();
- }
-
- @Override
- public void render(String object, SafeHtmlBuilder builder) {
- String html = AbstractImagePrototype.create(OtherSharedTreeView.images.othersShared()).getHTML();
- builder.appendHtmlConstant(html).appendHtmlConstant(" ");
- builder.append(OtherSharedTreeView.Templates.INSTANCE.nameSpan(object));
- }
- }), selectionModel2, null);
- }
- else if (value instanceof String) {
- if (value.equals(treeTitle)) {
- fetchSharingUsers(null);
- final SingleSelectionModel<String> selectionModel3 = new SingleSelectionModel<String>();
- selectionModel3.addSelectionChangeHandler(new Handler() {
-
- @Override
- public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
- if (selectionModel3.getSelectedObject() != null) {
- app.deselectOthers(app.getOtherSharedTreeView(), selectionModel3);
- app.applyPermissions(null);
- String username = selectionModel3.getSelectedObject();
- if (userDataProviderMap.get(username) == null) {
- userDataProviderMap.put(username, new ListDataProvider<Folder>());
- }
- fetchSharedFiles(username, userDataProviderMap.get(username));
- }
- }
- });
- app.addSelectionModel(selectionModel3);
- return new DefaultNodeInfo<String>(userLevelDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
-
- @Override
- public SafeHtml render(String object) {
- SafeHtmlBuilder builder = new SafeHtmlBuilder();
- render(object, builder);
- return builder.toSafeHtml();
- }
-
- @Override
- public void render(String object, SafeHtmlBuilder builder) {
- String html = AbstractImagePrototype.create(OtherSharedTreeView.images.user()).getHTML();
- builder.appendHtmlConstant(html).appendHtmlConstant(" ");
- builder.append(OtherSharedTreeView.Templates.INSTANCE.nameSpan(object));
- }
- }), selectionModel3, null);
- }
- String username = (String) value;
- if (userDataProviderMap.get(username) == null) {
- userDataProviderMap.put(username, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = userDataProviderMap.get(username);
- fetchSharedContainers(username, dataProvider, null);
- return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
- }
- else {
- final Folder f = (Folder) value;
- if (dataProviderMap.get(f) == null) {
- dataProviderMap.put(f, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f);
- fetchFolder(f, dataProvider, false);
- return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
- }
- }
-
- private void fetchSharingUsers(final Command callback) {
- GetRequest<SharingUsers> getSharingUsers = new GetRequest<SharingUsers>(SharingUsers.class, app.getApiPath(), "", "?format=json") {
- @Override
- public void onSuccess(final SharingUsers _result) {
- userLevelDataProvider.getList().clear();
- userLevelDataProvider.getList().addAll(_result.getUsers());
- for (String name : _result.getUsers()) {
- sharedFiles.put(name, new HashSet<File>());
- }
- Iterator<String> iter = _result.getUsers().iterator();
- fetchSharedContainers(iter, callback);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getSharingUsers.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getSharingUsers);
- }
-
- protected void fetchSharedContainers(final Iterator<String> iter, final Command callback) {
- if (iter.hasNext()) {
- String username = iter.next();
- if (userDataProviderMap.get(username) == null) {
- userDataProviderMap.put(username, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = userDataProviderMap.get(username);
- fetchSharedContainers(username, dataProvider, new Command() {
-
- @Override
- public void execute() {
- fetchSharedContainers(iter, callback);
-
- }
- });
- }
- else
- if (callback != null)
- callback.execute();
- }
-
- @Override
- public boolean isLeaf(Object o) {
- if (o == null)
- return false;
- else if (o instanceof Folder) {
- Folder f = (Folder) o;
- return f.getSubfolders().isEmpty();
- }
- else {
- if (o.equals(treeTitle))
- return userLevelDataProvider.getList().isEmpty();
- ListDataProvider<Folder> dp = userDataProviderMap.get(o);
- if (dp != null)
- return dp.getList().isEmpty();
- return true;
- }
- }
-
- private void fetchSharedContainers(final String username, final ListDataProvider<Folder> dataProvider, final Command callback) {
- GetRequest<AccountResource> getUserSharedContainers = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), username, "?format=json") {
-
- @Override
- public void onSuccess(AccountResource _result) {
- final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
- Iterator<Folder> iter = _result.getContainers().iterator();
- fetchFolder(username, iter, tempProvider, new Command() {
-
- @Override
- public void execute() {
- dataProvider.getList().clear();
- dataProvider.getList().addAll(tempProvider.getList());
- if (callback != null)
- callback.execute();
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting account", t);
- if (t instanceof RestException)
- app.displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching user data: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getUserSharedContainers.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getUserSharedContainers);
- }
-
- protected void fetchSharedFiles(final String username, final ListDataProvider<Folder> dataProvider) {
- GetRequest<AccountResource> getUserSharedContainers = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), username, "?format=json") {
-
- @Override
- public void onSuccess(AccountResource _result) {
- final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
- Iterator<Folder> iter = _result.getContainers().iterator();
- fetchFolder(username, iter, tempProvider, new Command() {
-
- @Override
- public void execute() {
- dataProvider.getList().clear();
- dataProvider.getList().addAll(tempProvider.getList());
- app.showFiles(sharedFiles.get(username));
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting account", t);
- if (t instanceof RestException)
- app.displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching user data: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getUserSharedContainers.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getUserSharedContainers);
- }
-
- protected void fetchFolder(final String username, final Iterator<Folder> iter, final ListDataProvider<Folder> dataProvider, final Command callback) {
- if (iter.hasNext()) {
- final Folder f = iter.next();
-
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), username, path, f) {
- @Override
- public void onSuccess(Folder _result) {
- if (!_result.isShared()) {
- for (File file : _result.getFiles()) {
- if (file.isShared())
- sharedFiles.get(username).add(file);
- }
- Iterator<Folder> iter2 = _result.getSubfolders().iterator();
- fetchFolder(username, iter2, dataProvider, new Command() {
-
- @Override
- public void execute() {
- fetchFolder(username, iter, dataProvider, callback);
- }
- });
- }
- else {
- dataProvider.getList().add(_result);
- fetchFolder(username, iter, dataProvider, callback);
- }
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
- else if (callback != null)
- callback.execute();
- }
-
- public Folder getSelection() {
- return selectionModel.getSelectedObject();
- }
-
- public void updateFolder(Folder folder, boolean showfiles) {
- if (dataProviderMap.get(folder) == null) {
- dataProviderMap.put(folder, new ListDataProvider<Folder>());
- }
- final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder);
- fetchFolder(folder, dataProvider, showfiles);
- }
-
- public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles) {
- String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
- @Override
- public void onSuccess(final Folder _result) {
- if (showfiles)
- app.showFiles(_result);
- Iterator<Folder> iter = _result.getSubfolders().iterator();
- fetchFolder(_result.getOwner(), iter, dataProvider, new Command() {
- @Override
- public void execute() {
- dataProvider.getList().clear();
- dataProvider.getList().addAll(_result.getSubfolders());
- app.getOtherSharedTreeView().updateChildren(f);
- }
- });
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error getting folder", t);
- if (t instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
-
- public void initialize(Command callback) {
- fetchSharingUsers(callback);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by IntelliJ IDEA. User: chstath Date: 7/5/11 Time: 5:29 PM To change this template use File | Settings | File
- * Templates.
- */
-public abstract class DeleteRequest implements ScheduledCommand {
- private String api;
-
- protected String owner;
-
- private String path;
-
- private Map<String, String> headers = new HashMap<String, String>();
-
- public abstract void onSuccess(Resource result);
-
- public abstract void onError(Throwable t);
-
- public DeleteRequest(String api, String owner, String path) {
- this.api = api;
- this.owner = owner;
- this.path = path;
- }
-
- @Override
- public void execute() {
- RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, api + owner + path);
- for (String header : headers.keySet()) {
- builder.setHeader(header, headers.get(header));
- }
- try {
- builder.sendRequest("", new RestRequestCallback<Resource>(api + owner + path, Response.SC_NO_CONTENT) {
- @Override
- public void onSuccess(Resource object) {
- DeleteRequest.this.onSuccess(object);
- }
-
- @Override
- public Resource deserialize(Response response) {
- return Resource.createFromResponse(Resource.class, owner, response, null);
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
- DeleteRequest.this.onError(throwable);
- }
-
- @Override
- public void onUnauthorized(Response response) {
- DeleteRequest.this.onUnauthorized(response);
- }
- });
- }
- catch (RequestException e) {
- }
- }
-
- protected abstract void onUnauthorized(Response response);
-
- public void setHeader(String header, String value) {
- headers.put(header, value);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-
-public abstract class GetRequest<T extends Resource> implements ScheduledCommand {
-
- protected Class<T> aClass;
-
- private String api;
-
- protected String owner;
-
- private String path;
-
- private int okCode;
-
- protected T result;
-
- private Map<String, String> headers = new HashMap<String, String>();
-
- public abstract void onSuccess(T _result);
-
- public abstract void onError(Throwable t);
-
- public GetRequest(Class<T> aClass, String api, String owner, String path, int okCode, T result) {
- this.aClass = aClass;
- this.api = api;
- this.owner = owner;
- this.path = path;
- this.okCode = okCode;
- this.result = result;
- }
-
- public GetRequest(Class<T> aClass, String api, String owner, String path) {
- this(aClass, api, owner, path, -1, null);
- }
-
- public GetRequest(Class<T> aClass, String api, String owner, String path, T result) {
- this(aClass, api, owner, path, -1, result);
- }
-
- @Override
- public void execute() {
- if (path.contains("?"))
- path += "&t=" + System.currentTimeMillis();
- else
- path += "?t=" + System.currentTimeMillis();
- RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, api + owner + path);
- for (String header : headers.keySet()) {
- builder.setHeader(header, headers.get(header));
- }
- try {
- builder.sendRequest("", new RestRequestCallback<T>(api + owner + path, okCode) {
- @Override
- public void onSuccess(T object) {
- GetRequest.this.onSuccess(object);
- }
-
- @Override
- public T deserialize(Response response) {
- return Resource.createFromResponse(aClass, owner, response, result);
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
- if (throwable instanceof RestException) {
- if (((RestException) throwable).getHttpStatusCode() == 304 && result != null){
- GWT.log("Using cache: " + result.toString(), null);
- onSuccess(result);
- return;
- }
- }
- GetRequest.this.onError(throwable);
- }
-
- @Override
- public void onUnauthorized(Response response) {
- GetRequest.this.onUnauthorized(response);
- }
- });
- }
- catch (RequestException e) {
- }
- }
-
- protected abstract void onUnauthorized(Response response);
-
- public void setHeader(String header, String value) {
- headers.put(header, value);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-
-public abstract class HeadRequest<T extends Resource> implements ScheduledCommand {
-
- protected Class<T> aClass;
-
- private String api;
-
- protected String owner;
-
- private String path;
-
- private int okCode;
-
- protected T cached;
-
- protected T result;
-
- private Map<String, String> headers = new HashMap<String, String>();
-
- public abstract void onSuccess(T _result);
-
- public abstract void onError(Throwable t);
-
- public HeadRequest(Class<T> aClass, String api, String owner, String path, int okCode, T result) {
- this.aClass = aClass;
- this.api = api;
- this.owner = owner;
- this.path = path;
- this.okCode = okCode;
- this.result = result;
- }
-
- public HeadRequest(Class<T> aClass, String api, String owner, String path) {
- this(aClass, api, owner, path, Response.SC_NO_CONTENT, null);
- }
-
- public HeadRequest(Class<T> aClass, String api, String owner, String path, T result) {
- this(aClass, api, owner, path, Response.SC_NO_CONTENT, result);
- }
-
- @Override
- public void execute() {
- if (path.contains("?"))
- path += "&t=" + System.currentTimeMillis();
- else
- path += "?t=" + System.currentTimeMillis();
- RequestBuilder builder = new RequestBuilder(RequestBuilder.HEAD, api + owner + path);
- for (String header : headers.keySet()) {
- builder.setHeader(header, headers.get(header));
- }
- try {
- builder.sendRequest("", new RestRequestCallback<T>(api + owner + path, okCode) {
- @Override
- public void onSuccess(T object) {
- HeadRequest.this.onSuccess(object);
- }
-
- @Override
- public T deserialize(Response response) {
- return Resource.createFromResponse(aClass, owner, response, result);
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
- if (throwable instanceof RestException) {
- if (((RestException) throwable).getHttpStatusCode() == 304 && cached != null){
- GWT.log("Using cache: " + cached.toString(), null);
- onSuccess(cached);
- return;
- }
- }
- HeadRequest.this.onError(throwable);
- }
-
- @Override
- public void onUnauthorized(Response response) {
- HeadRequest.this.onUnauthorized(response);
- }
- });
- }
- catch (RequestException e) {
- }
- }
-
- protected abstract void onUnauthorized(Response response);
-
- public void setHeader(String header, String value) {
- headers.put(header, value);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class PostRequest implements ScheduledCommand {
-
- private String api;
-
- protected String owner;
-
- private String path;
-
- String data = "";
-
- private Map<String, String> headers = new HashMap<String, String>();
-
- public abstract void onSuccess(Resource result);
-
- public abstract void onError(Throwable t);
-
- public PostRequest(String api, String owner, String path) {
- this.api = api;
- this.owner = owner;
- this.path = path;
- }
-
- public PostRequest(String api, String owner, String path, String data) {
- this.api = api;
- this.owner = owner;
- this.path = path;
- this.data = data;
- }
-
- @Override
- public void execute() {
- RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, api + owner + path);
- for (String header : headers.keySet()) {
- builder.setHeader(header, headers.get(header));
- }
- try {
- builder.sendRequest(data, new RestRequestCallback<Resource>(api + owner + path, Response.SC_ACCEPTED) {
- @Override
- public void onSuccess(Resource object) {
- PostRequest.this.onSuccess(object);
- }
-
- @Override
- public Resource deserialize(Response response) {
- return Resource.createFromResponse(Resource.class, owner, response, null);
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
- PostRequest.this.onError(throwable);
- }
-
- @Override
- public void onUnauthorized(Response response) {
- PostRequest.this.onUnauthorized(response);
- }
- });
- }
- catch (RequestException e) {
- GWT.log("", e);
- }
- }
-
- protected abstract void onUnauthorized(Response response);
-
- public void setHeader(String header, String value) {
- headers.put(header, value);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.http.client.URL;
-
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class PutRequest implements ScheduledCommand {
-
- private String api;
-
- protected String owner;
-
- private String path;
-
- private Map<String, String> headers = new HashMap<String, String>();
-
- public abstract void onSuccess(Resource result);
-
- public abstract void onError(Throwable t);
-
- public PutRequest(String api, String owner, String path) {
- this.api = api;
- this.owner = owner;
- this.path = path;
- }
-
- @Override
- public void execute() {
- RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, api + owner + path);
- for (String header : headers.keySet()) {
- builder.setHeader(header, headers.get(header));
- }
- try {
- builder.sendRequest("", new RestRequestCallback<Resource>(api + owner + path, Response.SC_CREATED) {
- @Override
- public void onSuccess(Resource object) {
- PutRequest.this.onSuccess(object);
- }
-
- @Override
- public Resource deserialize(Response response) {
- return Resource.createFromResponse(Resource.class, owner, response, null);
- }
-
- @Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
- PutRequest.this.onError(throwable);
- }
-
- @Override
- public void onUnauthorized(Response response) {
- PutRequest.this.onUnauthorized(response);
- }
- });
- }
- catch (RequestException e) {
- }
- }
-
- protected abstract void onUnauthorized(Response response);
-
- public void setHeader(String header, String value) {
- headers.put(header, value);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.rest;
-
-
-public class RestException extends Throwable {
-
- private int httpStatusCode;
- private String httpStatusText;
- private String text;
-
- public RestException() {
- }
-
- public RestException(String message) {
- super(message);
- }
-
- public RestException(Throwable innerException) {
- super(innerException);
- }
-
- public RestException(String message, Throwable innerException) {
- super(message, innerException);
- }
-
- public RestException(String aPath, int aStatusCode, String aStatusText, String aText) {
- super("HTTP error: " + aStatusCode+"\nPath:"+aPath + "\nStatus text:" + aStatusText + "\nText:" + aText);
- httpStatusCode = aStatusCode;
- httpStatusText = aStatusText;
- text = aText;
- }
-
- public int getHttpStatusCode() {
- return httpStatusCode;
- }
-
- public String getHttpStatusText() {
- return httpStatusText;
- }
-
- public String getText() {
- return text;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.rest;
-
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.Response;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-public abstract class RestRequestCallback<T extends Resource> implements RequestCallback {
-
- private static final int HTTP_OK = 200;
- private int okcode = -1;
- private String path;
-
- public RestRequestCallback(String path, int okCode) {
- this.path = path;
- this.okcode = okCode;
- }
-
- public RestRequestCallback(String path) {
- this(path, -1);
- }
-
- @Override
- public void onResponseReceived(Request request, Response response) {
- try {
- if (response.getStatusCode() == HTTP_OK || (okcode !=-1 && response.getStatusCode() == okcode))
- onSuccess(deserialize(response));
- else if (response.getStatusCode() == Response.SC_UNAUTHORIZED)
- onUnauthorized(response);
- else {
- String statusText = "";
- String text = "";
- // Ignore JavaScript errors caused by non-existent text.
- try {
- statusText = response.getStatusText();
- }
- catch (Exception e) {}
-
- try {
- text = response.getText();
- }
- catch (Exception e) {}
-
- onError(request, new RestException(path, response.getStatusCode(), statusText, text));
- }
- } catch (Exception e) {
- onError(request, e);
- }
- }
-
- public abstract void onSuccess(T result);
-
- public abstract T deserialize(Response response);
-
- public abstract void onUnauthorized(Response response);
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.tagtree;
-
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-
-import java.util.Date;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-public class Tag extends Resource {
- /*
- * The name of the tag.
- */
- private String name = null;
-
- private Set<File> files = new LinkedHashSet<File>();
-
- public Tag() {};
-
- public Tag(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
-// public void populate(Response response) {
-// String header = response.getHeader("Last-Modified");
-// if (header != null)
-// lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header);
-//
-// header = response.getHeader("X-Container-Bytes-Used");
-// if (header != null)
-// bytesUsed = Long.valueOf(header);
-//
-// subfolders.clear(); //This is necessary in case we update a pre-existing Tag so that stale subfolders won't show up
-// files.clear();
-// JSONValue json = JSONParser.parseStrict(response.getText());
-// JSONArray array = json.isArray();
-// if (array != null) {
-// for (int i=0; i<array.size(); i++) {
-// JSONObject o = array.get(i).isObject();
-// if (o != null) {
-// String contentType = unmarshallString(o, "content_type");
-// if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
-// Tag f = new Tag();
-// f.populate(this, o, container);
-// subfolders.add(f);
-// }
-// else {
-// File file = new File();
-// file.populate(this, o, container);
-// files.add(file);
-// }
-// }
-// }
-// }
-// }
-//
-// public void populate(Tag parent, JSONObject o, String aContainer) {
-// this.parent = parent;
-// String path = null;
-// if (o.containsKey("subdir")) {
-// path = unmarshallString(o, "subdir");
-// }
-// else {
-// path = unmarshallString(o, "name");
-// lastModified = unmarshallDate(o, "last_modified");
-// }
-// if (path.endsWith("/"))
-// path = path.substring(0, path.length() - 1);
-// if (path.contains("/"))
-// name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
-// else
-// name = path;
-// if (aContainer != null) {
-// container = aContainer;
-// prefix = path;
-// }
-// else {
-// container = name;
-// prefix = "";
-// }
-// }
-//
-// public static Tag createFromResponse(Response response, Tag result) {
-// Tag f = null;
-// if (result == null)
-// f = new Tag();
-// else
-// f = result;
-//
-// f.populate(response);
-// return f;
-// }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof Tag) {
- Tag o = (Tag) other;
- return name.equals(o.getName());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
- public Set<File> getFiles() {
- return files;
- }
-
- @Override
- public Date getLastModified() {
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.tagtree;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.resources.client.ImageResource.ImageOptions;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Tree;
-import gr.grnet.pithos.web.client.FolderContextMenu;
-
-public class TagTreeView extends Composite {
-
- static interface BasicResources extends CellTree.Resources {
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
- ImageResource cellTreeClosedItem();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
- ImageResource cellTreeLoading();
-
- @Override
- @ImageOptions(flipRtl = true)
- @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
- ImageResource cellTreeOpenItem();
-
- @Override
- @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
- CellTree.Style cellTreeStyle();
- }
-
- static interface Images extends Tree.Resources, FolderContextMenu.Images {
-
- @Source("gr/grnet/pithos/resources/home22.png")
- ImageResource home();
-
- @Source("gr/grnet/pithos/resources/info.png")
- public ImageResource tag();
- }
-
- static Images images = GWT.create(Images.class);
-
- static interface Templates extends SafeHtmlTemplates {
- public Templates INSTANCE = GWT.create(Templates.class);
-
- @Template("<span>{0}</span>")
- public SafeHtml nameSpan(String name);
- }
-
- private TagTreeViewModel model;
-
- public TagTreeView(TagTreeViewModel viewModel) {
- this.model = viewModel;
- /*
- * Create the tree using the model. We use <code>null</code> as the default
- * value of the root node. The default value will be passed to
- * CustomTreeModel#getNodeInfo();
- */
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
-
- tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
-
-
- public Tag getSelection() {
- return model.getSelection();
- }
-
- public void updateTag(Tag tag) {
- model.updateTag(tag);
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.pithos.web.client.tagtree;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.AccountResource;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.tagtree.TagTreeView.Templates;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.cell.client.TextCell;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.text.shared.SafeHtmlRenderer;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.google.gwt.view.client.TreeViewModel;
-
-public class TagTreeViewModel implements TreeViewModel {
-
- private Cell<Tag> tagCell = new AbstractCell<Tag>(ContextMenuEvent.getType().getName()) {
-
- @Override
- public void render(@SuppressWarnings("unused") Context context, Tag tag, SafeHtmlBuilder safeHtmlBuilder) {
- String html = AbstractImagePrototype.create(TagTreeView.images.tag()).getHTML();
- safeHtmlBuilder.appendHtmlConstant(html);
- safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(tag.getName()));
- }
-
- @Override
- public void onBrowserEvent(@SuppressWarnings("unused") Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Tag tag, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<Tag> valueUpdater) {
- if (event.getType().equals(com.google.gwt.event.dom.client.ContextMenuEvent.getType().getName())) {
- TagTreeViewModel.this.selectionModel.setSelected(tag, true);
- }
- }
- };
-
- private ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
- private ListDataProvider<Tag> tagDataProvider = new ListDataProvider<Tag>();
-
- protected SingleSelectionModel<Tag> selectionModel;
-
- protected Pithos app;
-
- public TagTreeViewModel(Pithos _app, SingleSelectionModel<Tag> selectionModel) {
- app = _app;
- this.selectionModel = selectionModel;
- }
-
- @Override
- public <T> NodeInfo<?> getNodeInfo(T value) {
- if (value == null) {
- return new DefaultNodeInfo<String>(rootDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
- @Override
- public SafeHtml render(String object) {
- SafeHtmlBuilder builder = new SafeHtmlBuilder();
- render(object, builder);
- return builder.toSafeHtml();
- }
-
- @Override
- public void render(String object, SafeHtmlBuilder builder) {
- String html = AbstractImagePrototype.create(TagTreeView.images.tag()).getHTML();
- builder.appendHtmlConstant(html);
- builder.append(Templates.INSTANCE.nameSpan(object));
- }
- }), null, null);
- }
- else if (value instanceof String) {
- //fetchAllTags();
- return new DefaultNodeInfo<Tag>(tagDataProvider, tagCell, selectionModel, null);
- }
- else
- return null;
- }
-
- @Override
- public boolean isLeaf(Object o) {
- if (o == null)
- return false;
- if (o instanceof String)
- return tagDataProvider.getList().isEmpty();
- return true;
- }
-
- public Tag getSelection() {
- return selectionModel.getSelectedObject();
- }
-
- public void updateTag(Tag tag) {
- fetchTag(tag);
- }
-
- public void fetchTag(Tag t) {
- AccountResource account = app.getAccount();
- Iterator<Folder> iter = account.getContainers().iterator();
- fetchTag(iter, t, new LinkedHashSet<File>());
- }
-
- protected void fetchTag(final Iterator<Folder> iter, final Tag t, final Set<File> files) {
- if (iter.hasNext()) {
- Folder f = iter.next();
- String path = f.getUri() + "?format=json&meta=" + t.getName();
- GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path) {
- @Override
- public void onSuccess(Folder _result) {
- files.addAll(_result.getFiles());
- fetchTag(iter, t, files);
- }
-
- @Override
- public void onError(Throwable th) {
- GWT.log("Error getting folder", th);
- if (th instanceof RestException)
- app.displayError("Error getting folder: " + ((RestException) th).getHttpStatusText());
- else
- app.displayError("System error fetching folder: " + th.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- getFolder.setHeader("X-Auth-Token", app.getToken());
- Scheduler.get().scheduleDeferred(getFolder);
- }
- else {
- app.showFiles(files);
- }
- }
-
- public void initialize(List<Tag> allTags) {
- tagDataProvider.getList().addAll(allTags);
- rootDataProvider.getList().add("Tags");
- }
-}
+++ /dev/null
-<!--
- ~ Copyright 2011 GRNET S.A. All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or
- ~ without modification, are permitted provided that the following
- ~ conditions are met:
- ~
- ~ 1. Redistributions of source code must retain the above
- ~ copyright notice, this list of conditions and the following
- ~ disclaimer.
- ~
- ~ 2. Redistributions in binary form must reproduce the above
- ~ copyright notice, this list of conditions and the following
- ~ disclaimer in the documentation and/or other materials
- ~ provided with the distribution.
- ~
- ~ THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- ~ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- ~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- ~ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- ~ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- ~ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ~ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- ~ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ~ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- ~ POSSIBILITY OF SUCH DAMAGE.
- ~
- ~ The views and conclusions contained in the software and
- ~ documentation are those of the authors and should not be
- ~ interpreted as representing official policies, either expressed
- ~ or implied, of GRNET S.A.
- -->
-
-<html>
- <head>
- <title>Pithos+</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <script language='javascript' src='gr.grnet.pithos.web.Pithos.nocache.js'></script>
- <script type="text/javascript">
- document.oncontextmenu = function() {
- return false;
- }
- </script>
- <script type="text/javascript" language="javascript" src="lytebox.js"></script>
- <link rel="stylesheet" href="lytebox.css" type="text/css" media="screen" /> </head>
- <body>
- <iframe src="javascript:''" id="__gwt_historyFrame" style="position:absolute;width:0;height:0;border:0"></iframe>
- </body>
-</html>
+++ /dev/null
-#lbOverlay { position: fixed; top: 0; left: 0; z-index: 99998; width: 100%; height: 500px; }\r
- #lbOverlay.grey { background-color: #000000; }\r
- #lbOverlay.red { background-color: #330000; }\r
- #lbOverlay.green { background-color: #003300; }\r
- #lbOverlay.blue { background-color: #011D50; }\r
- #lbOverlay.gold { background-color: #666600; }\r
-\r
-#lbMain { position: absolute; left: 0; width: 100%; z-index: 99999; text-align: center; line-height: 0; }\r
-#lbMain a img { border: none; }\r
-\r
-#lbOuterContainer { position: relative; background-color: #fff; width: 200px; height: 200px; margin: 0 auto; }\r
- #lbOuterContainer.grey { border: 3px solid #888888; }\r
- #lbOuterContainer.red { border: 3px solid #DD0000; }\r
- #lbOuterContainer.green { border: 3px solid #00B000; }\r
- #lbOuterContainer.blue { border: 3px solid #5F89D8; }\r
- #lbOuterContainer.gold { border: 3px solid #B0B000; }\r
-\r
-#lbDetailsContainer { font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; width: 100%; line-height: 1.4em; overflow: auto; margin: 0 auto; }\r
- #lbDetailsContainer.grey { border: 3px solid #888888; border-top: none; }\r
- #lbDetailsContainer.red { border: 3px solid #DD0000; border-top: none; }\r
- #lbDetailsContainer.green { border: 3px solid #00B000; border-top: none; }\r
- #lbDetailsContainer.blue { border: 3px solid #5F89D8; border-top: none; }\r
- #lbDetailsContainer.gold { border: 3px solid #B0B000; border-top: none; }\r
-\r
-#lbImageContainer, #lbIframeContainer { padding: 10px; }\r
-#lbLoading {\r
- position: absolute; top: 45%; left: 0%; height: 32px; width: 100%; text-align: center; line-height: 0; background: url(images/loading.gif) center no-repeat;\r
-}\r
-\r
-#lbHoverNav { position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; }\r
-#lbImageContainer>#lbHoverNav { left: 0; }\r
-#lbHoverNav a { outline: none; }\r
-\r
-#lbPrev { width: 49%; height: 100%; background: transparent url(images/blank.gif) no-repeat; display: block; left: 0; float: left; }\r
- #lbPrev.grey:hover, #lbPrev.grey:visited:hover { background: url(images/prev_grey.gif) left 15% no-repeat; }\r
- #lbPrev.red:hover, #lbPrev.red:visited:hover { background: url(images/prev_red.gif) left 15% no-repeat; }\r
- #lbPrev.green:hover, #lbPrev.green:visited:hover { background: url(images/prev_green.gif) left 15% no-repeat; }\r
- #lbPrev.blue:hover, #lbPrev.blue:visited:hover { background: url(images/prev_blue.gif) left 15% no-repeat; }\r
- #lbPrev.gold:hover, #lbPrev.gold:visited:hover { background: url(images/prev_gold.gif) left 15% no-repeat; }\r
- \r
-#lbNext { width: 49%; height: 100%; background: transparent url(images/blank.gif) no-repeat; display: block; right: 0; float: right; }\r
- #lbNext.grey:hover, #lbNext.grey:visited:hover { background: url(images/next_grey.gif) right 15% no-repeat; }\r
- #lbNext.red:hover, #lbNext.red:visited:hover { background: url(images/next_red.gif) right 15% no-repeat; }\r
- #lbNext.green:hover, #lbNext.green:visited:hover { background: url(images/next_green.gif) right 15% no-repeat; }\r
- #lbNext.blue:hover, #lbNext.blue:visited:hover { background: url(images/next_blue.gif) right 15% no-repeat; }\r
- #lbNext.gold:hover, #lbNext.gold:visited:hover { background: url(images/next_gold.gif) right 15% no-repeat; }\r
-\r
-#lbPrev2, #lbNext2 { text-decoration: none; font-weight: bold; }\r
- #lbPrev2.grey, #lbNext2.grey, #lbSpacer.grey { color: #333333; }\r
- #lbPrev2.red, #lbNext2.red, #lbSpacer.red { color: #620000; }\r
- #lbPrev2.green, #lbNext2.green, #lbSpacer.green { color: #003300; }\r
- #lbPrev2.blue, #lbNext2.blue, #lbSpacer.blue { color: #01379E; }\r
- #lbPrev2.gold, #lbNext2.gold, #lbSpacer.gold { color: #666600; }\r
- \r
-#lbPrev2_Off, #lbNext2_Off { font-weight: bold; }\r
- #lbPrev2_Off.grey, #lbNext2_Off.grey { color: #CCCCCC; }\r
- #lbPrev2_Off.red, #lbNext2_Off.red { color: #FFCCCC; }\r
- #lbPrev2_Off.green, #lbNext2_Off.green { color: #82FF82; }\r
- #lbPrev2_Off.blue, #lbNext2_Off.blue { color: #B7CAEE; }\r
- #lbPrev2_Off.gold, #lbNext2_Off.gold { color: #E1E100; }\r
- \r
-#lbDetailsData { padding: 0 10px; }\r
- #lbDetailsData.grey { color: #333333; }\r
- #lbDetailsData.red { color: #620000; }\r
- #lbDetailsData.green { color: #003300; }\r
- #lbDetailsData.blue { color: #01379E; }\r
- #lbDetailsData.gold { color: #666600; }\r
-\r
-#lbDetails { width: 60%; float: left; text-align: left; }\r
-#lbCaption { display: block; font-weight: bold; }\r
-#lbNumberDisplay { float: left; display: block; padding-bottom: 1.0em; }\r
-#lbNavDisplay { float: left; display: block; padding-bottom: 1.0em; }\r
-\r
-#lbClose { width: 64px; height: 28px; float: right; margin-bottom: 1px; }\r
- #lbClose.grey { background: url(images/close_grey.png) no-repeat; }\r
- #lbClose.red { background: url(images/close_red.png) no-repeat; }\r
- #lbClose.green { background: url(images/close_green.png) no-repeat; }\r
- #lbClose.blue { background: url(images/close_blue.png) no-repeat; }\r
- #lbClose.gold { background: url(images/close_gold.png) no-repeat; }\r
-\r
-#lbPlay { width: 64px; height: 28px; float: right; margin-bottom: 1px; }\r
- #lbPlay.grey { background: url(images/play_grey.png) no-repeat; }\r
- #lbPlay.red { background: url(images/play_red.png) no-repeat; }\r
- #lbPlay.green { background: url(images/play_green.png) no-repeat; }\r
- #lbPlay.blue { background: url(images/play_blue.png) no-repeat; }\r
- #lbPlay.gold { background: url(images/play_gold.png) no-repeat; }\r
- \r
-#lbPause { width: 64px; height: 28px; float: right; margin-bottom: 1px; }\r
- #lbPause.grey { background: url(images/pause_grey.png) no-repeat; }\r
- #lbPause.red { background: url(images/pause_red.png) no-repeat; }\r
- #lbPause.green { background: url(images/pause_green.png) no-repeat; }\r
- #lbPause.blue { background: url(images/pause_blue.png) no-repeat; }\r
- #lbPause.gold { background: url(images/pause_gold.png) no-repeat; }
\ No newline at end of file
+++ /dev/null
-//***********************************************************************************************************************************/\r
-// LyteBox v3.22\r
-//\r
-// Author: Markus F. Hay\r
-// Website: http://www.dolem.com/lytebox\r
-// Date: October 2, 2007\r
-// License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)\r
-// Browsers: Tested successfully on WinXP with the following browsers (using no DOCTYPE and Strict/Transitional/Loose DOCTYPES):\r
-// * Firefox: 2.0.0.7, 1.5.0.12\r
-// * Internet Explorer: 7.0, 6.0 SP2, 5.5 SP2\r
-// * Opera: 9.23\r
-//\r
-// Releases: For up-to-date and complete release information, visit http://www.dolem.com/forum/showthread.php?tid=62\r
-// * v3.22 (10/02/07)\r
-// * v3.21 (09/30/07)\r
-// * v3.20 (07/12/07)\r
-// * v3.10 (05/28/07)\r
-// * v3.00 (05/15/07)\r
-// * v2.02 (11/13/06)\r
-//\r
-// Credit: LyteBox was originally derived from the Lightbox class (v2.02) that was written by Lokesh Dhakar. For more\r
-// information please visit http://huddletogether.com/projects/lightbox2/\r
-//***********************************************************************************************************************************/\r
-Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } }\r
-Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }\r
-String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }\r
-\r
-function LyteBox() {\r
- /*** Start Global Configuration ***/\r
- this.theme = 'grey'; // themes: grey (default), red, green, blue, gold\r
- this.hideFlash = true; // controls whether or not Flash objects should be hidden\r
- this.outerBorder = true; // controls whether to show the outer grey (or theme) border\r
- this.resizeSpeed = 8; // controls the speed of the image resizing (1=slowest and 10=fastest)\r
- this.maxOpacity = 80; // higher opacity = darker overlay, lower opacity = lighter overlay\r
- this.navType = 1; // 1 = "Prev/Next" buttons on top left and left (default), 2 = "<< prev | next >>" links next to image number\r
- this.autoResize = true; // controls whether or not images should be resized if larger than the browser window dimensions\r
- this.doAnimations = true; // controls whether or not "animate" Lytebox, i.e. resize transition between images, fade in/out effects, etc.\r
- \r
- this.borderSize = 12; // if you adjust the padding in the CSS, you will need to update this variable -- otherwise, leave this alone...\r
- /*** End Global Configuration ***/\r
- \r
- /*** Configure Slideshow Options ***/\r
- this.slideInterval = 4000; // Change value (milliseconds) to increase/decrease the time between "slides" (10000 = 10 seconds)\r
- this.showNavigation = true; // true to display Next/Prev buttons/text during slideshow, false to hide\r
- this.showClose = true; // true to display the Close button, false to hide\r
- this.showDetails = true; // true to display image details (caption, count), false to hide\r
- this.showPlayPause = true; // true to display pause/play buttons next to close button, false to hide\r
- this.autoEnd = true; // true to automatically close Lytebox after the last image is reached, false to keep open\r
- this.pauseOnNextClick = false; // true to pause the slideshow when the "Next" button is clicked\r
- this.pauseOnPrevClick = true; // true to pause the slideshow when the "Prev" button is clicked\r
- /*** End Slideshow Configuration ***/\r
- \r
- if(this.resizeSpeed > 10) { this.resizeSpeed = 10; }\r
- if(this.resizeSpeed < 1) { resizeSpeed = 1; }\r
- this.resizeDuration = (11 - this.resizeSpeed) * 0.15;\r
- this.resizeWTimerArray = new Array();\r
- this.resizeWTimerCount = 0;\r
- this.resizeHTimerArray = new Array();\r
- this.resizeHTimerCount = 0;\r
- this.showContentTimerArray = new Array();\r
- this.showContentTimerCount = 0;\r
- this.overlayTimerArray = new Array();\r
- this.overlayTimerCount = 0;\r
- this.imageTimerArray = new Array();\r
- this.imageTimerCount = 0;\r
- this.timerIDArray = new Array();\r
- this.timerIDCount = 0;\r
- this.slideshowIDArray = new Array();\r
- this.slideshowIDCount = 0;\r
- this.imageArray = new Array();\r
- this.activeImage = null;\r
- this.slideArray = new Array();\r
- this.activeSlide = null;\r
- this.frameArray = new Array();\r
- this.activeFrame = null;\r
- this.checkFrame();\r
- this.isSlideshow = false;\r
- this.isLyteframe = false;\r
- /*@cc_on\r
- /*@if (@_jscript)\r
- this.ie = (document.all && !window.opera) ? true : false;\r
- /*@else @*/\r
- this.ie = false;\r
- /*@end\r
- @*/\r
- this.ie7 = (this.ie && window.XMLHttpRequest); \r
- this.initialize();\r
-}\r
-LyteBox.prototype.initialize = function() {\r
- this.updateLyteboxItems();\r
- var objBody = this.doc.getElementsByTagName("body").item(0); \r
- if (this.doc.getElementById('lbOverlay')) {\r
- objBody.removeChild(this.doc.getElementById("lbOverlay"));\r
- objBody.removeChild(this.doc.getElementById("lbMain"));\r
- }\r
- var objOverlay = this.doc.createElement("div");\r
- objOverlay.setAttribute('id','lbOverlay');\r
- objOverlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- if ((this.ie && !this.ie7) || (this.ie7 && this.doc.compatMode == 'BackCompat')) {\r
- objOverlay.style.position = 'absolute';\r
- }\r
- objOverlay.style.display = 'none';\r
- objBody.appendChild(objOverlay);\r
- var objLytebox = this.doc.createElement("div");\r
- objLytebox.setAttribute('id','lbMain');\r
- objLytebox.style.display = 'none';\r
- objBody.appendChild(objLytebox);\r
- var objOuterContainer = this.doc.createElement("div");\r
- objOuterContainer.setAttribute('id','lbOuterContainer');\r
- objOuterContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objLytebox.appendChild(objOuterContainer);\r
- var objIframeContainer = this.doc.createElement("div");\r
- objIframeContainer.setAttribute('id','lbIframeContainer');\r
- objIframeContainer.style.display = 'none';\r
- objOuterContainer.appendChild(objIframeContainer);\r
- var objIframe = this.doc.createElement("iframe");\r
- objIframe.setAttribute('id','lbIframe');\r
- objIframe.setAttribute('name','lbIframe');\r
- objIframe.style.display = 'none';\r
- objIframeContainer.appendChild(objIframe);\r
- var objImageContainer = this.doc.createElement("div");\r
- objImageContainer.setAttribute('id','lbImageContainer');\r
- objOuterContainer.appendChild(objImageContainer);\r
- var objLyteboxImage = this.doc.createElement("img");\r
- objLyteboxImage.setAttribute('id','lbImage');\r
- objImageContainer.appendChild(objLyteboxImage);\r
- var objLoading = this.doc.createElement("div");\r
- objLoading.setAttribute('id','lbLoading');\r
- objOuterContainer.appendChild(objLoading);\r
- var objDetailsContainer = this.doc.createElement("div");\r
- objDetailsContainer.setAttribute('id','lbDetailsContainer');\r
- objDetailsContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objLytebox.appendChild(objDetailsContainer);\r
- var objDetailsData =this.doc.createElement("div");\r
- objDetailsData.setAttribute('id','lbDetailsData');\r
- objDetailsData.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objDetailsContainer.appendChild(objDetailsData);\r
- var objDetails = this.doc.createElement("div");\r
- objDetails.setAttribute('id','lbDetails');\r
- objDetailsData.appendChild(objDetails);\r
- var objCaption = this.doc.createElement("span");\r
- objCaption.setAttribute('id','lbCaption');\r
- objDetails.appendChild(objCaption);\r
- var objHoverNav = this.doc.createElement("div");\r
- objHoverNav.setAttribute('id','lbHoverNav');\r
- objImageContainer.appendChild(objHoverNav);\r
- var objBottomNav = this.doc.createElement("div");\r
- objBottomNav.setAttribute('id','lbBottomNav');\r
- objDetailsData.appendChild(objBottomNav);\r
- var objPrev = this.doc.createElement("a");\r
- objPrev.setAttribute('id','lbPrev');\r
- objPrev.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objPrev.setAttribute('href','#');\r
- objHoverNav.appendChild(objPrev);\r
- var objNext = this.doc.createElement("a");\r
- objNext.setAttribute('id','lbNext');\r
- objNext.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objNext.setAttribute('href','#');\r
- objHoverNav.appendChild(objNext);\r
- var objNumberDisplay = this.doc.createElement("span");\r
- objNumberDisplay.setAttribute('id','lbNumberDisplay');\r
- objDetails.appendChild(objNumberDisplay);\r
- var objNavDisplay = this.doc.createElement("span");\r
- objNavDisplay.setAttribute('id','lbNavDisplay');\r
- objNavDisplay.style.display = 'none';\r
- objDetails.appendChild(objNavDisplay);\r
- var objClose = this.doc.createElement("a");\r
- objClose.setAttribute('id','lbClose');\r
- objClose.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objClose.setAttribute('href','#');\r
- objBottomNav.appendChild(objClose);\r
- var objPause = this.doc.createElement("a");\r
- objPause.setAttribute('id','lbPause');\r
- objPause.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objPause.setAttribute('href','#');\r
- objPause.style.display = 'none';\r
- objBottomNav.appendChild(objPause);\r
- var objPlay = this.doc.createElement("a");\r
- objPlay.setAttribute('id','lbPlay');\r
- objPlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- objPlay.setAttribute('href','#');\r
- objPlay.style.display = 'none';\r
- objBottomNav.appendChild(objPlay);\r
-};\r
-LyteBox.prototype.updateLyteboxItems = function() { \r
- var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');\r
- for (var i = 0; i < anchors.length; i++) {\r
- var anchor = anchors[i];\r
- var relAttribute = String(anchor.getAttribute('rel'));\r
- if (anchor.getAttribute('href')) {\r
- if (relAttribute.toLowerCase().match('lytebox')) {\r
- anchor.onclick = function () { myLytebox.start(this, false, false); return false; }\r
- } else if (relAttribute.toLowerCase().match('lyteshow')) {\r
- anchor.onclick = function () { myLytebox.start(this, true, false); return false; }\r
- } else if (relAttribute.toLowerCase().match('lyteframe')) {\r
- anchor.onclick = function () { myLytebox.start(this, false, true); return false; }\r
- }\r
- }\r
- }\r
-};\r
-LyteBox.prototype.start = function(imageLink, doSlide, doFrame) {\r
- if (this.ie && !this.ie7) { this.toggleSelects('hide'); }\r
- if (this.hideFlash) { this.toggleFlash('hide'); }\r
- this.isLyteframe = (doFrame ? true : false);\r
- var pageSize = this.getPageSize();\r
- var objOverlay = this.doc.getElementById('lbOverlay');\r
- var objBody = this.doc.getElementsByTagName("body").item(0);\r
- objOverlay.style.height = pageSize[1] + "px";\r
- objOverlay.style.display = '';\r
- this.appear('lbOverlay', (this.doAnimations ? 0 : this.maxOpacity));\r
- var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');\r
- if (this.isLyteframe) {\r
- this.frameArray = [];\r
- this.frameNum = 0;\r
- if ((imageLink.getAttribute('rel') == 'lyteframe')) {\r
- var rev = imageLink.getAttribute('rev');\r
- this.frameArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));\r
- } else {\r
- if (imageLink.getAttribute('rel').indexOf('lyteframe') != -1) {\r
- for (var i = 0; i < anchors.length; i++) {\r
- var anchor = anchors[i];\r
- if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {\r
- var rev = anchor.getAttribute('rev');\r
- this.frameArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));\r
- }\r
- }\r
- this.frameArray.removeDuplicates();\r
- while(this.frameArray[this.frameNum][0] != imageLink.getAttribute('href')) { this.frameNum++; }\r
- }\r
- }\r
- } else {\r
- this.imageArray = [];\r
- this.imageNum = 0;\r
- this.slideArray = [];\r
- this.slideNum = 0;\r
- if ((imageLink.getAttribute('rel') == 'lytebox')) {\r
- this.imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));\r
- } else {\r
- if (imageLink.getAttribute('rel').indexOf('lytebox') != -1) {\r
- for (var i = 0; i < anchors.length; i++) {\r
- var anchor = anchors[i];\r
- if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {\r
- this.imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));\r
- }\r
- }\r
- this.imageArray.removeDuplicates();\r
- while(this.imageArray[this.imageNum][0] != imageLink.getAttribute('href')) { this.imageNum++; }\r
- }\r
- if (imageLink.getAttribute('rel').indexOf('lyteshow') != -1) {\r
- for (var i = 0; i < anchors.length; i++) {\r
- var anchor = anchors[i];\r
- if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {\r
- this.slideArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));\r
- }\r
- }\r
- this.slideArray.removeDuplicates();\r
- while(this.slideArray[this.slideNum][0] != imageLink.getAttribute('href')) { this.slideNum++; }\r
- }\r
- }\r
- }\r
- var object = this.doc.getElementById('lbMain');\r
- object.style.top = (this.getPageScroll() + (pageSize[3] / 15)) + "px";\r
- object.style.display = '';\r
- if (!this.outerBorder) {\r
- this.doc.getElementById('lbOuterContainer').style.border = 'none';\r
- this.doc.getElementById('lbDetailsContainer').style.border = 'none';\r
- } else {\r
- this.doc.getElementById('lbOuterContainer').style.borderBottom = '';\r
- this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- }\r
- this.doc.getElementById('lbOverlay').onclick = function() { myLytebox.end(); return false; }\r
- this.doc.getElementById('lbMain').onclick = function(e) {\r
- var e = e;\r
- if (!e) {\r
- if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {\r
- e = window.parent.window.event;\r
- } else {\r
- e = window.event;\r
- }\r
- }\r
- var id = (e.target ? e.target.id : e.srcElement.id);\r
- if (id == 'lbMain') { myLytebox.end(); return false; }\r
- }\r
- this.doc.getElementById('lbClose').onclick = function() { myLytebox.end(); return false; }\r
- this.doc.getElementById('lbPause').onclick = function() { myLytebox.togglePlayPause("lbPause", "lbPlay"); return false; }\r
- this.doc.getElementById('lbPlay').onclick = function() { myLytebox.togglePlayPause("lbPlay", "lbPause"); return false; } \r
- this.isSlideshow = doSlide;\r
- this.isPaused = (this.slideNum != 0 ? true : false);\r
- if (this.isSlideshow && this.showPlayPause && this.isPaused) {\r
- this.doc.getElementById('lbPlay').style.display = '';\r
- this.doc.getElementById('lbPause').style.display = 'none';\r
- }\r
- if (this.isLyteframe) {\r
- this.changeContent(this.frameNum);\r
- } else {\r
- if (this.isSlideshow) {\r
- this.changeContent(this.slideNum);\r
- } else {\r
- this.changeContent(this.imageNum);\r
- }\r
- }\r
-};\r
-LyteBox.prototype.changeContent = function(imageNum) {\r
- if (this.isSlideshow) {\r
- for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }\r
- }\r
- this.activeImage = this.activeSlide = this.activeFrame = imageNum;\r
- if (!this.outerBorder) {\r
- this.doc.getElementById('lbOuterContainer').style.border = 'none';\r
- this.doc.getElementById('lbDetailsContainer').style.border = 'none';\r
- } else {\r
- this.doc.getElementById('lbOuterContainer').style.borderBottom = '';\r
- this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);\r
- }\r
- this.doc.getElementById('lbLoading').style.display = '';\r
- this.doc.getElementById('lbImage').style.display = 'none';\r
- this.doc.getElementById('lbIframe').style.display = 'none';\r
- this.doc.getElementById('lbPrev').style.display = 'none';\r
- this.doc.getElementById('lbNext').style.display = 'none';\r
- this.doc.getElementById('lbIframeContainer').style.display = 'none';\r
- this.doc.getElementById('lbDetailsContainer').style.display = 'none';\r
- this.doc.getElementById('lbNumberDisplay').style.display = 'none';\r
- if (this.navType == 2 || this.isLyteframe) {\r
- object = this.doc.getElementById('lbNavDisplay');\r
- object.innerHTML = ' <span id="lbPrev2_Off" style="display: none;" class="' + this.theme + '">« prev</span><a href="#" id="lbPrev2" class="' + this.theme + '" style="display: none;">« prev</a> <b id="lbSpacer" class="' + this.theme + '">||</b> <span id="lbNext2_Off" style="display: none;" class="' + this.theme + '">next »</span><a href="#" id="lbNext2" class="' + this.theme + '" style="display: none;">next »</a>';\r
- object.style.display = 'none';\r
- }\r
- if (this.isLyteframe) {\r
- var iframe = myLytebox.doc.getElementById('lbIframe');\r
- var styles = this.frameArray[this.activeFrame][2];\r
- var aStyles = styles.split(';');\r
- for (var i = 0; i < aStyles.length; i++) {\r
- if (aStyles[i].indexOf('width:') >= 0) {\r
- var w = aStyles[i].replace('width:', '');\r
- iframe.width = w.trim();\r
- } else if (aStyles[i].indexOf('height:') >= 0) {\r
- var h = aStyles[i].replace('height:', '');\r
- iframe.height = h.trim();\r
- } else if (aStyles[i].indexOf('scrolling:') >= 0) {\r
- var s = aStyles[i].replace('scrolling:', '');\r
- iframe.scrolling = s.trim();\r
- } else if (aStyles[i].indexOf('border:') >= 0) {\r
- // Not implemented yet, as there are cross-platform issues with setting the border (from a GUI standpoint)\r
- //var b = aStyles[i].replace('border:', '');\r
- //iframe.style.border = b.trim();\r
- }\r
- }\r
- this.resizeContainer(parseInt(iframe.width), parseInt(iframe.height));\r
- } else {\r
- imgPreloader = new Image();\r
- imgPreloader.onload = function() {\r
- var imageWidth = imgPreloader.width;\r
- var imageHeight = imgPreloader.height;\r
- if (myLytebox.autoResize) {\r
- var pagesize = myLytebox.getPageSize();\r
- var x = pagesize[2] - 150;\r
- var y = pagesize[3] - 150;\r
- if (imageWidth > x) {\r
- imageHeight = Math.round(imageHeight * (x / imageWidth));\r
- imageWidth = x; \r
- if (imageHeight > y) { \r
- imageWidth = Math.round(imageWidth * (y / imageHeight));\r
- imageHeight = y; \r
- }\r
- } else if (imageHeight > y) { \r
- imageWidth = Math.round(imageWidth * (y / imageHeight));\r
- imageHeight = y; \r
- if (imageWidth > x) {\r
- imageHeight = Math.round(imageHeight * (x / imageWidth));\r
- imageWidth = x;\r
- }\r
- }\r
- }\r
- var lbImage = myLytebox.doc.getElementById('lbImage')\r
- lbImage.src = (myLytebox.isSlideshow ? myLytebox.slideArray[myLytebox.activeSlide][0] : myLytebox.imageArray[myLytebox.activeImage][0]);\r
- lbImage.width = imageWidth;\r
- lbImage.height = imageHeight;\r
- myLytebox.resizeContainer(imageWidth, imageHeight);\r
- imgPreloader.onload = function() {};\r
- }\r
- imgPreloader.src = (this.isSlideshow ? this.slideArray[this.activeSlide][0] : this.imageArray[this.activeImage][0]);\r
- }\r
-};\r
-LyteBox.prototype.resizeContainer = function(imgWidth, imgHeight) {\r
- this.wCur = this.doc.getElementById('lbOuterContainer').offsetWidth;\r
- this.hCur = this.doc.getElementById('lbOuterContainer').offsetHeight;\r
- this.xScale = ((imgWidth + (this.borderSize * 2)) / this.wCur) * 100;\r
- this.yScale = ((imgHeight + (this.borderSize * 2)) / this.hCur) * 100;\r
- var wDiff = (this.wCur - this.borderSize * 2) - imgWidth;\r
- var hDiff = (this.hCur - this.borderSize * 2) - imgHeight;\r
- if (!(hDiff == 0)) {\r
- this.hDone = false;\r
- this.resizeH('lbOuterContainer', this.hCur, imgHeight + this.borderSize*2, this.getPixelRate(this.hCur, imgHeight));\r
- } else {\r
- this.hDone = true;\r
- }\r
- if (!(wDiff == 0)) {\r
- this.wDone = false;\r
- this.resizeW('lbOuterContainer', this.wCur, imgWidth + this.borderSize*2, this.getPixelRate(this.wCur, imgWidth));\r
- } else {\r
- this.wDone = true;\r
- }\r
- if ((hDiff == 0) && (wDiff == 0)) {\r
- if (this.ie){ this.pause(250); } else { this.pause(100); } \r
- }\r
- this.doc.getElementById('lbPrev').style.height = imgHeight + "px";\r
- this.doc.getElementById('lbNext').style.height = imgHeight + "px";\r
- this.doc.getElementById('lbDetailsContainer').style.width = (imgWidth + (this.borderSize * 2) + (this.ie && this.doc.compatMode == "BackCompat" && this.outerBorder ? 2 : 0)) + "px";\r
- this.showContent();\r
-};\r
-LyteBox.prototype.showContent = function() {\r
- if (this.wDone && this.hDone) {\r
- for (var i = 0; i < this.showContentTimerCount; i++) { window.clearTimeout(this.showContentTimerArray[i]); }\r
- if (this.outerBorder) {\r
- this.doc.getElementById('lbOuterContainer').style.borderBottom = 'none';\r
- }\r
- this.doc.getElementById('lbLoading').style.display = 'none';\r
- if (this.isLyteframe) {\r
- this.doc.getElementById('lbIframe').style.display = '';\r
- this.appear('lbIframe', (this.doAnimations ? 0 : 100));\r
- } else {\r
- this.doc.getElementById('lbImage').style.display = '';\r
- this.appear('lbImage', (this.doAnimations ? 0 : 100));\r
- this.preloadNeighborImages();\r
- }\r
- if (this.isSlideshow) {\r
- if(this.activeSlide == (this.slideArray.length - 1)) {\r
- if (this.autoEnd) {\r
- this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.end('slideshow')", this.slideInterval);\r
- }\r
- } else {\r
- if (!this.isPaused) {\r
- this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.changeContent("+(this.activeSlide+1)+")", this.slideInterval);\r
- }\r
- }\r
- this.doc.getElementById('lbHoverNav').style.display = (this.showNavigation && this.navType == 1 ? '' : 'none');\r
- this.doc.getElementById('lbClose').style.display = (this.showClose ? '' : 'none');\r
- this.doc.getElementById('lbDetails').style.display = (this.showDetails ? '' : 'none');\r
- this.doc.getElementById('lbPause').style.display = (this.showPlayPause && !this.isPaused ? '' : 'none');\r
- this.doc.getElementById('lbPlay').style.display = (this.showPlayPause && !this.isPaused ? 'none' : '');\r
- this.doc.getElementById('lbNavDisplay').style.display = (this.showNavigation && this.navType == 2 ? '' : 'none');\r
- } else {\r
- this.doc.getElementById('lbHoverNav').style.display = (this.navType == 1 && !this.isLyteframe ? '' : 'none');\r
- if ((this.navType == 2 && !this.isLyteframe && this.imageArray.length > 1) || (this.frameArray.length > 1 && this.isLyteframe)) {\r
- this.doc.getElementById('lbNavDisplay').style.display = '';\r
- } else {\r
- this.doc.getElementById('lbNavDisplay').style.display = 'none';\r
- }\r
- this.doc.getElementById('lbClose').style.display = '';\r
- this.doc.getElementById('lbDetails').style.display = '';\r
- this.doc.getElementById('lbPause').style.display = 'none';\r
- this.doc.getElementById('lbPlay').style.display = 'none';\r
- }\r
- this.doc.getElementById('lbImageContainer').style.display = (this.isLyteframe ? 'none' : '');\r
- this.doc.getElementById('lbIframeContainer').style.display = (this.isLyteframe ? '' : 'none');\r
- try {\r
- this.doc.getElementById('lbIframe').src = this.frameArray[this.activeFrame][0];\r
- } catch(e) { }\r
- } else {\r
- this.showContentTimerArray[this.showContentTimerCount++] = setTimeout("myLytebox.showContent()", 200);\r
- }\r
-};\r
-LyteBox.prototype.updateDetails = function() {\r
- var object = this.doc.getElementById('lbCaption');\r
- var sTitle = (this.isSlideshow ? this.slideArray[this.activeSlide][1] : (this.isLyteframe ? this.frameArray[this.activeFrame][1] : this.imageArray[this.activeImage][1]));\r
- object.style.display = '';\r
- object.innerHTML = (sTitle == null ? '' : sTitle);\r
- this.updateNav();\r
- this.doc.getElementById('lbDetailsContainer').style.display = '';\r
- object = this.doc.getElementById('lbNumberDisplay');\r
- if (this.isSlideshow && this.slideArray.length > 1) {\r
- object.style.display = '';\r
- object.innerHTML = "Image " + eval(this.activeSlide + 1) + " of " + this.slideArray.length;\r
- this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 && this.showNavigation ? '' : 'none');\r
- } else if (this.imageArray.length > 1 && !this.isLyteframe) {\r
- object.style.display = '';\r
- object.innerHTML = "Image " + eval(this.activeImage + 1) + " of " + this.imageArray.length;\r
- this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 ? '' : 'none');\r
- } else if (this.frameArray.length > 1 && this.isLyteframe) {\r
- object.style.display = '';\r
- object.innerHTML = "Page " + eval(this.activeFrame + 1) + " of " + this.frameArray.length;\r
- this.doc.getElementById('lbNavDisplay').style.display = '';\r
- } else {\r
- this.doc.getElementById('lbNavDisplay').style.display = 'none';\r
- }\r
- this.appear('lbDetailsContainer', (this.doAnimations ? 0 : 100));\r
-};\r
-LyteBox.prototype.updateNav = function() {\r
- if (this.isSlideshow) {\r
- if (this.activeSlide != 0) {\r
- var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));\r
- object.style.display = '';\r
- object.onclick = function() {\r
- if (myLytebox.pauseOnPrevClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }\r
- myLytebox.changeContent(myLytebox.activeSlide - 1); return false;\r
- }\r
- } else {\r
- if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }\r
- }\r
- if (this.activeSlide != (this.slideArray.length - 1)) {\r
- var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));\r
- object.style.display = '';\r
- object.onclick = function() {\r
- if (myLytebox.pauseOnNextClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }\r
- myLytebox.changeContent(myLytebox.activeSlide + 1); return false;\r
- }\r
- } else {\r
- if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }\r
- }\r
- } else if (this.isLyteframe) {\r
- if(this.activeFrame != 0) {\r
- var object = this.doc.getElementById('lbPrev2');\r
- object.style.display = '';\r
- object.onclick = function() {\r
- myLytebox.changeContent(myLytebox.activeFrame - 1); return false;\r
- }\r
- } else {\r
- this.doc.getElementById('lbPrev2_Off').style.display = '';\r
- }\r
- if(this.activeFrame != (this.frameArray.length - 1)) {\r
- var object = this.doc.getElementById('lbNext2');\r
- object.style.display = '';\r
- object.onclick = function() {\r
- myLytebox.changeContent(myLytebox.activeFrame + 1); return false;\r
- }\r
- } else {\r
- this.doc.getElementById('lbNext2_Off').style.display = '';\r
- } \r
- } else {\r
- if(this.activeImage != 0) {\r
- var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));\r
- object.style.display = '';\r
- object.onclick = function() {\r
- myLytebox.changeContent(myLytebox.activeImage - 1); return false;\r
- }\r
- } else {\r
- if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }\r
- }\r
- if(this.activeImage != (this.imageArray.length - 1)) {\r
- var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));\r
- object.style.display = '';\r
- object.onclick = function() {\r
- myLytebox.changeContent(myLytebox.activeImage + 1); return false;\r
- }\r
- } else {\r
- if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }\r
- }\r
- }\r
- this.enableKeyboardNav();\r
-};\r
-LyteBox.prototype.enableKeyboardNav = function() { document.onkeydown = this.keyboardAction; };\r
-LyteBox.prototype.disableKeyboardNav = function() { document.onkeydown = ''; };\r
-LyteBox.prototype.keyboardAction = function(e) {\r
- var keycode = key = escape = null;\r
- keycode = (e == null) ? event.keyCode : e.which;\r
- key = String.fromCharCode(keycode).toLowerCase();\r
- escape = (e == null) ? 27 : e.DOM_VK_ESCAPE;\r
- if ((key == 'x') || (key == 'c') || (keycode == escape)) {\r
- myLytebox.end();\r
- } else if ((key == 'p') || (keycode == 37)) {\r
- if (myLytebox.isSlideshow) {\r
- if(myLytebox.activeSlide != 0) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeSlide - 1);\r
- }\r
- } else if (myLytebox.isLyteframe) {\r
- if(myLytebox.activeFrame != 0) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeFrame - 1);\r
- }\r
- } else {\r
- if(myLytebox.activeImage != 0) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeImage - 1);\r
- }\r
- }\r
- } else if ((key == 'n') || (keycode == 39)) {\r
- if (myLytebox.isSlideshow) {\r
- if(myLytebox.activeSlide != (myLytebox.slideArray.length - 1)) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeSlide + 1);\r
- }\r
- } else if (myLytebox.isLyteframe) {\r
- if(myLytebox.activeFrame != (myLytebox.frameArray.length - 1)) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeFrame + 1);\r
- }\r
- } else {\r
- if(myLytebox.activeImage != (myLytebox.imageArray.length - 1)) {\r
- myLytebox.disableKeyboardNav();\r
- myLytebox.changeContent(myLytebox.activeImage + 1);\r
- }\r
- }\r
- }\r
-};\r
-LyteBox.prototype.preloadNeighborImages = function() {\r
- if (this.isSlideshow) {\r
- if ((this.slideArray.length - 1) > this.activeSlide) {\r
- preloadNextImage = new Image();\r
- preloadNextImage.src = this.slideArray[this.activeSlide + 1][0];\r
- }\r
- if(this.activeSlide > 0) {\r
- preloadPrevImage = new Image();\r
- preloadPrevImage.src = this.slideArray[this.activeSlide - 1][0];\r
- }\r
- } else {\r
- if ((this.imageArray.length - 1) > this.activeImage) {\r
- preloadNextImage = new Image();\r
- preloadNextImage.src = this.imageArray[this.activeImage + 1][0];\r
- }\r
- if(this.activeImage > 0) {\r
- preloadPrevImage = new Image();\r
- preloadPrevImage.src = this.imageArray[this.activeImage - 1][0];\r
- }\r
- }\r
-};\r
-LyteBox.prototype.togglePlayPause = function(hideID, showID) {\r
- if (this.isSlideshow && hideID == "lbPause") {\r
- for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }\r
- }\r
- this.doc.getElementById(hideID).style.display = 'none';\r
- this.doc.getElementById(showID).style.display = '';\r
- if (hideID == "lbPlay") {\r
- this.isPaused = false;\r
- if (this.activeSlide == (this.slideArray.length - 1)) {\r
- this.end();\r
- } else {\r
- this.changeContent(this.activeSlide + 1);\r
- }\r
- } else {\r
- this.isPaused = true;\r
- }\r
-};\r
-LyteBox.prototype.end = function(caller) {\r
- var closeClick = (caller == 'slideshow' ? false : true);\r
- if (this.isSlideshow && this.isPaused && !closeClick) { return; }\r
- this.disableKeyboardNav();\r
- this.doc.getElementById('lbMain').style.display = 'none';\r
- this.fade('lbOverlay', (this.doAnimations ? this.maxOpacity : 0));\r
- this.toggleSelects('visible');\r
- if (this.hideFlash) { this.toggleFlash('visible'); }\r
- if (this.isSlideshow) {\r
- for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }\r
- }\r
- if (this.isLyteframe) {\r
- this.initialize();\r
- }\r
-};\r
-LyteBox.prototype.checkFrame = function() {\r
- if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {\r
- this.isFrame = true;\r
- this.lytebox = "window.parent." + window.name + ".myLytebox";\r
- this.doc = parent.document;\r
- } else {\r
- this.isFrame = false;\r
- this.lytebox = "myLytebox";\r
- this.doc = document;\r
- }\r
-};\r
-LyteBox.prototype.getPixelRate = function(cur, img) {\r
- var diff = (img > cur) ? img - cur : cur - img;\r
- if (diff >= 0 && diff <= 100) { return 10; }\r
- if (diff > 100 && diff <= 200) { return 15; }\r
- if (diff > 200 && diff <= 300) { return 20; }\r
- if (diff > 300 && diff <= 400) { return 25; }\r
- if (diff > 400 && diff <= 500) { return 30; }\r
- if (diff > 500 && diff <= 600) { return 35; }\r
- if (diff > 600 && diff <= 700) { return 40; }\r
- if (diff > 700) { return 45; }\r
-};\r
-LyteBox.prototype.appear = function(id, opacity) {\r
- var object = this.doc.getElementById(id).style;\r
- object.opacity = (opacity / 100);\r
- object.MozOpacity = (opacity / 100);\r
- object.KhtmlOpacity = (opacity / 100);\r
- object.filter = "alpha(opacity=" + (opacity + 10) + ")";\r
- if (opacity == 100 && (id == 'lbImage' || id == 'lbIframe')) {\r
- try { object.removeAttribute("filter"); } catch(e) {} /* Fix added for IE Alpha Opacity Filter bug. */\r
- this.updateDetails();\r
- } else if (opacity >= this.maxOpacity && id == 'lbOverlay') {\r
- for (var i = 0; i < this.overlayTimerCount; i++) { window.clearTimeout(this.overlayTimerArray[i]); }\r
- return;\r
- } else if (opacity >= 100 && id == 'lbDetailsContainer') {\r
- try { object.removeAttribute("filter"); } catch(e) {} /* Fix added for IE Alpha Opacity Filter bug. */\r
- for (var i = 0; i < this.imageTimerCount; i++) { window.clearTimeout(this.imageTimerArray[i]); }\r
- this.doc.getElementById('lbOverlay').style.height = this.getPageSize()[1] + "px";\r
- } else {\r
- if (id == 'lbOverlay') {\r
- this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+20) + ")", 1);\r
- } else {\r
- this.imageTimerArray[this.imageTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+10) + ")", 1);\r
- }\r
- }\r
-};\r
-LyteBox.prototype.fade = function(id, opacity) {\r
- var object = this.doc.getElementById(id).style;\r
- object.opacity = (opacity / 100);\r
- object.MozOpacity = (opacity / 100);\r
- object.KhtmlOpacity = (opacity / 100);\r
- object.filter = "alpha(opacity=" + opacity + ")";\r
- if (opacity <= 0) {\r
- try {\r
- object.display = 'none';\r
- } catch(err) { }\r
- } else if (id == 'lbOverlay') {\r
- this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-20) + ")", 1);\r
- } else {\r
- this.timerIDArray[this.timerIDCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-10) + ")", 1);\r
- }\r
-};\r
-LyteBox.prototype.resizeW = function(id, curW, maxW, pixelrate, speed) {\r
- if (!this.hDone) {\r
- this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + curW + ", " + maxW + ", " + pixelrate + ")", 100);\r
- return;\r
- }\r
- var object = this.doc.getElementById(id);\r
- var timer = speed ? speed : (this.resizeDuration/2);\r
- var newW = (this.doAnimations ? curW : maxW);\r
- object.style.width = (newW) + "px";\r
- if (newW < maxW) {\r
- newW += (newW + pixelrate >= maxW) ? (maxW - newW) : pixelrate;\r
- } else if (newW > maxW) {\r
- newW -= (newW - pixelrate <= maxW) ? (newW - maxW) : pixelrate;\r
- }\r
- this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + newW + ", " + maxW + ", " + pixelrate + ", " + (timer+0.02) + ")", timer+0.02);\r
- if (parseInt(object.style.width) == maxW) {\r
- this.wDone = true;\r
- for (var i = 0; i < this.resizeWTimerCount; i++) { window.clearTimeout(this.resizeWTimerArray[i]); }\r
- }\r
-};\r
-LyteBox.prototype.resizeH = function(id, curH, maxH, pixelrate, speed) {\r
- var timer = speed ? speed : (this.resizeDuration/2);\r
- var object = this.doc.getElementById(id);\r
- var newH = (this.doAnimations ? curH : maxH);\r
- object.style.height = (newH) + "px";\r
- if (newH < maxH) {\r
- newH += (newH + pixelrate >= maxH) ? (maxH - newH) : pixelrate;\r
- } else if (newH > maxH) {\r
- newH -= (newH - pixelrate <= maxH) ? (newH - maxH) : pixelrate;\r
- }\r
- this.resizeHTimerArray[this.resizeHTimerCount++] = setTimeout("myLytebox.resizeH('" + id + "', " + newH + ", " + maxH + ", " + pixelrate + ", " + (timer+.02) + ")", timer+.02);\r
- if (parseInt(object.style.height) == maxH) {\r
- this.hDone = true;\r
- for (var i = 0; i < this.resizeHTimerCount; i++) { window.clearTimeout(this.resizeHTimerArray[i]); }\r
- }\r
-};\r
-LyteBox.prototype.getPageScroll = function() {\r
- if (self.pageYOffset) {\r
- return this.isFrame ? parent.pageYOffset : self.pageYOffset;\r
- } else if (this.doc.documentElement && this.doc.documentElement.scrollTop){\r
- return this.doc.documentElement.scrollTop;\r
- } else if (document.body) {\r
- return this.doc.body.scrollTop;\r
- }\r
-};\r
-LyteBox.prototype.getPageSize = function() { \r
- var xScroll, yScroll, windowWidth, windowHeight;\r
- if (window.innerHeight && window.scrollMaxY) {\r
- xScroll = this.doc.scrollWidth;\r
- yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);\r
- } else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){\r
- xScroll = this.doc.body.scrollWidth;\r
- yScroll = this.doc.body.scrollHeight;\r
- } else {\r
- xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;\r
- yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;\r
- xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;\r
- yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;\r
- }\r
- if (self.innerHeight) {\r
- windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;\r
- windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;\r
- } else if (document.documentElement && document.documentElement.clientHeight) {\r
- windowWidth = this.doc.documentElement.clientWidth;\r
- windowHeight = this.doc.documentElement.clientHeight;\r
- } else if (document.body) {\r
- windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;\r
- windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;\r
- windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;\r
- windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;\r
- }\r
- var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;\r
- var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;\r
- return new Array(pageWidth, pageHeight, windowWidth, windowHeight);\r
-};\r
-LyteBox.prototype.toggleFlash = function(state) {\r
- var objects = this.doc.getElementsByTagName("object");\r
- for (var i = 0; i < objects.length; i++) {\r
- objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- var embeds = this.doc.getElementsByTagName("embed");\r
- for (var i = 0; i < embeds.length; i++) {\r
- embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- if (this.isFrame) {\r
- for (var i = 0; i < parent.frames.length; i++) {\r
- try {\r
- objects = parent.frames[i].window.document.getElementsByTagName("object");\r
- for (var j = 0; j < objects.length; j++) {\r
- objects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- } catch(e) { }\r
- try {\r
- embeds = parent.frames[i].window.document.getElementsByTagName("embed");\r
- for (var j = 0; j < embeds.length; j++) {\r
- embeds[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- } catch(e) { }\r
- }\r
- }\r
-};\r
-LyteBox.prototype.toggleSelects = function(state) {\r
- var selects = this.doc.getElementsByTagName("select");\r
- for (var i = 0; i < selects.length; i++ ) {\r
- selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- if (this.isFrame) {\r
- for (var i = 0; i < parent.frames.length; i++) {\r
- try {\r
- selects = parent.frames[i].window.document.getElementsByTagName("select");\r
- for (var j = 0; j < selects.length; j++) {\r
- selects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';\r
- }\r
- } catch(e) { }\r
- }\r
- }\r
-};\r
-LyteBox.prototype.pause = function(numberMillis) {\r
- var now = new Date();\r
- var exitTime = now.getTime() + numberMillis;\r
- while (true) {\r
- now = new Date();\r
- if (now.getTime() > exitTime) { return; }\r
- }\r
-};\r
-if (window.addEventListener) {\r
- window.addEventListener("load",initLytebox,false);\r
-} else if (window.attachEvent) {\r
- window.attachEvent("onload",initLytebox);\r
-} else {\r
- window.onload = function() {initLytebox();}\r
-}\r
-function initLytebox() { myLytebox = new LyteBox(); }
\ No newline at end of file
+++ /dev/null
-body {
- color: black;
- font-family: Verdana, 'PT Sans', sans-serif;
- font-size: 16px;
- margin: 8px;
- margin-top: 3px;
- background-color: transparent;
-}
-
-table td {
- font-family: Verdana, 'PT Sans', sans-serif;
-}
-
-.pithos-outer {
- background: url(images/background.png) repeat-x;
-}
-
-a {
- color: white;
- text-decoration: none;
-}
-
-a:hover {
- color: white;
-}
-
-a:visited {
- color: white;
-}
-
-a.info {
- position: relative; /*this is the key*/
- z-index: 24;
- color: black;
- text-decoration: none
-}
-
-a.info:hover {
- z-index: 25;
- background-color: yellow;
-}
-
-a.info div {
- display: none
-}
-
-a.info:hover span {
- cursor: pointer;
-}
-
-/* The span will only display on :hover state. */
-a.info:hover div {
- display: block;
- position: absolute;
- bottom: 2em;
- right: 1em;
- width: 10em;
- border: 1px solid lightblue;
- background-color: #D0E4F6;
- color: black;
- text-align: center
-}
-
-.pithos-DialogBox .inner form {
- margin: 0px;
-}
-
-.pithos-dialogbox .inner form input,
-.pithos-dialogbox .inner form textarea
-{
- border: 1px solid #aaa;
- padding:4px;
-}
-
-.pithos-DialogBox .button {
- background: none;
- background-color: #4085A5;
- color: white;
- padding: 5px 6px;
- white-space: nowrap;
-
-}
-
-.pithos-DialogBox .Caption {
- color: white;
- background-color: #4085a5;
- padding: 20px;
- border-bottom: 1px solid white;
-}
-
-.pithos-DialogBox .close {
- background: url(images/close-popup.png) no-repeat;
- cursor: pointer;
- position: absolute;
- width: 13px;
- height: 13px;
- top: 12px;
- right: 7px;
-}
-
-.pithos-DialogBox .dialogMiddleCenter {
- background: url(images/popup-bg.png) repeat-x;
- background-color: white;
- padding: 3px;
-}
-
-.pithos-DialogBox .dialogBottomCenter {
- border-bottom: 5px solid #4085A5;
-}
-
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabTopLeft {
- background-position: 0px -55px;
-}
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabTopRight {
- background-position: -6px -55px;
-}
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabTopCenter {
- background: #D0E4F6;
-}
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabMiddleLeft,
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabMiddleCenter,
-.gwt-DecoratedTabBar .gwt-TabBarItem-selected .tabMiddleRight {
- background: #D0E4F6;
- color:#d45500;
-}
-.pithos-TabPanelBottom {
- border: none;
-}
-
-table.pithos-permList {
- border-spacing: 3px;
- border-collapse: collapse;
-
-}
-
-table.pithos-permList td {
- padding: 5px 5px 5px 5px;
- font-size:80%;
-}
-
-table.pithos-permList.props-labels {
- font-weight: bold;
-}
-
-.props-labels {
- font-size: 80%;
- font-weight: bold;
-}
-
-.props-toplabels {
- font-size: 80%;
- font-weight: bold;
- font-style: italic;
-}
-
-.props-values {
- font-size: 80%;
-}
-
-.hidden-link {
- text-decoration: none !important;
- color: black !important;
-}
-
-.hidden-link:visited {
- text-decoration: none !important;
- color: black !important;
-}
-
-.pithos-topPanel {
- background-color: #4085a5;
- font-size: 75%;
- height: 59px;
- border-bottom: 1px solid white;
-}
-
-.pithos-usernameMenu {
- cursor: pointer;
-}
-
-.pithos-usernameMenuItem {
- background: url(images/down-arrow-light.png) no-repeat scroll right 8px transparent;
- padding-right: 13px;
- cursor: pointer;
- color: white;
-}
-
-.pithos-usernameMenuItem:HOVER {
- background: url(images/down-arrow-lighter.png) no-repeat scroll right 8px transparent;
- background-color: #599EBD;
-}
-
-.pithos-usernameMenuItem:ACTIVE {
- background: url(images/down-arrow-lighter.png) no-repeat scroll right 8px transparent;
- background-color: #BED5E0;
-}
-
-.pithos-langMenuItem {
- cursor: pointer;
- color: #72ADC8;
-}
-
-.gwt-MenuBar-vertical {
- background: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupTopLeft {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupTopCenter {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupTopRight {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupMiddleLeft {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupMiddleRight {
- background: none;
- background-color: #D0E3ED;
-}
-
-.pithos-userItemMenu {
- background-color: #D0E3ED;
-}
-
-.gwt-popuppanel {
- border: 3px solid #D0E3ED;
- padding: 3px;
- background: #D0E3ED;
- border-image: initial;
-}
-
-.gwt-MenuBar .gwt-MenuItem {
- border-bottom: 1px solid #EFEFEF;
-}
-
-.gwt-MenuBar .gwt-MenuItem-selected {
- background-color: #E1EFF6;
-}
-
-.gwt-MenuBarPopup .menuPopupBottomLeft {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupBottomCenter {
- background: none;
- background-color: #D0E3ED;
-}
-
-.gwt-MenuBarPopup .menuPopupBottomRight {
- background: none;
- background-color: #D0E3ED;
-}
-
-.pithos-sessionExpired {
- width: 24em;
- /* Restore the padding we remove when overriding the gwt-DialogBox style */
- padding: 3px;
-}
-
-.pithos-statusbar {
- background-color: #4085a5;
- border: none;
- font-size: 90%;
- vertical-align: middle;
- font-weight: normal;
- height:119px;
- color: white;
-}
-
-.pithos-FileListContainer {
- padding-left: 10px;
-}
-
-.pithos-List {
- cursor: default;
- border-collapse: collapse;
- /* prevents selecting text in table with shift and ctrl*/
- -moz-user-select: none;
-}
-
-.pithos-errorMessage {
- font-size: 90%;
- background-color: #880000;
- color: #fff;
- cursor: pointer;
-}
-
-.pithos-errorMessage td {
- font-size: 90%;
-}
-
-.pithos-warnMessage {
- font-size: 90%;
- background-color: #eeee99;
- cursor: pointer;
-}
-
-.pithos-infoMessage {
- font-size: 90%;
- background-color: #ccffcc;
- cursor: pointer;
-}
-
-.pithos-clearMessage {
- font-size: 90%;
- font-weight: bold;
- text-decoration: none;
- color: black;
-}
-
-.pithos-clearMessage:visited {
- font-size: 90%;
- font-weight: bold;
- text-decoration: none;
- color: black;
-}
-
-.pithos-readForAllNote {
- width: 240px;
- text-align: justify;
- font-style: italic;
- font-size: 12px;
- padding-left: 4;
-}
-
-.pithos-treeHeader {
- background-color: #74aec9;
- height: 25px;
- width: 100%;
-}
-
-.pithos-statistics {
- color: white;
- padding: 5px;
-}
-
-.pithos-splitPanel {
- background: url(images/white50.png) transparent;
- margin-bottom: 34px;
-}
-
-.pithos-splitPanel-noframe {
- margin-bottom: 0;
-}
-
-/* Use the background color for the splitter. */
-.gwt-HorizontalSplitPanel .hsplitter {
- cursor: move;
- border: 0px;
- background: url(images/background.png) repeat-x;
-}
-
-.pithos-tag {
- display:inline;
-}
-
-.pithos-uploadButton {
- background: none;
- background-color: #ff7f2a;
- font-size: 120%;
- text-align: center;
- height: auto;
- padding: 8px;
- width: 146px;
- border: none;
-}
-
-.pithos-uploadButton:HOVER {
- background-color: #f95;
-}
-
-.pithos-rightSide {
- vertical-align: middle;
- width: 100%;
- padding-left: 7px;
-}
-.pithos-parentButton {
- background: none;
- background-color: #a1c8da;
-}
-
-.pithos-folderStatistics {
- background-color: #a1c8da;
- text-align: center;
- color: white;
- height: 32px;
- padding: 5px 15px;
- margin-right: 10px;
-}
-
-.grnet-sign {
- color: #72ADC8;
-}
-
-.pithos-logo {
- position: absolute;
- top: 25;
-}
-
-.pithos-header {
- background: url(images/white50.png);
- margin-top: 34;
- height: 60px;
-}
-
-.pithos-header-noframe {
- margin-top: 0;
-}
-
-/*.cellTreeWidget-selectedTree {
- background-color: #BCD7E3;
-}*/
-
-.pithos-list thead th img {
- top: 5px !important;
-}
-
-.effectPanel-inner {
- background-color: #4085A5;
- margin: 10px;
-}
-
-.pithos-toolsButton {
- background-color: #FF7F2A !important;
- background-position: 9px 7px !important;
-}
-
-.pithos-toolsButton:hover {
- background-color: #F95 !important;
-}
-
-/*move background from inner to centerinner to wrap action buttons too*/
-.dialogMiddleCenterInner.dialogContent {
- background: url(https://pithos.dev.grnet.gr/ui/images/white50.png);
- margin: 7px;
- padding: 15px;
- /*border: 1px solid #aaa;*/
- -moz-box-shadow: 0 0 1px 1px #888;
- -webkit-box-shadow: 0 0 1px 1px #888;
- box-shadow: 0 0 1px 1px #888;
-}
-
-/*remove background/padding from .inner*/
-.pithos-dialogbox .inner {
- background: none;
- padding:0;
- width: auto !important;
-}
-
-/*button styles*/
-.pithos-dalogbox .button {
-}
-
-/*button position within the overlay content*/
-.dialogMiddleCenterInner .button {
- margin-left: 2px;
- border: none;
- padding: 7px 20px;
- margin-top: 10px;
- float: right;
- margin-right: 4px;
-}
-
-/* fix placement of overlay paragraphs */
-.pithos-credentialstext {
- padding: 0 0 10px 0;
-}
-
-/* overlay styles */
-.pithos-dialogbox {
- background-color: white;
- border: 2px solid #444;
- text-align: left;
- -moz-box-shadow: 0 0 90px 5px #000;
- -webkit-box-shadow: 0 0 90px 5px #000;
- box-shadow: 0 0 90px 5px #000;
-}
-
-/* hide overlay dialogue unneeded side elements */
-.dialogMiddleRight, .dialogBottomRight, .dialogTopRight,
-.dialogMiddleLeft, .dialogBottomLeft, .dialogTopLeft,
-.dialogBottomCenter {
- display: none;
-}
-
-/* fix dialogbox caption padding and font-size */
-.pithos-dialogbox .caption {
- padding: 10px !important;
- font-size: 1.1em;
-}
-
-
-/* form input styling */
-.dialogMiddleCenterInner input {
- border: 1px solid #aaa;
- padding: 4px;
-}
-
-/* fix tag color */
-a.pithos-tag {
- color: #4085a5;
-}
\ No newline at end of file