/** * Returns the default editor URI for the current resource type.<p> * * @param context the request context * @param resourceType the current resource type * @param userAgent the user agent String that identifies the browser * @return a valid default editor URI for the resource type or null, if no editor matches */ protected String getDefaultEditorUri(CmsRequestContext context, String resourceType, String userAgent) { SortedMap filteredEditors = filterEditorsForResourceType(resourceType); while (filteredEditors.size() > 0) { // get the configuration with the lowest key value from the map Float key = (Float)filteredEditors.firstKey(); CmsWorkplaceEditorConfiguration conf = (CmsWorkplaceEditorConfiguration)filteredEditors.get(key); // match the found configuration with the current users browser if (conf.matchesBrowser(userAgent)) { return conf.getEditorUri(); } filteredEditors.remove(key); } if (context == null) { // this is just so that all parameters are used, signature should be identical to getEditorUri(...) return null; } // no valid default editor found return null; }
/** * Filters the matching editors for the given resource type from the list of all available editors.<p> * * @param resourceType the resource type to filter * @return a map of filtered editor configurations sorted asceding by the ranking for the current resource type, with the (Float) ranking as key */ private SortedMap<Float, CmsWorkplaceEditorConfiguration> filterEditorsForResourceType(String resourceType) { SortedMap<Float, CmsWorkplaceEditorConfiguration> filteredEditors = new TreeMap<Float, CmsWorkplaceEditorConfiguration>(); Iterator<CmsWorkplaceEditorConfiguration> i = m_editorConfigurations.iterator(); while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = i.next(); if (currentConfig.matchesResourceType(resourceType)) { float key = currentConfig.getRankingForResourceType(resourceType); if (key >= 0) { filteredEditors.put(new Float(key), currentConfig); } } } return filteredEditors; }
/** * Returns the mapping for the given resource type.<p> * * @param resourceType the resource type name to check * @return the mapping or null, if no mapping is specified */ public String getMappingForResourceType(String resourceType) { String[] resourceTypeParams = (String[])getResourceTypes().get(resourceType); if (resourceTypeParams == null) { return null; } else { return resourceTypeParams[1]; } }
while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = (CmsWorkplaceEditorConfiguration)i.next(); String mapping = currentConfig.getMappingForResourceType(resourceType); if (mapping != null) { preferredEditorSetting = settings.getPreferredEditor(mapping); if ((preferredConf != null) && preferredConf.isWidgetEditor() && preferredConf.matchesBrowser(userAgent)) { return preferredConf.getWidgetEditor(); if (conf.isWidgetEditor() && conf.matchesBrowser(userAgent)) { return conf.getWidgetEditor();
while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = i.next(); String mapping = currentConfig.getMappingForResourceType(resourceType); if (mapping != null) { preferredEditorSetting = settings.getPreferredEditor(mapping); if ((preferredConf != null) && preferredConf.matchesBrowser(userAgent)) { return preferredConf.getEditorUri(); if (conf.matchesBrowser(userAgent)) { return conf.getEditorUri();
/** * Constructor with xml data String.<p> * * @param xmlData the XML data String containing the information about the editor * @param editorUri the editor workplace URI */ public CmsWorkplaceEditorConfiguration(byte[] xmlData, String editorUri) { setValidConfiguration(true); try { initialize(CmsXmlUtils.unmarshalHelper(xmlData, null), editorUri); } catch (CmsXmlException e) { // xml String could not be parsed logConfigurationError(Messages.get().getBundle().key(Messages.ERR_XML_PARSE_0), e); } }
CmsWorkplaceEditorConfiguration currentConfig = i.next(); Iterator<String> k = currentConfig.getResourceTypes().keySet().iterator(); while (k.hasNext()) { if ((currentConfig.getMappingForResourceType(key) == null) || currentConfig.getMappingForResourceType(key).equals(key)) { editorConfigs.put(new Float(currentConfig.getRankingForResourceType(key)), currentConfig);
Float key = availableEditors.lastKey(); CmsWorkplaceEditorConfiguration conf = availableEditors.get(key); options.add(keyDefault(conf.getEditorLabel(), conf.getEditorLabel())); values.add(conf.getEditorUri()); if (conf.getEditorUri().equals(preSelection)) { selectedIndex = counter;
CmsWorkplaceEditorConfiguration editorConfig = new CmsWorkplaceEditorConfiguration(xmlData, folderName + EDITOR_FILENAME); if (editorConfig.isValidConfiguration()) { m_editorConfigurations.add(editorConfig);
/** * Filters the preferred editor from the list of all available editors.<p> * * @param preferredEditor the preferred editor identification String * @return the preferred editor configuration object or null, if none is found */ private CmsWorkplaceEditorConfiguration filterPreferredEditor(String preferredEditor) { if (m_preferredEditors.size() == 0) { Iterator<CmsWorkplaceEditorConfiguration> i = m_editorConfigurations.iterator(); while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = i.next(); m_preferredEditors.put(currentConfig.getEditorUri(), currentConfig); } } return m_preferredEditors.get(preferredEditor); }
/** * Tests if the current browser is matching the configuration.<p> * * @param currentBrowser the users browser String to test * @return true if the browser matches the configuration, otherwise false */ public boolean matchesBrowser(String currentBrowser) { if (currentBrowser == null) { return false; } for (int i = 0; i < getBrowserPattern().size(); i++) { boolean matches = getBrowserPattern().get(i).matcher(currentBrowser.trim()).matches(); if (matches) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROWSER_MATCHES_CONFIG_1, currentBrowser)); } return true; } } return false; }
while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = i.next(); String mapping = currentConfig.getMappingForResourceType(resourceType); if (mapping != null) { preferredEditorSetting = settings.getPreferredEditor(mapping); if ((preferredConf != null) && preferredConf.isWidgetEditor() && preferredConf.matchesBrowser(userAgent)) { return preferredConf.getWidgetEditor(); if (conf.isWidgetEditor() && conf.matchesBrowser(userAgent)) { return conf.getWidgetEditor();
while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = (CmsWorkplaceEditorConfiguration)i.next(); String mapping = currentConfig.getMappingForResourceType(resourceType); if (mapping != null) { preferredEditorSetting = settings.getPreferredEditor(mapping); if ((preferredConf != null) && preferredConf.matchesBrowser(userAgent)) { return preferredConf.getEditorUri(); if (conf.matchesBrowser(userAgent)) { return conf.getEditorUri();
/** * Constructor with xml data String.<p> * * @param xmlData the XML data String containing the information about the editor * @param editorUri the editor workplace URI * @param name the editor configuration name */ public CmsWorkplaceEditorConfiguration(byte[] xmlData, String editorUri, String name) { setValidConfiguration(true); try { m_name = name; initialize(CmsXmlUtils.unmarshalHelper(xmlData, null), editorUri); } catch (CmsXmlException e) { // xml String could not be parsed logConfigurationError(Messages.get().getBundle().key(Messages.ERR_XML_PARSE_0), e); } }
CmsWorkplaceEditorConfiguration currentConfig = (CmsWorkplaceEditorConfiguration)i.next(); Iterator k = currentConfig.getResourceTypes().keySet().iterator(); while (k.hasNext()) { if (currentConfig.getMappingForResourceType(key) == null) { editorConfigs.put(new Float(currentConfig.getRankingForResourceType(key)), currentConfig);
Float key = (Float)availableEditors.lastKey(); CmsWorkplaceEditorConfiguration conf = (CmsWorkplaceEditorConfiguration)availableEditors.get(key); options.add(keyDefault(conf.getEditorLabel(), conf.getEditorLabel())); values.add(conf.getEditorUri()); if (conf.getEditorUri().equals(preSelection)) { selectedIndex = counter;
CmsWorkplaceEditorConfiguration editorConfig = new CmsWorkplaceEditorConfiguration( xmlData, folderName + EDITOR_FILENAME, currentFolder.getName()); if (editorConfig.isValidConfiguration()) { m_editorConfigurations.add(editorConfig);
/** * Filters the preferred editor from the list of all available editors.<p> * * @param preferredEditor the preferred editor identification String * @return the preferred editor configuration object or null, if none is found */ private CmsWorkplaceEditorConfiguration filterPreferredEditor(String preferredEditor) { if (m_preferredEditors.size() == 0) { Iterator i = m_editorConfigurations.iterator(); while (i.hasNext()) { CmsWorkplaceEditorConfiguration currentConfig = (CmsWorkplaceEditorConfiguration)i.next(); m_preferredEditors.put(currentConfig.getEditorUri(), currentConfig); } } return (CmsWorkplaceEditorConfiguration)m_preferredEditors.get(preferredEditor); }
/** * Tests if the current browser is matching the configuration.<p> * * @param currentBrowser the users browser String to test * @return true if the browser matches the configuration, otherwise false */ public boolean matchesBrowser(String currentBrowser) { if (currentBrowser == null) { return false; } for (int i = 0; i < getBrowserPattern().size(); i++) { boolean matches = ((Pattern)getBrowserPattern().get(i)).matcher(currentBrowser.trim()).matches(); if (matches) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_BROWSER_MATCHES_CONFIG_1, currentBrowser)); } return true; } } return false; }
/** * Returns the default editor URI for the current resource type.<p> * * @param context the request context * @param resourceType the current resource type * @param userAgent the user agent String that identifies the browser * @return a valid default editor URI for the resource type or null, if no editor matches */ protected String getDefaultEditorUri(CmsRequestContext context, String resourceType, String userAgent) { SortedMap<Float, CmsWorkplaceEditorConfiguration> filteredEditors = filterEditorsForResourceType(resourceType); while (filteredEditors.size() > 0) { // get the configuration with the lowest key value from the map Float key = filteredEditors.firstKey(); CmsWorkplaceEditorConfiguration conf = filteredEditors.get(key); // match the found configuration with the current users browser if (conf.matchesBrowser(userAgent)) { return conf.getEditorUri(); } filteredEditors.remove(key); } if (context == null) { // this is just so that all parameters are used, signature should be identical to getEditorUri(...) return null; } // no valid default editor found return null; }