com.jalios.jcmsplugin.virtualdesktop
Class Desktop

java.lang.Object
  extended by com.jalios.jcmsplugin.virtualdesktop.Desktop
All Implemented Interfaces:
Serializable

public class Desktop
extends Object
implements Serializable

Since:
virtualdesktop-1.0
Version:
$Revision: 22731 $
See Also:
Serialized Form

Constructor Summary
Desktop()
          Default constructor to build a new empty desktop.
Desktop(File xmlFile)
          Creates a new Desktop from an XML File.
 
Method Summary
 void addTab(Tab tab)
          Add the specified tab at the end of the current Tab list.
static boolean canEditDesktop(Member mbr, Data data)
          Check that the specified Member is allowed to edit the Desktop of the specified Data.
 Service findService(String serviceId)
          Find a service anywhere in this Desktop based on the specified service id.
 String getCss()
          Retrieve the theme of this desktop.
static Desktop getDesktop(JcmsContext context)
          Retrieve the desktop associated to the specified JcmsContext.
static Data getDesktopDataOwner(JcmsContext context)
          Retrieve the Data for which the desktop is being displayed/edited in the current context.
static Desktop getFromExtraDBData(Data data)
          Retrieve the Desktop stored in the extradbdata of the specified Data, if any.
static Desktop getFromExtraInfo(Data data)
          Retrieve the Desktop stored in the extrainfo of the specified Data, if any.
 String getId()
          Retrieves the id of this desktopElement
 long getLastAccessTime()
          Retrieve the last access time of this desktop.
 Tab getSelectedTab()
          Retrieve the Tab to open when accessing this Desktop.
 String getShortName()
          Returns the short name of this class to use of all instance.
 Tab getTab(String tabId)
          Retrieve a tab of this desktop from its id.
 List<Tab> getTabList()
          Retrieve the list of tab of this Desktop.
static boolean removeOldDesktopFromExtraInfo(Data data, long expirationDelay)
          Remove the Desktop from the extra info of the specified Data if the desktop last access time is older than the specified expiration delay.
 void removeTab(Tab tab)
          Remove the specified tab from the current Tab list.
 void saveInExtraDBData(Data data)
          Save this Desktop in the specified Data's extradbdata
 void saveInExtraInfo(Data data)
          Save this Desktop in the specified data's extrainfo
 void setCss(String css)
          Set the theme of this desktop.
static void setDesktopDataOwner(JcmsContext context, Data data)
          Set the Data for which the Desktop will be edited in the current context.
 void setLastAccessTime()
          Set the last access time of this desktop to current time.
 void setSelectedTab(Tab tab)
          Set the Tab to be opened when accessing this Destkop
 String toString()
           
 String toXml()
          Serialize this Desktop into an XML String.
 String toXml(boolean outputId)
          Serialize this Desktop into an XML String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Desktop

public Desktop()
Default constructor to build a new empty desktop.


Desktop

public Desktop(File xmlFile)
        throws org.jdom.JDOMException,
               IOException,
               com.jalios.jcmsplugin.virtualdesktop.DesktopElement.ParseException
Creates a new Desktop from an XML File.

Parameters:
xmlFile - a valid XML File
Throws:
IOException - if the File could not be read
org.jdom.JDOMException - if the XML file could not be parsed
ParseException - when xml could not be parse to create Desktop elements
com.jalios.jcmsplugin.virtualdesktop.DesktopElement.ParseException
Since:
virtualdesktop-1.0
Method Detail

getShortName

public String getShortName()
Returns the short name of this class to use of all instance. e.g. "desktop", "tab", "column", "service"

Returns:
a string, common to all instance of the same type

getCss

public String getCss()
Retrieve the theme of this desktop.

Returns:
a theme name
Since:
virtualdesktop-1.0
See Also:
DesktopManager.getThemes()

setCss

public void setCss(String css)
Set the theme of this desktop.

Parameters:
css - a theme name taken from DesktopManager.getThemes()
Since:
virtualdesktop-1.0

getLastAccessTime

public long getLastAccessTime()
Retrieve the last access time of this desktop.

Returns:
an epoch time in millis

setLastAccessTime

public void setLastAccessTime()
Set the last access time of this desktop to current time.


getTabList

public List<Tab> getTabList()
Retrieve the list of tab of this Desktop.

Returns:
a List of Tab, never return null.

getTab

public Tab getTab(String tabId)
Retrieve a tab of this desktop from its id.

Parameters:
tabId - the id of the tab
Returns:
a Tab instance of null if it could not be found.

addTab

public void addTab(Tab tab)
Add the specified tab at the end of the current Tab list.

Parameters:
tab - the Tab to add (if null, no operation is performed)

removeTab

public void removeTab(Tab tab)
Remove the specified tab from the current Tab list.

Parameters:
tab - the Tab to remove (if null, no operation is performed)

setSelectedTab

public void setSelectedTab(Tab tab)
Set the Tab to be opened when accessing this Destkop

Parameters:
tab - the Tab to open

getSelectedTab

public Tab getSelectedTab()
Retrieve the Tab to open when accessing this Desktop.

Returns:
the selected Tab or the first one if none has been selected (return null if this Desktop does not contains any Tab yet)

findService

public Service findService(String serviceId)
Find a service anywhere in this Desktop based on the specified service id.

Parameters:
serviceId - the id of the Service to look for.
Returns:
the Service matching the specified serviceId or null if it could not be found.

getDesktop

public static Desktop getDesktop(JcmsContext context)
Retrieve the desktop associated to the specified JcmsContext.

Create a new default desktop if none could be found.
Update the last access time of the desktop.

Parameters:
context - the current JcmsContext
Returns:
the existing user desktop or a new default one otherwise
Since:
virtualdesktop-1.0
See Also:
getFromExtraDBData(Data)

getDesktopDataOwner

public static Data getDesktopDataOwner(JcmsContext context)
Retrieve the Data for which the desktop is being displayed/edited in the current context.

Usually returns the logged Member, except when an administrator has requested Desktop edition of a Workspace, Group or any other relevant Data.

Parameters:
context - the current JcmsContext
Returns:
the Data for which the Desktop will be edited in the current context, returns null if the specified context is null

setDesktopDataOwner

public static void setDesktopDataOwner(JcmsContext context,
                                       Data data)
Set the Data for which the Desktop will be edited in the current context.

Parameters:
context - the current JcmsContext
data - the Data to be associated in the current context

canEditDesktop

public static boolean canEditDesktop(Member mbr,
                                     Data data)
Check that the specified Member is allowed to edit the Desktop of the specified Data.

Rules that applies as of current implementation depending on Data instance:

Parameters:
mbr - the Member for which right access are being checked
data - the Data in which the desktop will be saved
Returns:
true if the member can edit the Desktop of the data, false otherwise.

saveInExtraInfo

public void saveInExtraInfo(Data data)
Save this Desktop in the specified data's extrainfo

Parameters:
data - the Data for which the Desktop will be saved
Since:
virtualdesktop-1.0

getFromExtraInfo

public static Desktop getFromExtraInfo(Data data)
Retrieve the Desktop stored in the extrainfo of the specified Data, if any.

Parameters:
data - the Data for which the Desktop is being retrieved
Returns:
the Desktop instance previously stored in Data's extrainfo with saveInExtraInfo(Data)
Since:
virtualdesktop-1.0

removeOldDesktopFromExtraInfo

public static boolean removeOldDesktopFromExtraInfo(Data data,
                                                    long expirationDelay)
Remove the Desktop from the extra info of the specified Data if the desktop last access time is older than the specified expiration delay.

Parameters:
data - the data from which to remove extra info
expirationDelay - delay (in minutes) above which the desktop is removed if has not been accessed
Returns:
true if the Data's Desktop has been and remove, false otherwise (returns false if no desktop was found for this data).

saveInExtraDBData

public void saveInExtraDBData(Data data)
Save this Desktop in the specified Data's extradbdata

Parameters:
data - the Data for which the Desktop will be saved
Since:
virtualdesktop-1.0

getFromExtraDBData

public static Desktop getFromExtraDBData(Data data)
Retrieve the Desktop stored in the extradbdata of the specified Data, if any.

Parameters:
data - the Data for which the Desktop is being retrieved
Returns:
the Desktop instance previously stored in Data's extradbdata with saveInExtraDBData(Data)
Since:
virtualdesktop-1.0

toXml

public String toXml()
Serialize this Desktop into an XML String.

Returns:
a new XML string with appropriate XML header.
Since:
virtualdesktop-1.0

toXml

public String toXml(boolean outputId)
Serialize this Desktop into an XML String.

Parameters:
outputId - false to skipt "id" attribute in xml element.
Returns:
a new XML string with appropriate XML header.
Since:
virtualdesktop-1.0

getId

public final String getId()
Retrieves the id of this desktopElement

Returns:
a unique identifier

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2007 Jalios SA. All Rights Reserved.