Massimiliano Assante 10 years ago
parent 3503d54829
commit c9d6c999d7

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>pickitem-widget</name>
<comment>pickuser-widget project</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
</natures>
</projectDescription>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/webapp" />
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER" />
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true" />
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary" />
<classpathentry kind="output" path="" />
</classpath>

@ -0,0 +1,3 @@
#Tue Apr 16 14:53:45 CEST 2013
eclipse.preferences.version=1
filesCopiedToWebInfLib=

@ -0,0 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/pickitem-widget/target/pickitem-widget-1.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -0,0 +1,5 @@
#Thu Jun 16 11:14:17 CEST 2011
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=gwt-servlet.jar
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgc3JjL21haW4vd2ViYXBwXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLmNvbXBhbnkuU29tZU1vZHVsZTwvZW50cnktcG9pbnQtbW9kdWxlPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+

@ -0,0 +1,7 @@
#Tue Apr 16 14:53:45 CEST 2013
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7

@ -0,0 +1,5 @@
#Tue Apr 16 14:53:45 CEST 2013
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="${module}">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="pickitem-widget"/>
</wb-module>
</project-modules>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.7"/>
</faceted-project>

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

@ -0,0 +1,9 @@
#Thu Sep 02 10:42:12 CEST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/pickuser-widget"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.widgets.pickitem.client.GwtTestPickUser"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="pickuser-widget"/>
</launchConfiguration>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/pickuser-widget"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.widgets.pickitem.client.GwtTestPickUser"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="pickuser-widget"/>
</launchConfiguration>

@ -0,0 +1,7 @@
gCube System - License
------------------------------------------------------------
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
The software and documentation is provided by its authors/distributors "as is" and no expressed or
implied warranty is given for its use, quality or fitness for a particular case.

@ -0,0 +1,6 @@
Mantainers
-------
* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".

@ -0,0 +1,35 @@
The gCube System - Pick User Widget
------------------------------------------------------------
This work is partially funded by the European Commission in the
context of the iMarine project (www.i-marine.eu), under the 1st call of FP7 IST priority.
Authors
-------
Massimiliano Assante
*
Version and Release Date
------------------------
APR 2013
Description
-----------
Social networking Library
Download information
--------------------
Source code is available from SVN:
https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/pickuser-widget
Binaries can be downloaded from:
http://maven.research-infrastructures.eu/nexus/index.html#welcome
Documentation
-------------
Documentation is available on-line from the Projects Documentation Wiki:
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

@ -0,0 +1,6 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.widgets.pickitem.0-4-0"
date="2013-10-21">
<Change>Refactored and ported to GWT 2.5.1</Change>
</Changeset>
</ReleaseNotes>

@ -0,0 +1,48 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>target/apidocs</directory>
<outputDirectory>/${artifactId}/doc/api</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>./</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>{description}</Description>
<Class>PortletsUser</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

@ -0,0 +1 @@
${scm.url}

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>pickitem-widget</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>gCube Pick User Widget</name>
<description>
gCube Pick Item Widget is a dropdown item list you can attach to a textbox to select items
</description>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</url>
</scm>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.5.1</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Google Web Toolkit (GWT) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<!-- "provided" so that we don't deploy -->
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>PickItem.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='pickitem'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- To Comment out -->
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.widgets.pickitem.client.PickItem' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>

@ -0,0 +1,61 @@
package org.gcube.portlets.widgets.pickitem.client;
import java.util.ArrayList;
import org.gcube.portlets.widgets.pickitem.client.bundle.CssAndImages;
import org.gcube.portlets.widgets.pickitem.client.dialog.PickItemsDialog;
import org.gcube.portlets.widgets.pickitem.client.events.PickedUserEvent;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* Use this widget to display a a dropdown user list you can attach to a textbox to make select portal users typing @
* uncomment //sample in the onModuleLoad() to see it working
*
* To get to know which user was selected listen for the {@link PickedUserEvent} on the {@link HandlerManager} instance you pass to this widget.
*
*/
public class PickItem implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
sample();
}
private void sample() {
HandlerManager eventbus = new HandlerManager(null);
ArrayList<ItemBean> users = new ArrayList<ItemBean>();
users.add(new ItemBean("id", "test.user1", "Test Foo", "phot URL"));
users.add(new ItemBean("id", "test.user2", "Test Fie", "phot URL"));
users.add(new ItemBean("id", "test.user3", "Abba Foo", "phot URL"));
users.add(new ItemBean("id", "test.user4", "ABabba Fie", "phot URL"));
users.add(new ItemBean("id", "test.user5", "ACaro Foo", "phot URL"));
users.add(new ItemBean("id", "test.user6", "Dario Fie", "phot URL"));
users.add(new ItemBean("id", "test.user7", "Ergo Fie", "phot URL"));
final TextBox tb = new TextBox();
final int popUpY = tb.getAbsoluteTop()+30;
final PickItemsDialog pickUserDlg = new PickItemsDialog('#', users, eventbus, 300);
tb.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
pickUserDlg.onKeyUp(event.getNativeKeyCode(), tb.getAbsoluteLeft(), popUpY, tb.getText());
}
});
RootPanel.get().add(tb);
}
}

@ -0,0 +1,18 @@
package org.gcube.portlets.widgets.pickitem.client.bundle;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
public interface CssAndImages extends ClientBundle {
public static final CssAndImages INSTANCE = GWT.create(CssAndImages.class);
@Source("PickItem.css")
public CssResource css();
}

@ -0,0 +1,86 @@
@external pickDialog, pick-label, pickperson, pickperson-selected, pickperson-photo, user-table, user-table-row, user-table-col, user-table-col.content, .user-table-col.smallphoto, user-token, content, smallphoto;
.pickDialog {
border: 1px solid #333;
background-color: #FFF;
}
.pick-label {
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 15px;
line-height: 18px;
color: inherit;
}
.pickperson {
color: #0B61A4;
cursor: pointer;
cursor: hand;
background: #FFF;
-webkit-transition: background-color .25s ease-in-out;
-moz-transition: background-color .25s ease-in-out;
-o-transition: background-color .25s ease-in-out;
transition: background-color .25s ease-in-out;
}
.pickperson-selected {
background-color: #033E6B;
color: whitesmoke;
}
.pickperson:active,.pickperson:focus,.pickperson:hover {
background-color: #033E6B;
color: whitesmoke;
}
.pickperson-photo {
display: block;
padding: 2px;
border: 1px solid #E6E6E6;
margin-left: 2px;
}
.user-table {
margin: 1px 0px;
display: table;
width: 100%;
background-clip: border-box;
background-image: none;
background-origin: padding-box;
}
.user-table-row {
display: table-row;
text-align: left;
}
.user-table-col {
display: table-cell;
text-align: left;
}
.user-table-col.content {
padding: 10px 0px 0px 10px;
vertical-align: top;
}
.user-table-col.smallphoto {
width: 40px;
}
.user-token {
margin: 3px;
height: auto !important;
padding: 1px 3px;
background-color: #E2E6F0 !important;
border: 1px solid #9DACCC;
color: #1C2A47;
cursor: default;
font-family: verdana, arial, sans-serif;
font-size: 11px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}

@ -0,0 +1,238 @@
package org.gcube.portlets.widgets.pickitem.client.dialog;
import java.util.ArrayList;
import org.gcube.portlets.widgets.pickitem.client.bundle.CssAndImages;
import org.gcube.portlets.widgets.pickitem.client.events.PickedUserEvent;
import org.gcube.portlets.widgets.pickitem.client.uibinder.SelectableItem;
import org.gcube.portlets.widgets.pickitem.client.uibinder.WithPhotoTemplate;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SuggestOracle.Callback;
import com.google.gwt.user.client.ui.SuggestOracle.Request;
import com.google.gwt.user.client.ui.SuggestOracle.Response;
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* Use this widget to display a a dropdown user list you can attach to a textbox to make select portal users typing @
*
* To get to know which user was selected listen for the {@link PickedUserEvent} on the {@link HandlerManager} instance you pass to this widget.
*
*/
public class PickItemsDialog extends PopupPanel {
public final static int ARROW_UP = 38;
public final static int ARROW_DOWN = 40;
public final static int DELETE = KeyCodes.KEY_DELETE;
public final static int ENTER = KeyCodes.KEY_ENTER;
public final static int ESCAPE = KeyCodes.KEY_ESCAPE;
public final static int TAB = KeyCodes.KEY_TAB;
private HandlerManager eventBus;
private int limit = 10;
private final MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
private int displayIndexSelected;
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel mainPanel = new VerticalPanel();
private String triggerChar;
private ArrayList<ItemBean> users;
//needed because is selected when it popups
private Widget first;
static {
CssAndImages.INSTANCE.css().ensureInjected();
}
/**
* @param triggerChar the 'single char' used to trigger the items list show, e.g. '@', '#' ....
* @param the list of user to pick
* @param eventBus the event bus on where the widget will fire the selected user event
* @param widthInPixel the desired width (grater than 199 pixel)
*/
public PickItemsDialog(char triggerChar, ArrayList<ItemBean> users, final HandlerManager eventBus, int widthInPixel) {
super(true, false);
if (widthInPixel < 200) {
throw new IllegalArgumentException("width must be greater than 199");
}
this.eventBus = eventBus;
this.triggerChar = ""+triggerChar;
this.users = users;
focusPanel.setWidth(widthInPixel+"px");
mainPanel.setWidth(widthInPixel+"px");
setWidth(widthInPixel+"px");
focusPanel.add(mainPanel);
setWidget(focusPanel);
setStyleName("pickDialog");
//add the user fill names to the oracle
for (ItemBean user : users) {
oracle.add(user.getAlternativeName());
}
//remove the first selected when hovering
focusPanel.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
if (first != null)
first.removeStyleName("pickperson-selected");
}
});
focusPanel.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
select(displayIndexSelected);
}
});
focusPanel.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
SelectableItem ut = (SelectableItem) mainPanel.getWidget(displayIndexSelected);
eventBus.fireEvent(new PickedUserEvent(new ItemBean("id", "username", ut.getItemName(), "thumb")));
hide();
select(0); //RESET
}
});
}
/**
* called for each keyUp event from the user
* @param keyCode the event keycode
* @param x
* @param y
* @param currText
*/
public void onKeyUp(int keyCode, int x, int y, String currText) {
if (currText.endsWith(triggerChar)) { //the only way i found to intercept @
setPopupPosition(x, y);
hide();
} else if (currText.contains(triggerChar)) {
if (pickingUser(currText)) {
handleNonCharKeys(keyCode);
}
} else if (!currText.contains(triggerChar))
hide();
}
/**
* split the text and keeps listening for user keyboard events
* @param currText the text being typed
*/
private boolean pickingUser(String currText) {
String[] toSplit = currText.split(triggerChar); //get the interesting part
if (toSplit[1].trim().length() > 0) {
showSuggestions(toSplit[1]);
return true;
}
hide();
return false;
}
/**
* handles the nonchar events (arrows, esc, enter etc)
* @param event
*/
private void handleNonCharKeys(int keyCode) {
switch (keyCode) {
case ARROW_UP:
if (displayIndexSelected > 0)
select(--displayIndexSelected);
break;
case ARROW_DOWN:
case TAB:
if (displayIndexSelected+1 < mainPanel.getWidgetCount())
select(displayIndexSelected+1);
break;
case ESCAPE:
case DELETE:
hide();
case ENTER: //selectd with keyboard
SelectableItem ut = null;
if (mainPanel.getWidgetCount() > 0) {
if (displayIndexSelected < 0 || displayIndexSelected >= mainPanel.getWidgetCount()) //when there's only one left sometimes here i get -sth, no time to see why :)
ut = (SelectableItem) mainPanel.getWidget(0);
else
ut = (SelectableItem) mainPanel.getWidget(displayIndexSelected);
eventBus.fireEvent(new PickedUserEvent(new ItemBean("id", "username", ut.getItemName(), "thumb")));
hide();
select(0); //RESET
}
break;
default:
break;
}
}
public void showSuggestions(String query) {
if (query.length() > 0) {
oracle.requestSuggestions(new Request(query, limit), new Callback() {
public void onSuggestionsReady(Request request, Response response) {
mainPanel.clear();
int i = 0;
for (Suggestion s : response.getSuggestions()) {
if (i == 0) {
first = getUserTemplate(getUserModelBySuggestion(s), i);
first.addStyleName("pickperson-selected");
mainPanel.add(first);
}
else
mainPanel.add(getUserTemplate(getUserModelBySuggestion(s), i));
i++;
}
if (i > 0) {
show();
}
}
});
}
}
private ItemBean getUserModelBySuggestion(Suggestion suggestion) {
for (ItemBean user : users) {
if (suggestion.getReplacementString().compareTo(user.getAlternativeName()) ==0)
return user;
}
return new ItemBean("no-match","no-match","no-match","no-match");
}
private WithPhotoTemplate getUserTemplate(ItemBean user, int displayIndex) {
return new WithPhotoTemplate(this, user, displayIndex);
}
/**
* select the user in the model and in the view
* @param displayIndex
*/
public void select(int displayIndex) {
for (int i = 0; i < mainPanel.getWidgetCount(); i++) {
Widget ut = (Widget) mainPanel.getWidget(i);
if (i == displayIndex) {
ut.addStyleName("pickperson-selected");
displayIndexSelected = i;
}
else
ut.removeStyleName("pickperson-selected");
}
}
}

@ -0,0 +1,31 @@
package org.gcube.portlets.widgets.pickitem.client.events;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.event.shared.GwtEvent;
public class PickedUserEvent extends GwtEvent<PickedUserEventHandler> {
public static Type<PickedUserEventHandler> TYPE = new Type<PickedUserEventHandler>();
private ItemBean user;
public ItemBean getSelectedUser() {
return user;
}
public PickedUserEvent(ItemBean user) {
this.user = user;
}
@Override
public Type<PickedUserEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(PickedUserEventHandler handler) {
handler.onSelectedUser(this);
}
}

@ -0,0 +1,7 @@
package org.gcube.portlets.widgets.pickitem.client.events;
import com.google.gwt.event.shared.EventHandler;
public interface PickedUserEventHandler extends EventHandler {
void onSelectedUser(PickedUserEvent event);
}

@ -0,0 +1,5 @@
package org.gcube.portlets.widgets.pickitem.client.uibinder;
public interface SelectableItem {
String getItemName();
}

@ -0,0 +1,56 @@
package org.gcube.portlets.widgets.pickitem.client.uibinder;
import org.gcube.portlets.widgets.pickitem.client.dialog.PickItemsDialog;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
public class WithPhotoTemplate extends Composite implements SelectableItem {
private static PhotoTemplateUiBinder uiBinder = GWT
.create(PhotoTemplateUiBinder.class);
interface PhotoTemplateUiBinder extends UiBinder<Widget, WithPhotoTemplate> {
}
PickItemsDialog owner;
private int currDisplayIndex;
@UiField
FocusPanel focusDiv;
@UiField
Image avatarImage;
@UiField
HTML contentArea;
public WithPhotoTemplate(PickItemsDialog owner, ItemBean user, int displayIndex) {
initWidget(uiBinder.createAndBindUi(this));
this.owner = owner;
currDisplayIndex = displayIndex;
if (user.getThumbnailURL() != null)
avatarImage.setUrl(user.getThumbnailURL());
avatarImage.setPixelSize(30, 30);
contentArea.setHTML(user.getAlternativeName());
}
@UiHandler("focusDiv")
void onMouseOver(MouseOverEvent e) {
owner.select(currDisplayIndex);
}
@Override
public String getItemName() {
return contentArea.getText();
}
}

@ -0,0 +1,22 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:FocusPanel ui:field="focusDiv" styleName="user-table pickperson">
<g:HTMLPanel ui:field="mainDiv">
<div class="user-table-row">
<div class="user-table-col smallphoto">
<a href="">
<g:Image title="" styleName="pickperson-photo" url=""
ui:field="avatarImage" width="30px" height="30px" />
</a>
</div>
<div class="user-table-col content">
<div>
<g:HTML styleName="pick-label" ui:field="contentArea" />
</div>
</div>
</div>
</g:HTMLPanel>
</g:FocusPanel>
</ui:UiBinder>

@ -0,0 +1,54 @@
package org.gcube.portlets.widgets.pickitem.shared;
import java.io.Serializable;
@SuppressWarnings("serial")
public class ItemBean implements Serializable {
private String id;
private String name;
private String alternativeName;
private String thumbnailURL;
public ItemBean() {
super();
}
public ItemBean(String id, String username, String fullName, String thumbnailURL) {
super();
this.id = id;
this.name = username;
this.alternativeName = fullName;
this.thumbnailURL = thumbnailURL;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAlternativeName() {
return alternativeName;
}
public void setAlternativeName(String altname) {
this.alternativeName = altname;
}
public String getThumbnailURL() {
return thumbnailURL;
}
public void setThumbnailURL(String thumbnailURL) {
this.thumbnailURL = thumbnailURL;
}
@Override
public String toString() {
return "ItemBean [id=" + id + ", name=" + name
+ ", alternativeName=" + alternativeName + ", thumbnailURL=" + thumbnailURL
+ "]";
}
}

@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>PickItem Widget Project</title>
<script type="text/javascript" language="javascript" src="pickitem/pickitem.nocache.js"></script>
</head>
<body>
</body>
</html>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>PickUser.html</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<!-- Inherit our applications main module. -->
<inherits name='org.gcube.portlets.widgets.pickitem.PickUser' />
</module>
Loading…
Cancel
Save