cmsworkplacemanager.java

来自「找了很久才找到到源代码」· Java 代码 · 共 1,709 行 · 第 1/5 页

JAVA
1,709
字号
    /**
     * Returns the user additional information configuration Manager.<p>
     *
     * @return the user additional information configuration manager
     */
    public CmsWorkplaceUserInfoManager getUserInfoManager() {

        return m_userInfoManager;
    }

    /**
     * Returns the map of configured workplace views.<p>
     * 
     * @return the map of configured workplace views
     */
    public List getViews() {

        return m_views;
    }

    /**
     * Returns the instanciated workplace editor manager class.<p>
     * 
     * @return the instanciated workplace editor manager class
     */
    public CmsWorkplaceEditorManager getWorkplaceEditorManager() {

        return m_editorManager;
    }

    /**
     * @see org.opencms.i18n.I_CmsLocaleHandler#initHandler(org.opencms.file.CmsObject)
     */
    public void initHandler(CmsObject cms) {

        // initialize the workplace locale set
        m_locales = initWorkplaceLocales(cms);
    }

    /**
     * Initializes the workplace manager with the OpenCms system configuration.<p>
     * 
     * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
     * 
     * @throws CmsRoleViolationException if the provided OpenCms user context does 
     *      not have <code>{@link CmsRole#WORKPLACE_MANAGER}</code> role permissions
     * @throws CmsException if something goes wrong
     */
    public synchronized void initialize(CmsObject cms) throws CmsException, CmsRoleViolationException {

        try {
            // ensure that the current user has permissions to initialize the workplace
            OpenCms.getRoleManager().checkRole(cms, CmsRole.WORKPLACE_MANAGER);

            // set the workplace encoding
            try {
                // workplace encoding is set on the workplace parent folder /system/workplace/ 
                CmsResource wpFolderRes = cms.readResource(CmsWorkplace.VFS_PATH_WORKPLACE);
                m_encoding = CmsLocaleManager.getResourceEncoding(cms, wpFolderRes);
            } catch (CmsVfsResourceNotFoundException e) {
                // workplace parent folder could not be read - use configured default encoding
                m_encoding = OpenCms.getSystemInfo().getDefaultEncoding();
            }

            // configure direct edit provider with default if not available
            if (m_directEditProvider == null) {
                m_directEditProvider = new CmsDirectEditDefaultProvider();
            }

            // throw away all currently configured module explorer types
            m_explorerTypeSettingsFromModules.clear();
            // now add the additional explorer types found in the modules
            CmsModuleManager moduleManager = OpenCms.getModuleManager();
            Iterator j = moduleManager.getModuleNames().iterator();
            while (j.hasNext()) {
                CmsModule module = moduleManager.getModule((String)j.next());
                if (module != null) {
                    addExplorerTypeSettings(module);
                }
            }
            // initialize the menu rules
            initMenuRules();
            // initialize the explorer type settings
            initExplorerTypeSettings();
            // initialize the workplace views
            initWorkplaceViews(cms);
            // initialize the workplace editor manager
            m_editorManager = new CmsWorkplaceEditorManager(cms);
            // initialize the locale handler
            initHandler(cms);

            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_ACCESS_INITIALIZED_0));
            }
            try {
                // read the temporary file project
                m_tempFileProject = cms.readProject(I_CmsProjectDriver.TEMP_FILE_PROJECT_NAME);
            } catch (CmsException e) {
                // during initial setup of OpenCms the temp file project does not yet exist...
                LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_TEMP_FILE_PROJECT_0));
            }
            // create an instance of editor display options
            m_editorDisplayOptions = new CmsEditorDisplayOptions();

            // throw away all current gallery settings
            m_galleries.clear();
            // read out the configured gallery classes
            j = OpenCms.getResourceManager().getResourceTypes().iterator();
            while (j.hasNext()) {
                I_CmsResourceType resourceType = (I_CmsResourceType)j.next();
                if (resourceType instanceof CmsResourceTypeFolderExtended) {
                    // found a configured extended folder resource type
                    CmsResourceTypeFolderExtended galleryType = (CmsResourceTypeFolderExtended)resourceType;
                    String folderClassName = galleryType.getFolderClassName();
                    if (CmsStringUtil.isNotEmpty(folderClassName)) {
                        // only process this as a gallery if the folder name is not empty
                        try {
                            // check, if the folder class is a subclass of A_CmsGallery
                            if (A_CmsGallery.class.isAssignableFrom(Class.forName(folderClassName))) {
                                // create gallery class instance
                                A_CmsGallery galleryInstance = (A_CmsGallery)Class.forName(folderClassName).newInstance();
                                // set gallery folder resource type
                                galleryInstance.setResourceType(galleryType);
                                // store the gallery class instance with the type name as lookup key
                                m_galleries.put(galleryType.getTypeName(), galleryInstance);
                            }
                        } catch (ClassNotFoundException e) {
                            LOG.error(e.getLocalizedMessage());
                        } catch (InstantiationException e) {
                            LOG.error(e.getLocalizedMessage());
                        } catch (IllegalAccessException e) {
                            LOG.error(e.getLocalizedMessage());
                        }
                    }
                }
            }

            // configures the tool manager
            getToolManager().configure(cms);

            // throw away all cached message objects
            m_messages = new HashMap();

            // register this object as event listener
            OpenCms.addCmsEventListener(this, new int[] {I_CmsEventListener.EVENT_CLEAR_CACHES});
        } catch (CmsException e) {
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            throw new CmsException(Messages.get().container(Messages.ERR_INITIALIZE_WORKPLACE_0));
        }
        m_adminCms = cms;
    }

    /**
     * Returns the default property editing mode on resources.<p>
     *
     * @return the default property editing mode on resources
     */
    public boolean isDefaultPropertiesOnStructure() {

        return m_defaultPropertiesOnStructure;
    }

    /**
     * Returns if tabs in the advanced property dialog are enabled.<p>
     *
     * @return <code>true</code> if tabs should be enabled, otherwise <code>false</code>
     */
    public boolean isEnableAdvancedPropertyTabs() {

        return m_enableAdvancedPropertyTabs;
    }

    /**
     * Returns if XML content is automatically corrected when opened with the editor.<p>
     * 
     * @return <code>true</code> if XML content is automatically corrected when opened with the editor, otherwise <code>false</code>
     */
    public boolean isXmlContentAutoCorrect() {

        return m_xmlContentAutoCorrect;
    }

    /** 
     * Removes the list of explorer type settings from the given module.<p>
     * 
     * @param module the module witch contains the explorer type settings to remove
     */
    public void removeExplorerTypeSettings(CmsModule module) {

        List explorerTypes = module.getExplorerTypes();
        if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
            Iterator i = explorerTypes.iterator();
            while (i.hasNext()) {
                CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next();
                if (m_explorerTypeSettingsFromModules.contains(settings)) {
                    m_explorerTypeSettingsFromModules.remove(settings);
                    if (CmsLog.INIT.isInfoEnabled()) {
                        CmsLog.INIT.info(Messages.get().getBundle().key(
                            Messages.INIT_REMOVE_EXPLORER_TYPE_SETTING_1,
                            settings.getName()));
                    }
                }
            }
            // reset the list of all explorer type settings
            initExplorerTypeSettings();
        }
    }

    /**
     * Sets if the autolock resources feature is enabled.<p>
     * 
     * @param value <code>"true"</code> if the autolock resources feature is enabled, otherwise false
     */
    public void setAutoLock(String value) {

        m_autoLockResources = Boolean.valueOf(value).booleanValue();
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                m_autoLockResources ? Messages.INIT_AUTO_LOCK_ENABLED_0 : Messages.INIT_AUTO_LOCK_DISABLED_0));
        }
    }

    /**
     * Sets the customized workplace foot.<p>
     * 
     * @param footCustom the customized workplace foot
     */
    public void setCustomFoot(CmsWorkplaceCustomFoot footCustom) {

        m_customFoot = footCustom;
    }

    /**
     * Sets the access object of the type settings.<p>
     * 
     * @param access access object
     */
    public void setDefaultAccess(CmsExplorerTypeAccess access) {

        m_defaultAccess = access;
    }

    /**
     * Sets the Workplace default locale.<p>
     * 
     * @param locale the locale to set
     */
    public void setDefaultLocale(String locale) {

        try {
            m_defaultLocale = CmsLocaleManager.getLocale(locale);
        } catch (Exception e) {
            if (CmsLog.INIT.isWarnEnabled()) {
                CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_NONCRIT_ERROR_0), e);
            }
        }
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_LOCALE_1, m_defaultLocale));
        }
    }

    /**
     * Sets the default property editing mode on resources.<p>
     *
     * @param defaultPropertiesOnStructure the default property editing mode on resources
     */
    public void setDefaultPropertiesOnStructure(String defaultPropertiesOnStructure) {

        m_defaultPropertiesOnStructure = Boolean.valueOf(defaultPropertiesOnStructure).booleanValue();
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                m_defaultPropertiesOnStructure ? Messages.INIT_PROP_ON_STRUCT_TRUE_0
                : Messages.INIT_PROP_ON_STRUCT_FALSE_0));
        }
    }

    /**
     * Sets the Workplace default user settings.<p>
     * 
     * @param defaultUserSettings the user settings to set
     */
    public void setDefaultUserSettings(CmsDefaultUserSettings defaultUserSettings) {

        m_defaultUserSettings = defaultUserSettings;

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                Messages.INIT_DEFAULT_USER_SETTINGS_1,
                m_defaultUserSettings.getClass().getName()));
        }
    }

    /**
     * Sets the direct edit provider.<p>
     * 
     * @param clazz the direct edit provider to set
     */
    public void setDirectEditProvider(I_CmsDirectEditProvider clazz) {

        m_directEditProvider = clazz;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                Messages.INIT_DIRECT_EDIT_PROVIDER_1,
                m_directEditProvider.getClass().getName()));
        }
    }

    /**
     * Sets the editor action class.<p>
     * 
     * @param clazz the editor action class to set
     */
    public void setEditorAction(I_CmsEditorActionHandler clazz) {

        m_editorAction = clazz;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                Messages.INIT_EDITOR_ACTION_CLASS_1,
                m_editorAction.getClass().getName()));
        }
    }

    /**
     * Sets the editor display option class.<p>
     * 
     * @param clazz the editor display option class to set
     */
    public void setEditorDisplayOptions(CmsEditorDisplayOptions clazz) {

        m_editorDisplayOptions = clazz;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(
                Messages.INIT_EDITOR_DISPLAY_OPTS_1,
                m_editorAction.getClass().getName()));
        }
    }

    /**
     * Sets the editor handler class.<p>
     * 

⌨️ 快捷键说明

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