📄 cmsworkplacemanager.java
字号:
/**
* Returns the {@link CmsWorkplaceMessages} for the given locale.<p>
*
* The workplace messages are a collection of resource bundles, containing the messages
* for all OpenCms core bundles and of all initialized modules.<p>
*
* Please note that the message objects are cached internally.
* The returned message object should therefore never be modified directly in any way.<p>
*
* @param locale the locale to get the messages for
*
* @return the {@link CmsWorkplaceMessages} for the given locale
*/
public CmsWorkplaceMessages getMessages(Locale locale) {
CmsWorkplaceMessages result = (CmsWorkplaceMessages)m_messages.get(locale);
if (result != null) {
// messages have already been read
return result;
}
// messages have not been read so far
synchronized (this) {
result = new CmsWorkplaceMessages(locale);
m_messages.put(locale, result);
}
return result;
}
/**
* Returns the configured multi context menu to use in the Explorer view.<p>
*
* @return the configured multi context menu to use in the Explorer view
*/
public CmsExplorerContextMenu getMultiContextMenu() {
return m_multiContextMenu;
}
/**
* Returns the id of the temporary file project required by the editors.<p>
*
* @return the id of the temporary file project required by the editors
*/
public int getTempFileProjectId() {
if (m_tempFileProject != null) {
return m_tempFileProject.getId();
} else {
return -1;
}
}
/**
* Returns the tool manager.<p>
*
* @return the tool manager
*/
public CmsToolManager getToolManager() {
if (m_toolManager == null) {
m_toolManager = new CmsToolManager();
}
return m_toolManager;
}
/**
* 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
cms.checkRole(CmsRole.WORKPLACE_MANAGER);
// set the workplace 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 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) {
throw new CmsException(Messages.get().container(Messages.ERR_INITIALIZE_WORKPLACE_0));
}
}
/**
* 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 true if tabs should be enabled, otherwise false
*/
public boolean isEnableAdvancedPropertyTabs() {
return m_enableAdvancedPropertyTabs;
}
/**
* Returns if messages should be includes in workflow mails.<p>
*
* @return true if messages should be includes, otherwise false
*/
public boolean isEnableWorkflowMessages() {
return m_workflowMessage;
}
/**
* 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 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));
}
}
/**
* Sets the direct edit provider.<p>
*
* @param clazz the direct edit provider to set
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -