⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 focusconfigmanagerejb.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public SubFocus getSubFocus(String subFocusName) {        String focusID = EntityHelper.getParentFocusName(subFocusName);        Focus focus = getFocus(focusID);        if(focus != null) {            return (SubFocus) focus.getObject(subFocusName);        } else {            return null;        }    }    /**     * Get the Tab object by it's name.     *     * @param tabName tab name attribute     * @return Tab object or NULL     */    public Tab getTab(String tabName) {        String subFocusID = EntityHelper.getParentSubFocusName(tabName);        SubFocus subFocus = getSubFocus(subFocusID);        if(subFocus != null) {            return (Tab) subFocus.getObject(tabName);        } else {            return null;        }    }    /**     * Get the Form object by it's name.     *     * @param formName form name attribute     * @return Form object or NULL     */    public Form getForm(String formName) {        if(formName == null) {            throw new NullPointerException("Got NULL form");        }        Tab tab = null;        String tabID = EntityHelper.getParentTabName(formName);        if(tabID != null) {            tab = getTab(tabID);        }        if(tab != null) {            return (Form) tab.getObject(formName);        } else {            return null;        }    }    // ---------------------------------------------------------------    // Localize Focus mamagement.    // ---------------------------------------------------------------    /**     * Get all focuses with localized captions.     *     * @param langID Language ID     * @return Collection of Focus objects     */    public Collection<Focus> getLocalizedFocuses(String langID) {        // Get all focuses.        Collection<Focus> focuses = getFocuses();        if(focuses == null) {            return null;        }        // Localize focus.        for(Focus focus : focuses) {            localizeFocus(langID, focus);        }        return focuses;    }    /**     * Get the Focus object by name with localized caption.     * Returns <b>null</b> if the focus not found.     *     * @param langID    Language ID     * @param focusName focus name attribute     * @return Focus object     */    public Focus getLocalizedFocus(String langID, String focusName) {        if(getLogger().isDebugEnabled()) {            DEBUG("Try to get focus '" + focusName + "' lang=[" + langID + "]");        }        // Get Focus object.        Focus focus = getFocus(focusName);        if(focus == null) {            return null;        }        // Localize focus.        localizeFocus(langID, focus);        return focus;    }    /**     * Get the SubFocus object by name with localized caption.     * Returns <b>null</b> if the focus not found.     *     * @param langID       Language ID     * @param subFocusName Subfocus name attribute     * @return Focus object     */    public SubFocus getLocalizedSubFocus(String langID, String subFocusName) {        if(getLogger().isDebugEnabled()) {            DEBUG("Try to get subfocus '" + subFocusName + "' lang=[" + langID + "]");        }        // Get SubFocus object.        SubFocus subFocus = getSubFocus(subFocusName);        if(subFocus == null) {            return null;        }        // Localize focus.        localizeSubFocus(langID, subFocus);        return subFocus;    }    /**     * Get the Tab object by name with localized caption.     * Returns <b>null</b> if the tab not found.     *     * @param langID  Language ID     * @param tabName tab name attribute     * @return Tab object     */    public Tab getLocalizedTab(String langID, String tabName) {        if(getLogger().isDebugEnabled()) {            DEBUG("Try to get tab '" + tabName + "' lang=[" + langID + "]");        }        // Get Tab object.        Tab tab = getTab(tabName);        if(tab == null) {            return null;        }        // Localize tab.        localizeTab(langID, tab);        return tab;    }    /**     * Get the Form object by name with localized caption.     * Returns <b>null</b> if the form not found.     *     * @param langID   Language ID     * @param formName form name attribute     * @return Form object     */    public Form getLocalizedForm(String langID, String formName) {        if(getLogger().isDebugEnabled()) {            DEBUG("Try to get form '" + formName + "' lang=[" + langID + "]");        }        // Get Form object.        Form form = getForm(formName);        if(form == null) {            return null;        }        // Localize form.        localizeForm(langID, form);        return form;    }    private static class UnmodifableExternalSet extends ExternalSet {        public UnmodifableExternalSet(ExternalSet set) {            super.setName(set.getName());        }        public void setName(String name) {            throw new IllegalStateException("You cannot modify this object, "                     + "get modifable version of focus. ");        }    }    public List<ExternalSet> getUnmodifiableExternalSet(String formId) {        Form initialForm = getInitialForm(formId);        List<ExternalSet> list = null;        if(initialForm != null ) {            ExternalSet[] sets = initialForm.getExternalSet();            list = new ArrayList<ExternalSet>(sets.length);            for(ExternalSet set : sets) {                list.add(new UnmodifableExternalSet(set));            }        }        return list;    }    private static class UnmodifableExternalField extends ExternalField {        public UnmodifableExternalField(ExternalField field) {            super.setName(field.getName());            super.setForm(field.getForm());            super.setSourceField(field.getSourceField());        }        public void setName(String name) {            throw new IllegalStateException("You cannot modify this object, "                    + "get modifable version of focus. ");        }        public void setForm(String form) {            throw new IllegalStateException("You cannot modify this object, "                    + "get modifable version of focus. ");        }        public void setSourceField(String sourceField) {            throw new IllegalStateException("You cannot modify this object, "                    + "get modifable version of focus. ");        }    }    public List<ExternalField> getUnmodifiableExternalFields(String formId) {        Form initialForm = getInitialForm(formId);        List<ExternalField> list = null;        if(initialForm != null ) {            ExternalField[] fields = initialForm.getExternalField();            list = new ArrayList<ExternalField>(fields.length);            for(ExternalField field : fields) {                list.add(new UnmodifableExternalField(field));            }        }        return list;    }    //    // Initialize focus localization.    //    private void updateLocalization(Focus focus) {        LocalizationManagerLocal localization = getLocalizationManagerLocal();        if(focus.getCaptions() != null) {            localization.fillFocusCaptions(focus.getName(), focus.getCaptions());        }        for(int m = 0; m < focus.getSubFocusCount(); m++) {            SubFocus subFocus = focus.getSubFocus(m);            if(subFocus.getCaptions() != null) {                localization.fillSubFocusCaptions(subFocus.getName(), subFocus.getCaptions());            }            for(int i = 0; i < subFocus.getTabCount(); i++) {                Tab tab = subFocus.getTab(i);                if(tab.getCaptions() != null) {                    localization.fillTabCaptions(tab.getName(), tab.getCaptions());                }                for(int j = 0; j < tab.getFormCount(); j++) {                    Form form = tab.getForm(j);                    if(form.getCaptions() != null) {                        localization.fillFormCaptions(form.getName(), form.getCaptions());                        Button[] buttons = EntityHelper.FormHelper.getFormButtons(form);                        for(Button button : buttons) {                            localization.fillButtonCaptions(                                    EntityHelper.FormHelper.getButtonName(                                            form, button), button.getCaptions());                        }                        // Save localization for form's html elements                        Htmlelements htmlElements = form.getHtmlelements();                        if(htmlElements != null){                            for (Htmlelement htmlElement : htmlElements.getHtmlelement()) {                                localization.fillHtmlElementContents(                                    EntityHelper.FormHelper.getHtmlElementName(                                            form, htmlElement), htmlElement.getHtmlcontents());                            }                        }                    }                    if(form.getDescriptions() != null) {                        localization.fillFormDescriptions(form.getName(), form.getDescriptions());                    }                }            }        }    }    //    // Localize focus.    //    private void localizeFocus(String langID, Focus focus) {        LocalizationManagerLocal localization = getLocalizationManagerLocal();        // set Focus caption        focus.setCaption(localization.getFocusCaption(langID, focus.getName()));        // set SubFocus captions        for(int i = 0; i < focus.getSubFocusCount(); i++) {            localizeSubFocus(langID, focus.getSubFocus(i));        }    }    //    // Localize subfocus.    //    private void localizeSubFocus(String langID, SubFocus subFocus) {        LocalizationManagerLocal localization = getLocalizationManagerLocal();        // set SubFocus caption        subFocus.setCaption(localization.getSubFocusCaption(langID, subFocus.getName()));        // set Tab captions        for(int i = 0; i < subFocus.getTabCount(); i++) {            localizeTab(langID, subFocus.getTab(i));        }    }    //    // Localize tab.    //    private void localizeTab(String langID, Tab tab) {        LocalizationManagerLocal localization = getLocalizationManagerLocal();        // set Tab caption        tab.setCaption(localization.getTabCaption(langID, tab.getName()));        // set Form captions        for(int i = 0; i < tab.getFormCount(); i++) {            localizeForm(langID, tab.getForm(i));        }    }    //    // Localize form.    //    private void localizeForm(String langID, Form form) {        LocalizationManagerLocal localization = getLocalizationManagerLocal();        // caption        form.setCaption(localization.getFormCaption(langID, form.getName()));        // buttons        Button[] buttons =  EntityHelper.FormHelper.getFormButtons(form);        for(Button button : buttons) {            button.setCaption(localization.getButtonCaption(                      langID, EntityHelper.FormHelper.getButtonName(form, button)));        }        // htmlelements        Htmlelements htmlElements = form.getHtmlelements();        if(htmlElements != null){            for (Htmlelement htmlElement : htmlElements.getHtmlelement()) {                htmlElement.setHtmlcontent(localization.getHtmlElementContent(                        langID, EntityHelper.FormHelper.getHtmlElementName(form, htmlElement)));                            }        }        // description        form.setDescription(localization.getFormDescription(langID, form.getName()));    }    //    // Get LocalizationManager.    //    private LocalizationManagerLocal getLocalizationManagerLocal() {        return (LocalizationManagerLocal) getLocalObject(JNDINames.LocalizationManager,                LocalizationManagerLocalHome.class);    }    //    // Clone focus    //    private Focus cloneFocus(Focus f) {        Focus clone = (Focus) XMLFactory.getXMLBinding().clone(f, Focus.class);        // indexing        for(int m = 0; m < clone.getSubFocusCount(); m++) {            SubFocus subFocus = clone.getSubFocus(m);            clone.putObject(subFocus.getName(), subFocus);            for(int i = 0; i < subFocus.getTabCount(); i++) {                Tab tab = subFocus.getTab(i);                subFocus.putObject(tab.getName(), tab);                for(int j = 0; j < tab.getFormCount(); j++) {                    Form form = tab.getForm(j);                    tab.putObject(form.getName(), form);                }            }        }        return clone;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -