Adempiere 3.5.2a

org.compiere.util
Class Env

java.lang.Object
  extended by org.compiere.util.Env

public final class Env
extends Object

System Environment and static variables.

Version:
$Id: Env.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
Author:
Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL
  • BF [ 1619390 ] Use default desktop browser as external browser
  • BF [ 2017987 ] Env.getContext(TAB_INFO) should NOT use global context

  • Field Summary
    static String LANGUAGE
              Context Language identifier
    static String NL
              New Line
    static BigDecimal ONE
              Big Decimal 1
    static BigDecimal ONEHUNDRED
              Big Decimal 100
    static String POS_ID
              Context for POS ID
    static int TAB_INFO
              Tab for Info
    static int WINDOW_CUSTOMIZE
              WindowNo for PrintCustomize
    static int WINDOW_FIND
              WindowNo for Find
    static int WINDOW_INFO
              WindowNo for PrintCustomize
    static int WINDOW_MLOOKUP
              WinowNo for MLookup
    static BigDecimal ZERO
              Big Decimal 0
     
    Constructor Summary
    Env()
               
     
    Method Summary
    static void clearContext()
              Clean up all context (i.e. delete it)
    static void clearContext(Properties ctx)
              Clean up all context (i.e. delete it)
    static void clearWinContext(int WindowNo)
              Clean up context for Window (i.e. delete it)
    static void clearWinContext(Properties ctx, int WindowNo)
              Clean up context for Window (i.e. delete it)
    static int createWindowNo(Container win)
              Add Container and return WindowNo.
    static void exitEnv(int status)
              Exit System
    static int getAD_Client_ID(Properties ctx)
              Get Login AD_Client_ID
    static String getAD_Language(Properties ctx)
              Get System AD_Language
    static int getAD_Org_ID(Properties ctx)
              Get Login AD_Org_ID
    static int getAD_Role_ID(Properties ctx)
              Get Login AD_Role_ID
    static int getAD_User_ID(Properties ctx)
              Get Login AD_User_ID
    static String getContext(Properties ctx, int WindowNo, int TabNo, String context)
              Get Value of Context for Window & Tab, if not found global context if available.
    static String getContext(Properties ctx, int WindowNo, String context)
              Get Value of Context for Window.
    static String getContext(Properties ctx, int WindowNo, String context, boolean onlyWindow)
              Get Value of Context for Window.
    static String getContext(Properties ctx, String context)
              Get global Value of Context
    static Timestamp getContextAsDate(Properties ctx, int WindowNo, String context)
              Get Context and convert it to a Timestamp if error return today's date
    static Timestamp getContextAsDate(Properties ctx, String context)
              Get Context and convert it to a Timestamp if error return today's date
    static int getContextAsInt(Properties ctx, int WindowNo, int TabNo, String context)
              Get Context and convert it to an integer (0 if error)
    static int getContextAsInt(Properties ctx, int WindowNo, String context)
              Get Context and convert it to an integer (0 if error)
    static int getContextAsInt(Properties ctx, int WindowNo, String context, boolean onlyWindow)
              Get Context and convert it to an integer (0 if error)
    static int getContextAsInt(Properties ctx, String context)
              Get Context and convert it to an integer (0 if error)
    static Properties getCtx()
              Get Context
    static String[] getEntireContext(Properties ctx)
              Get Context as String array with format: key == value
    static JFrame getFrame(Container container)
              Get Frame of Window
    static Graphics getGraphics(Container container)
              Get Graphics of container or its parent.
    static String getHeader(Properties ctx, int WindowNo)
              Get Header info (connection, org, user)
    static Image getImage(String fileNameInImageDir)
              Get Image with File name
    static ImageIcon getImageIcon(String fileNameInImageDir)
              Get ImageIcon.
    static ImageIcon getImageIcon2(String fileName)
              Get ImageIcon.
    static Language getLanguage(Properties ctx)
              Get System Language
    static Language getLoginLanguage(Properties ctx)
              Get Login Language
    static Window getParent(Container container)
              Return JDialog or JFrame Parent
    static String getPreference(Properties ctx, int AD_Window_ID, String context, boolean system)
              Get Preference.
    static JFrame getWindow(int WindowNo)
              Return the JFrame pointer of WindowNo - or null
    static int getWindowNo(Container container)
              Search Window by comparing the Frames
    static boolean hideWindow(CFrame window)
              Hide Window
    static boolean isAutoCommit(Properties ctx)
              Is AutoCommit
    static boolean isAutoCommit(Properties ctx, int WindowNo)
              Is Window AutoCommit (if not set use default)
    static boolean isAutoNew(Properties ctx)
              Is Auto New Record
    static boolean isAutoNew(Properties ctx, int WindowNo)
              Is Window Auto New Record (if not set use default)
    static boolean isBaseLanguage(Language language, String tableName)
              Check Base Language
    static boolean isBaseLanguage(Properties ctx, String tableName)
              Check Base Language
    static boolean isBaseLanguage(String AD_Language, String tableName)
              Check Base Language
    static boolean isBaseTranslation(String tableName)
              Table is in Base Translation (AD)
    static boolean isMac()
              Do we run on Apple
    static boolean isMultiLingualDocument(Properties ctx)
              Do we have Multi-Lingual Documents.
    static boolean isSOTrx(Properties ctx)
              Is Sales Order Trx
    static boolean isSOTrx(Properties ctx, int WindowNo)
              Is Sales Order Trx
    static boolean isWindows()
              Do we run on Windows
    static void logout()
              Logout from the system
    static String parseContext(Properties ctx, int WindowNo, String value, boolean onlyWindow)
              Parse Context replaces global or Window context @tag@ with actual value.
    static String parseContext(Properties ctx, int WindowNo, String value, boolean onlyWindow, boolean ignoreUnparsable)
              Parse Context replaces global or Window context @tag@ with actual value.
    static String parseVariable(String expression, PO po, String trxName, boolean keepUnparseable)
              Parse expression, replaces global or PO properties @tag@ with actual value.
    static void reset(boolean finalCall)
              Reset Cache
    static void setAutoCommit(Properties ctx, boolean autoCommit)
              Set Auto Commit
    static void setAutoCommit(Properties ctx, int WindowNo, boolean autoCommit)
              Set Auto Commit for Window
    static void setAutoNew(Properties ctx, boolean autoNew)
              Set Auto New Record
    static void setAutoNew(Properties ctx, int WindowNo, boolean autoNew)
              Set Auto New Record for Window
    static void setContext(Properties ctx, int WindowNo, int TabNo, String context, String value)
              Set Context for Window & Tab to Value
    static void setContext(Properties ctx, int WindowNo, String context, boolean value)
              Set Context for Window to Y/N Value
    static void setContext(Properties ctx, int WindowNo, String context, int value)
              Set Context for Window to int Value
    static void setContext(Properties ctx, int WindowNo, String context, String value)
              Set Context for Window to Value
    static void setContext(Properties ctx, int WindowNo, String context, Timestamp value)
              Set Context for Window to Value
    static void setContext(Properties ctx, String context, boolean value)
              Set Global Context to Y/N Value
    static void setContext(Properties ctx, String context, int value)
              Set Global Context to (int) Value
    static void setContext(Properties ctx, String context, String value)
              Set Global Context to Value
    static void setContext(Properties ctx, String context, Timestamp value)
              Set Global Context to Value
    static void setContextProvider(ContextProvider provider)
               
    static void setCtx(Properties ctx)
              Set Context
    static void setSOTrx(Properties ctx, boolean isSOTrx)
              Set SO Trx
    static CFrame showWindow(int AD_Window_ID)
              Show Window
    static void sleep(int sec)
              Sleep
    static void startBrowser(String url)
              Start Browser
    static Set<Window> updateUI()
              Update all windows after look and feel changes.
    static void verifyLanguage(Properties ctx, Language language)
              Verify Language.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    WINDOW_FIND

    public static final int WINDOW_FIND
    WindowNo for Find

    See Also:
    Constant Field Values

    WINDOW_MLOOKUP

    public static final int WINDOW_MLOOKUP
    WinowNo for MLookup

    See Also:
    Constant Field Values

    WINDOW_CUSTOMIZE

    public static final int WINDOW_CUSTOMIZE
    WindowNo for PrintCustomize

    See Also:
    Constant Field Values

    WINDOW_INFO

    public static final int WINDOW_INFO
    WindowNo for PrintCustomize

    See Also:
    Constant Field Values

    TAB_INFO

    public static final int TAB_INFO
    Tab for Info

    See Also:
    Constant Field Values

    LANGUAGE

    public static final String LANGUAGE
    Context Language identifier

    See Also:
    Constant Field Values

    POS_ID

    public static final String POS_ID
    Context for POS ID

    See Also:
    Constant Field Values

    ZERO

    public static final BigDecimal ZERO
    Big Decimal 0


    ONE

    public static final BigDecimal ONE
    Big Decimal 1


    ONEHUNDRED

    public static final BigDecimal ONEHUNDRED
    Big Decimal 100


    NL

    public static final String NL
    New Line

    Constructor Detail

    Env

    public Env()
    Method Detail

    setContextProvider

    public static void setContextProvider(ContextProvider provider)

    exitEnv

    public static void exitEnv(int status)
    Exit System

    Parameters:
    status - System exit status (usually 0 for no error)

    logout

    public static void logout()
    Logout from the system


    reset

    public static void reset(boolean finalCall)
    Reset Cache

    Parameters:
    finalCall - everything otherwise login data remains

    getCtx

    public static final Properties getCtx()
    Get Context

    Returns:
    Properties

    setCtx

    public static void setCtx(Properties ctx)
    Set Context

    Parameters:
    ctx - context

    setContext

    public static void setContext(Properties ctx,
                                  String context,
                                  String value)
    Set Global Context to Value

    Parameters:
    ctx - context
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  String context,
                                  Timestamp value)
    Set Global Context to Value

    Parameters:
    ctx - context
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  String context,
                                  int value)
    Set Global Context to (int) Value

    Parameters:
    ctx - context
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  String context,
                                  boolean value)
    Set Global Context to Y/N Value

    Parameters:
    ctx - context
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  int WindowNo,
                                  String context,
                                  String value)
    Set Context for Window to Value

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  int WindowNo,
                                  String context,
                                  Timestamp value)
    Set Context for Window to Value

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  int WindowNo,
                                  String context,
                                  int value)
    Set Context for Window to int Value

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  int WindowNo,
                                  String context,
                                  boolean value)
    Set Context for Window to Y/N Value

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    value - context value

    setContext

    public static void setContext(Properties ctx,
                                  int WindowNo,
                                  int TabNo,
                                  String context,
                                  String value)
    Set Context for Window & Tab to Value

    Parameters:
    ctx - context
    WindowNo - window no
    TabNo - tab no
    context - context key
    value - context value

    setAutoCommit

    public static void setAutoCommit(Properties ctx,
                                     boolean autoCommit)
    Set Auto Commit

    Parameters:
    ctx - context
    autoCommit - auto commit (save)

    setAutoCommit

    public static void setAutoCommit(Properties ctx,
                                     int WindowNo,
                                     boolean autoCommit)
    Set Auto Commit for Window

    Parameters:
    ctx - context
    WindowNo - window no
    autoCommit - auto commit (save)

    setAutoNew

    public static void setAutoNew(Properties ctx,
                                  boolean autoNew)
    Set Auto New Record

    Parameters:
    ctx - context
    autoNew - auto new record

    setAutoNew

    public static void setAutoNew(Properties ctx,
                                  int WindowNo,
                                  boolean autoNew)
    Set Auto New Record for Window

    Parameters:
    ctx - context
    WindowNo - window no
    autoNew - auto new record

    setSOTrx

    public static void setSOTrx(Properties ctx,
                                boolean isSOTrx)
    Set SO Trx

    Parameters:
    ctx - context
    isSOTrx - SO Context

    getContext

    public static String getContext(Properties ctx,
                                    String context)
    Get global Value of Context

    Parameters:
    ctx - context
    context - context key
    Returns:
    value or ""

    getContext

    public static String getContext(Properties ctx,
                                    int WindowNo,
                                    String context,
                                    boolean onlyWindow)
    Get Value of Context for Window. if not found global context if available and enabled

    Parameters:
    ctx - context
    WindowNo - window
    context - context key
    onlyWindow - if true, no defaults are used unless explicitly asked for
    Returns:
    value or ""

    getContext

    public static String getContext(Properties ctx,
                                    int WindowNo,
                                    String context)
    Get Value of Context for Window. if not found global context if available

    Parameters:
    ctx - context
    WindowNo - window
    context - context key
    Returns:
    value or ""

    getContext

    public static String getContext(Properties ctx,
                                    int WindowNo,
                                    int TabNo,
                                    String context)
    Get Value of Context for Window & Tab, if not found global context if available. If TabNo is TAB_INFO only tab's context will be checked.

    Parameters:
    ctx - context
    WindowNo - window no
    TabNo - tab no
    context - context key
    Returns:
    value or ""

    getContextAsInt

    public static int getContextAsInt(Properties ctx,
                                      String context)
    Get Context and convert it to an integer (0 if error)

    Parameters:
    ctx - context
    context - context key
    Returns:
    value

    getContextAsInt

    public static int getContextAsInt(Properties ctx,
                                      int WindowNo,
                                      String context)
    Get Context and convert it to an integer (0 if error)

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    Returns:
    value or 0

    getContextAsInt

    public static int getContextAsInt(Properties ctx,
                                      int WindowNo,
                                      String context,
                                      boolean onlyWindow)
    Get Context and convert it to an integer (0 if error)

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    onlyWindow - if true, no defaults are used unless explicitly asked for
    Returns:
    value or 0

    getContextAsInt

    public static int getContextAsInt(Properties ctx,
                                      int WindowNo,
                                      int TabNo,
                                      String context)
    Get Context and convert it to an integer (0 if error)

    Parameters:
    ctx - context
    WindowNo - window no
    TabNo - tab no
    context - context key
    Returns:
    value or 0

    isAutoCommit

    public static boolean isAutoCommit(Properties ctx)
    Is AutoCommit

    Parameters:
    ctx - context
    Returns:
    true if auto commit

    isAutoCommit

    public static boolean isAutoCommit(Properties ctx,
                                       int WindowNo)
    Is Window AutoCommit (if not set use default)

    Parameters:
    ctx - context
    WindowNo - window no
    Returns:
    true if auto commit

    isAutoNew

    public static boolean isAutoNew(Properties ctx)
    Is Auto New Record

    Parameters:
    ctx - context
    Returns:
    true if auto new

    isAutoNew

    public static boolean isAutoNew(Properties ctx,
                                    int WindowNo)
    Is Window Auto New Record (if not set use default)

    Parameters:
    ctx - context
    WindowNo - window no
    Returns:
    true if auto new record

    isSOTrx

    public static boolean isSOTrx(Properties ctx)
    Is Sales Order Trx

    Parameters:
    ctx - context
    Returns:
    true if SO (default)

    isSOTrx

    public static boolean isSOTrx(Properties ctx,
                                  int WindowNo)
    Is Sales Order Trx

    Parameters:
    ctx - context
    WindowNo - window no
    Returns:
    true if SO (default)

    getContextAsDate

    public static Timestamp getContextAsDate(Properties ctx,
                                             String context)
    Get Context and convert it to a Timestamp if error return today's date

    Parameters:
    ctx - context
    context - context key
    Returns:
    Timestamp

    getContextAsDate

    public static Timestamp getContextAsDate(Properties ctx,
                                             int WindowNo,
                                             String context)
    Get Context and convert it to a Timestamp if error return today's date

    Parameters:
    ctx - context
    WindowNo - window no
    context - context key
    Returns:
    Timestamp

    getAD_Client_ID

    public static int getAD_Client_ID(Properties ctx)
    Get Login AD_Client_ID

    Parameters:
    ctx - context
    Returns:
    login AD_Client_ID

    getAD_Org_ID

    public static int getAD_Org_ID(Properties ctx)
    Get Login AD_Org_ID

    Parameters:
    ctx - context
    Returns:
    login AD_Org_ID

    getAD_User_ID

    public static int getAD_User_ID(Properties ctx)
    Get Login AD_User_ID

    Parameters:
    ctx - context
    Returns:
    login AD_User_ID

    getAD_Role_ID

    public static int getAD_Role_ID(Properties ctx)
    Get Login AD_Role_ID

    Parameters:
    ctx - context
    Returns:
    login AD_Role_ID

    getPreference

    public static String getPreference(Properties ctx,
                                       int AD_Window_ID,
                                       String context,
                                       boolean system)
    Get Preference.
                    0)      Current Setting
                    1)      Window Preference
                    2)      Global Preference
                    3)      Login settings
                    4)      Accounting settings
      

    Parameters:
    ctx - context
    AD_Window_ID - window no
    context - Entity to search
    system - System level preferences (vs. user defined)
    Returns:
    preference value

    isBaseLanguage

    public static boolean isBaseLanguage(Properties ctx,
                                         String tableName)
    Check Base Language

    Parameters:
    ctx - context
    tableName - table to be translated
    Returns:
    true if base language and table not translated

    isBaseLanguage

    public static boolean isBaseLanguage(String AD_Language,
                                         String tableName)
    Check Base Language

    Parameters:
    AD_Language - language
    tableName - table to be translated
    Returns:
    true if base language and table not translated

    isBaseLanguage

    public static boolean isBaseLanguage(Language language,
                                         String tableName)
    Check Base Language

    Parameters:
    language - language
    tableName - table to be translated
    Returns:
    true if base language and table not translated

    isBaseTranslation

    public static boolean isBaseTranslation(String tableName)
    Table is in Base Translation (AD)

    Parameters:
    tableName - table
    Returns:
    true if base trl

    isMultiLingualDocument

    public static boolean isMultiLingualDocument(Properties ctx)
    Do we have Multi-Lingual Documents. Set in DB.loadOrgs

    Parameters:
    ctx - context
    Returns:
    true if multi lingual documents

    getAD_Language

    public static String getAD_Language(Properties ctx)
    Get System AD_Language

    Parameters:
    ctx - context
    Returns:
    AD_Language eg. en_US

    getLanguage

    public static Language getLanguage(Properties ctx)
    Get System Language

    Parameters:
    ctx - context
    Returns:
    Language

    getLoginLanguage

    public static Language getLoginLanguage(Properties ctx)
    Get Login Language

    Parameters:
    ctx - context
    Returns:
    Language

    verifyLanguage

    public static void verifyLanguage(Properties ctx,
                                      Language language)
    Verify Language. Check that language is supported by the system

    Parameters:
    ctx - might be updated with new AD_Language
    language - language

    getEntireContext

    public static String[] getEntireContext(Properties ctx)
    Get Context as String array with format: key == value

    Parameters:
    ctx - context
    Returns:
    context string

    getHeader

    public static String getHeader(Properties ctx,
                                   int WindowNo)
    Get Header info (connection, org, user)

    Parameters:
    ctx - context
    WindowNo - window
    Returns:
    Header String

    clearWinContext

    public static void clearWinContext(Properties ctx,
                                       int WindowNo)
    Clean up context for Window (i.e. delete it)

    Parameters:
    ctx - context
    WindowNo - window

    clearContext

    public static void clearContext(Properties ctx)
    Clean up all context (i.e. delete it)

    Parameters:
    ctx - context

    parseContext

    public static String parseContext(Properties ctx,
                                      int WindowNo,
                                      String value,
                                      boolean onlyWindow,
                                      boolean ignoreUnparsable)
    Parse Context replaces global or Window context @tag@ with actual value.

    Parameters:
    ctx - context
    WindowNo - Number of Window
    value - Message to be parsed
    onlyWindow - if true, no defaults are used
    ignoreUnparsable - if true, unsuccessful @return parsed String or "" if not successful and ignoreUnparsable
    Returns:
    parsed context

    parseContext

    public static String parseContext(Properties ctx,
                                      int WindowNo,
                                      String value,
                                      boolean onlyWindow)
    Parse Context replaces global or Window context @tag@ with actual value.

    Parameters:
    ctx - context
    WindowNo - Number of Window
    value - Message to be parsed
    onlyWindow - if true, no defaults are used
    Returns:
    parsed String or "" if not successful

    parseVariable

    public static String parseVariable(String expression,
                                       PO po,
                                       String trxName,
                                       boolean keepUnparseable)
    Parse expression, replaces global or PO properties @tag@ with actual value.

    Parameters:
    expression -
    po -
    trxName -
    Returns:
    String

    createWindowNo

    public static int createWindowNo(Container win)
    Add Container and return WindowNo. The container is a APanel, AWindow or JFrame/JDialog

    Parameters:
    win - window
    Returns:
    WindowNo used for context

    getWindowNo

    public static int getWindowNo(Container container)
    Search Window by comparing the Frames

    Parameters:
    container - container
    Returns:
    WindowNo of container or 0

    getWindow

    public static JFrame getWindow(int WindowNo)
    Return the JFrame pointer of WindowNo - or null

    Parameters:
    WindowNo - window
    Returns:
    JFrame of WindowNo

    clearWinContext

    public static void clearWinContext(int WindowNo)
    Clean up context for Window (i.e. delete it)

    Parameters:
    WindowNo - window

    clearContext

    public static void clearContext()
    Clean up all context (i.e. delete it)


    getFrame

    public static JFrame getFrame(Container container)
    Get Frame of Window

    Parameters:
    container - Container
    Returns:
    JFrame of container or null

    getGraphics

    public static Graphics getGraphics(Container container)
    Get Graphics of container or its parent. The element may not have a Graphic if not displayed yet, but the parent might have.

    Parameters:
    container - Container
    Returns:
    Graphics of container or null

    getParent

    public static Window getParent(Container container)
    Return JDialog or JFrame Parent

    Parameters:
    container - Container
    Returns:
    JDialog or JFrame of container

    getImage

    public static Image getImage(String fileNameInImageDir)
    Get Image with File name

    Parameters:
    fileNameInImageDir - full file name in imgaes folder (e.g. Bean16.gif)
    Returns:
    image

    getImageIcon

    public static ImageIcon getImageIcon(String fileNameInImageDir)
    Get ImageIcon.

    Parameters:
    fileNameInImageDir - full file name in imgaes folder (e.g. Bean16.gif)
    Returns:
    image

    getImageIcon2

    public static ImageIcon getImageIcon2(String fileName)
    Get ImageIcon. This method different from getImageIcon where the fileName parameter is without extension. The method will first try .gif and then .png if .gif does not exists.

    Parameters:
    fileName - file name in imgaes folder without the extension(e.g. Bean16)
    Returns:
    image

    startBrowser

    public static void startBrowser(String url)
    Start Browser

    Parameters:
    url - url

    isMac

    public static boolean isMac()
    Do we run on Apple

    Returns:
    true if Mac

    isWindows

    public static boolean isWindows()
    Do we run on Windows

    Returns:
    true if windows

    hideWindow

    public static boolean hideWindow(CFrame window)
    Hide Window

    Parameters:
    window - window
    Returns:
    true if window is hidden, otherwise close it

    showWindow

    public static CFrame showWindow(int AD_Window_ID)
    Show Window

    Parameters:
    AD_Window_ID - window
    Returns:
    true if window re-displayed

    sleep

    public static void sleep(int sec)
    Sleep

    Parameters:
    sec - seconds

    updateUI

    public static Set<Window> updateUI()
    Update all windows after look and feel changes.

    Since:
    2006-11-27

    Adempiere 3.5.2a

    Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.