WorkspaceLightTree

From Gcube Wiki
Revision as of 15:14, 31 August 2012 by Federico.defaveri (Talk | contribs) (How to use the library)

Jump to: navigation, search

The Workspace Light Tree widget offers to the developers a "File Chooser" like GWT component to access the user's Workspace information. Like a File Chooser let choose a File the WorkspaceLightTree let the user select a WorkspaceItem.

Available Panels

The main panel is the WorkspaceLightTreePanel which shows the user Workspace tree where the user can select the WorkspaceItem. The developer can set which types of items are selectable and which are showable. All events are propagated through the GWT handling system. All the background login (contacting the HomeLibrary, loading the Workspace, converting the items) is hidden to the developer.

As support to common actions, selection of items to load or open and selection of items to save, three additional panel have been added:

  • WorkspaceLightTreeLoadPopup a pop-up panel that let the user to select an item for loading.
  • WorkspaceLightTreeSavePanel a save panel where the user can select a destination item (both folder and/or folder item) and if required can digit an item name (validated through the HomeLibrary).
  • WorkspaceLightTreeSavePopup a popup version of the save panel.

How to use the library

In the INSTALL file the developer can find the most updated information. Here the last available information:

To use this widget some steps are required:
1. setup your gwt xml module configuration file adding this line:
	 <inherits name='org.gcube.portlets.user.workspace.lighttree.WorkspacePortletLightTree'/>
 
2. add the light tree jar to your eclipse project as library (the home library is also needed, please read the homelibrary 
	INSTALL instructions)
3. setup your web.xml adding this lines:
    <servlet>
        <servlet-name>WorkspaceLightService</servlet-name>
         <servlet-class>org.gcube.portlets.user.workspace.lighttree.server.WorkspaceServiceImpl</servlet-class>
    </servlet>
 
    <servlet-mapping>
       <servlet-name>WorkspaceLightService</servlet-name>
       <url-pattern>/[YOUR APPLICATION SUFFIX]/WorkspaceLightService</url-pattern>
    </servlet-mapping>
 
4. Check in your portlet which is the username attribute name. The lighttree expect to find the username on httpsession attributes 
	with the name "username"

Examples

Here some usage examples. For more examples and demo code please checkout the WorkspaceLightTreeSample project from d4science svn site.

Simple load popup

  WorkspaceLightTreeLoadPopup popup = new WorkspaceLightTreeLoadPopup("Show the entire tree - all items selectable", false, true);
  popup.addPopupHandler(<my popup handler>);
  popup.show();

QueryItem selection

  WorkspaceLightTreeLoadPopup popup = new WorkspaceLightTreeLoadPopup("Show all items - only query selectable", false, true);
 
  //only the query item can be selected
  popup.setSelectableTypes(ItemType.QUERY);
  popup.addPopupHandler(<my popup handler>);
  popup.show();

Simple save popup

  WorkspaceLightTreeSavePopup popup = new WorkspaceLightTreeSavePopup("Show the entire tree - only folder selectable - name field", true);
 
  //only the basket item can be selected
  popup.setSelectableTypes(ItemType.FOLDER);
  popup.addPopupHandler(<my popup handler>);
  popup.show();