Class 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, www.arhipac.ro
  • BF [ 1619390 ] Use default desktop browser as external browser
  • BF [ 2017987 ] Env.getContext(TAB_INFO) should NOT use global context
  • FR [ 2392044 ] Introduce Env.WINDOW_MAIN
    • Constructor Detail

      • Env

        public Env()
    • Method Detail

      • setContextProvider

        public static void setContextProvider​(ContextProvider provider)
        Deprecated.
        Parameters:
        provider -
      • addEventListener

        public static void addEventListener​(IEnvEventListener listener)
        Parameters:
        listener -
      • removeEventListener

        public static boolean removeEventListener​(IEnvEventListener listener)
        Parameters:
        listener -
        Returns:
        boolean
      • 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)
        Replace the contents of the current session/process context. Don't use this to setup a new session/process context, use ServerContext.setCurrentInstance instead.
        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,
                                      int TabNo,
                                      String context,
                                      int 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,
                                      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 and Tab to Value
        Parameters:
        ctx - context
        WindowNo - window no
        TabNo - tab no
        context - context key
        value - context value
      • setAutoCommit

        @Deprecated
        public static void setAutoCommit​(Properties ctx,
                                         boolean autoCommit)
        Deprecated.
        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

        @Deprecated
        public static void setAutoNew​(Properties ctx,
                                      boolean autoNew)
        Deprecated.
        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 and 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 ""
      • getContext

        public static String getContext​(Properties ctx,
                                        int WindowNo,
                                        int TabNo,
                                        String context,
                                        boolean onlyTab)
        Get Value of Context for Window and 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
        onlyTab - if true, no window value is searched
        Returns:
        value or ""
      • getContext

        public static String getContext​(Properties ctx,
                                        int WindowNo,
                                        int TabNo,
                                        String context,
                                        boolean onlyTab,
                                        boolean onlyWindow)
        Get Value of Context for Window and 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
        onlyTab - if true, no window value is searched
        onlyWindow - if true, no global context will be searched
        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
      • getPreference

        public static String getPreference​(Properties ctx,
                                           int AD_Window_ID,
                                           int AD_InfoWindow,
                                           int AD_Process_ID_Of_Panel,
                                           String context)
        get preference of process from env
        Parameters:
        ctx -
        AD_Window_ID -
        AD_InfoWindow -
        AD_Process_ID_Of_Panel -
        context -
        Returns:
      • getPreference

        public static String getPreference​(Properties ctx,
                                           int AD_Window_ID,
                                           int AD_InfoWindow,
                                           String context)
        get preference of info window from env
        Parameters:
        ctx -
        AD_Window_ID -
        AD_InfoWindow -
        context -
        Returns:
      • 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
      • getLocaleLanguage

        public static Language getLocaleLanguage​(Properties ctx)
        Parameters:
        ctx -
        Returns:
        Language
      • getLocale

        public static Locale getLocale​(Properties ctx)
        Parameters:
        ctx -
        Returns:
        Locale
      • getSupportedLanguages

        public static ArrayList<String> getSupportedLanguages()
      • 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
      • clearTabContext

        public static void clearTabContext​(Properties ctx,
                                           int WindowNo,
                                           int TabNo)
        Clean up context for Window Tab (i.e. delete it). Please note that this method is not clearing the tab info context (i.e. _TabInfo).
        Parameters:
        ctx - context
        WindowNo - window
        TabNo - tab
      • 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,
                                          int tabNo,
                                          String value,
                                          boolean onlyTab,
                                          boolean ignoreUnparsable)
        Parse Context replaces global or Window context @tag@ with actual value.
        Parameters:
        ctx - context
        WindowNo - Number of Window
        tabNo - Number of Tab
        value - Message to be parsed
        onlyTab - if true, only value from tabNo 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
      • parseContext

        public static String parseContext​(Properties ctx,
                                          int WindowNo,
                                          int tabNo,
                                          String value,
                                          boolean onlyTab)
        Parse Context replaces global or Window context @tag@ with actual value.
        Parameters:
        ctx - context
        WindowNo - Number of Window
        tabNo - Number of Tab
        value - Message to be parsed
        onlyTab - if true, no value from tabNo 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
      • 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)
      • 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
      • sleep

        public static void sleep​(int sec)
        Sleep
        Parameters:
        sec - seconds
      • getRemoteCallCtx

        public static Properties getRemoteCallCtx​(Properties ctx)
        Prepare the context for calling remote server (for e.g, ejb), only default and global variables are pass over. It is too expensive and also can have serialization issue if every remote call to server is passing the whole client context.
        Parameters:
        ctx -
        Returns:
        Properties
      • getMWindowVO

        public static GridWindowVO getMWindowVO​(int WindowNo,
                                                int AD_Window_ID,
                                                int AD_Menu_ID)
        Get Window Model
        Parameters:
        WindowNo - Window No
        AD_Window_ID - window
        AD_Menu_ID - menu
        Returns:
        Model Window Value Obkect
      • getStandardReportFooterTrademarkText

        public static String getStandardReportFooterTrademarkText()
        Returns:
        trademark text for standard report footer
      • getZoomWindowID

        public static int getZoomWindowID​(MQuery query)
      • getZoomWindowID

        public static int getZoomWindowID​(int AD_Table_ID,
                                          int Record_ID)
      • getZoomWindowID

        public static int getZoomWindowID​(int AD_Table_ID,
                                          int Record_ID,
                                          int windowNo)
      • setPredefinedVariables

        public static void setPredefinedVariables​(Properties ctx,
                                                  int windowNo,
                                                  String predefinedVariables)
        Add in context predefined variables with prefix +, coming from menu or window definition Predefined variables must come separated by new lines in one of the formats: VAR=VALUE VAR="VALUE" VAR='VALUE' The + prefix is not required, is added here to the defined variables
        Parameters:
        ctx -
        windowNo -
        predefinedVariables -