telosys
Blame | Last modification | View Log | RSS feed
package org.objectweb.telosys.uil.screenmap;
import org.objectweb.telosys.common.TelosysObject;
import org.objectweb.telosys.common.TelosysRuntimeException;
import org.objectweb.telosys.common.TelosysVersion;
import org.objectweb.telosys.uil.TelosysUIL;
/**
* This class provides the attributes loaded from the "<config>" tag of the "screens.xml" file <br>
* <br>
* Only one instance of this class ( held by ScreenDefinitions )
*
* @author Laurent GUERIN
*
*/
public class ScreenDefConfig extends TelosysObject
{
// <config default_action
private String _sDefaultAction = null ;
// <config telosys_jar_file
private String _sTelosysJarFile = null ;
// <config telosys_framework_file
private String _sTelosysFrameworkFile = null ;
// <config framework_css_dir
private String _sFrameworkCSSDir = null ;
// <config ajax_request_url
private String _sAjaxRequestUrl = null ;
// <config screen_map_url
private String _sScreenMapUrl = null ;
// <config base_language
private String _sBaseLanguage = null ;
// <config all_languages
private String _sAllLanguages = null ;
/**
* Constructor
*/
public ScreenDefConfig()
{
super();
//--- Set the default values
_sDefaultAction = "none";
//_sTelosysJarFile = getFullPathFile("/WEB-INF/lib/telosys-"+ TelosysVersion.VERSION.trim() + ".jar", true);
_sTelosysJarFile = "/WEB-INF/lib/telosys-"+ TelosysVersion.VERSION.trim() + ".jar" ;
_sTelosysFrameworkFile = "/telosys/telosys.js";
_sFrameworkCSSDir = "/telosys";
_sAjaxRequestUrl = "/action" ;
_sScreenMapUrl = "/screenmap" ;
}
//---------------------------------------------------------------------------
// private String getFullPathFile(String sFile, boolean bMustExist)
// {
// if (sFile != null)
// {
// //--- Determine Full Path
// String sFullPath = null;
// // if ( sFile.startsWith(".") ) // RELATIVE
// // {
// // //--- Cut the first char
// // sFile = sFile.substring(1);
// //--- Full path = Application root dir + relative file name
// sFullPath = Telosys.getFullPath(sFile);
// // }
// // else // ABSOLUTE
// // {
// // sFullPath = sFile;
// // }
//
// //--- Check existence (if needed)
// if (bMustExist)
// {
// File file = new File(sFullPath);
// if (file.exists())
// {
// return sFullPath;
// }
// }
// else
// {
// return sFullPath;
// }
// }
// return null;
// }
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Context : Auto-Open Context mode
//---------------------------------------------------------------------------
/**
* Set the default action
* @param s action ( "none" or "open" or "use" )
*/
/* package */ void setDefaultAction(String s)
{
trace("setDefaultAction(" + s +")");
if ( s != null )
{
String s2 = s.trim().toLowerCase() ;
if ( s2.equals("none") || s2.equals("open") || s2.equals("use") )
{
_sDefaultAction = s2;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid default action : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the default action for the screen ( "open", "use", "none" )
* @return the default action ( never null : "none" by default )
*/
public String getDefaultAction()
{
return _sDefaultAction;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Telosys Framework Javascript File
//---------------------------------------------------------------------------
/**
* Set the web context path for the telosys javascript framework file
* @param s ( ie: "/js/telosys.js" )
*/
/* package */ void setFrameworkJavascriptFile(String s)
{
trace("setFrameworkJavascriptFile(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
_sTelosysFrameworkFile = s.trim() ;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid Framework Javascript file : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the web context path of the javascript framework file
* @return the full path of the file ( ie: "/js/telosys.js" ), never null
*/
public String getFrameworkJavascriptFile()
{
return _sTelosysFrameworkFile;
}
//---------------------------------------------------------------------------
// /**
// * Returns the full filesystem path of the Telosys Framework Javascript file
// *
// * @return the path ( ie : "/filesystem_dir/web_dir/context_dir/js/telosys.js" )
// */
// public String getFrameworkJavascriptFilePath()
// {
// return getFullPathFile(_sTelosysFrameworkFile, false);
// }
//---------------------------------------------------------------------------
// Telosys Javascript framework URL
//---------------------------------------------------------------------------
// /* package */void setTelosysFrameworkUrl(String s)
// {
// _sTelosysFrameworkUrl = s;
// }
// //---------------------------------------------------------------------------
// public String getTelosysFrameworkUrl()
// {
// return _sTelosysFrameworkUrl;
// }
// public String getFrameworkJavascriptFilePath()
// {
// return _sTelosysFrameworkFile ;
// }
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Telosys CSS files
//---------------------------------------------------------------------------
/**
* Set the web context path for the framework CSS directory
* @param s the directory ( ie: "/css/telosys" )
*/
/* package */ void setFrameworkCSSDir(String s)
{
trace("setFrameworkCSSDir(" + s +")");
if (s != null)
{
if ( s.trim().length() > 0 )
{
_sFrameworkCSSDir = s.trim();
return ;
}
}
throw new TelosysRuntimeException("Config : invalid Framework CSS dir : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the web context path of the framework CSS directory
* @return the directory ( ie: "/css/telosys" ), never null
*/
public String getFrameworkCSSDir()
{
return _sFrameworkCSSDir ;
}
//---------------------------------------------------------------------------
// /**
// * Returns the full filesystem path of the framework CSS directory
// * @return the directory ( ie : "/filesystem_dir/web_dir/context_dir/css" )
// */
// public String getFrameworkCSSDirPath()
// {
// return Telosys.getFullPath ( _sFrameworkCSSDir );
// }
//---------------------------------------------------------------------------
/**
* Returns the web context path of a given framework CSS file
* @param sFileName ( ie : "image.png" )
* @return the full path with the directory ( ie: "/css/telosys/image.png" )
*/
public String getFrameworkCSSFile(String sFileName)
{
String sDir = _sFrameworkCSSDir;
if (!sDir.endsWith("/"))
{
sDir = sDir + "/";
}
return sDir + sFileName ;
}
//---------------------------------------------------------------------------
/**
* Returns the web context path of the framework CSS file
* @return the full path of the file ( ie: "/css/telosys/telosys.css" )
*/
public String getFrameworkCSSFile()
{
return getFrameworkCSSFile( TelosysUIL.TELOSYS_CSS_FILE );
}
//---------------------------------------------------------------------------
// /**
// * Returns the full filesystem path of the given CSS file name
// * @param sFileName ( ie : "image.png" )
// * @return the path ( ie : "/filesystem_dir/web_dir/context_dir/css/image.png" )
// */
// public String getFrameworkCSSFilePath(String sFileName)
// {
//// String sDir = _sFrameworkCSSDir;
//// if (!sDir.endsWith("/"))
//// {
//// sDir = sDir + "/";
//// }
// return getFullPathFile( getFrameworkCSSFile(sFileName), false);
// }
//
//---------------------------------------------------------------------------
// /**
// * Returns the full filesystem path of the Telosys Framework CSS file
// *
// * @return the path ( ie : "/filesystem_dir/web_dir/context_dir/css/telosys.css" )
// */
// public String getFrameworkCSSFilePath()
// {
// return getFrameworkCSSFilePath( TelosysUIL.TELOSYS_CSS_FILE ) ;
// }
//---------------------------------------------------------------------------
// Telosys JAR File
//---------------------------------------------------------------------------
/**
* Set the full file name of the telosys jar file <br>
* The file is set only if it is NOT NULL and NOT VOID
*
* @param s
*/
/* package */ void setTelosysJarFile(String s)
{
trace("setTelosysJarFile(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
//_sTelosysJarFile = getFullPathFile(s.trim(), true);
_sTelosysJarFile = s.trim();
return ;
}
}
// Else : keep the default file
//throw new TelosysRuntimeException("Config : invalid Telosys JAR file: '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the Telosys JAR file ( same as defined in the configuration file )
* @return the jar file ( e.g. "/WEB-INF/lib/telosys-1.0.0.jar" ), never null
*/
public String getTelosysJarFile()
{
return _sTelosysJarFile;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// AJAX request URL
//---------------------------------------------------------------------------
/**
* Set the URL to use for AJAX calls ( for screen actions )
* @param s the webcontext URL ( e.g. "/action" )
*/
/* package */ void setAjaxRequestUrl(String s)
{
trace("setAjaxRequestUrl(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
_sAjaxRequestUrl = s.trim() ;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid Ajax Request URL : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the URL to use for AJAX calls ( for screen actions )
* @return e.g. "/action" ( never null )
*/
public String getAjaxRequestUrl()
{
return _sAjaxRequestUrl;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Screen Map URL
//---------------------------------------------------------------------------
/**
* Set the URL to use to get a screenmap
* @param s the webcontext URL ( e.g. "/screenmap" )
*/
/* package */ void setScreenMapUrl(String s)
{
trace("setScreenMapUrl(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
_sScreenMapUrl = s.trim() ;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid ScreenMap URL : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the URL to use to get a screenmap
* @return e.g. "/screenmap" ( never null )
*/
public String getScreenMapUrl()
{
return _sScreenMapUrl;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// ScreenMap language
//---------------------------------------------------------------------------
/**
* Set the "base language" ( for i18n )
* @param s
*/
/* package */ void setBaseLanguage(String s)
{
trace("setBaseLanguage(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
_sBaseLanguage = s.trim() ;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid base language : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the "base language" ( for i18n )
* @return the "base language" or null
*/
public String getBaseLanguage()
{
return _sBaseLanguage;
}
//---------------------------------------------------------------------------
// All the languages used for i18n
//---------------------------------------------------------------------------
/**
* Set the languages string ( for i18n, languages supported by the translator )
* @param s ( e.g. "fr,en,de" )
*/
/* package */ void setAllLanguages(String s)
{
trace("setAllLanguages(" + s +")");
if ( s != null )
{
if ( s.trim().length() > 0 )
{
_sAllLanguages = s.trim() ;
return ;
}
}
throw new TelosysRuntimeException("Config : invalid languages list : '" + s + "'");
}
//---------------------------------------------------------------------------
/**
* Returns the languages string ( for i18n, languages supported by the translator )
* @return the string ( e.g. "fr,en,de" ), or null if not set
*/
public String getAllLanguages()
{
return _sAllLanguages;
}
//---------------------------------------------------------------------------
/**
* Returns the languages array ( for i18n, languages supported by the translator )
* @return the array ( e.g. { "fr","en","de" } ), or null if not set
*/
public String[] getAllLanguagesArray()
{
if ( _sAllLanguages != null )
{
String[] array = _sAllLanguages.split(",");
for ( int i = 0 ; i < array.length ; i++)
{
String s = array[i];
if ( s != null )
{
array[i] = s.trim();
}
}
return array ;
}
else
{
return null ;
}
}
//---------------------------------------------------------------------------
}
Generated by GNU enscript 1.6.4.