Returns the syntax highlighting type for the currently edited resource.<p>

@param resource the resource to edit

@return the syntax highlighting type
421081
public CodeMirrorLanguage getHighlightMode(CmsResource resource) {

        if (resource != null) {
            // determine resource type
            int type = resource.getTypeId();
            if (CmsResourceTypeJsp.isJspTypeId(type)) {
                // JSP file
                return CodeMirrorLanguage.JSP;
            }
            if (CmsResourceTypeXmlContent.isXmlContent(resource) || CmsResourceTypeXmlPage.isXmlPage(resource)) {
                // XML content file or XML page file
                return CodeMirrorLanguage.XML;
            }
            // all other files will be matched according to their suffix
            int dotIndex = resource.getName().lastIndexOf('.');
            if (dotIndex != -1) {
                String suffix = resource.getName().substring(dotIndex + 1).toLowerCase();
                for (CodeMirrorLanguage lang : CodeMirrorLanguage.values()) {
                    if (lang.isSupportedFileType(suffix)) {
                        return lang;
                    }
                }
            }
        }
        // return HTML type as default
        return CodeMirrorLanguage.HTML;
    }
1146285
public static CmsSelectWidgetOption getWidgetOptionForType(CmsObject cms, String typeName) {

        String niceTypeName = typeName;
        try {
            Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
            niceTypeName = CmsWorkplaceMessages.getResourceTypeName(locale, typeName);
        } catch (@SuppressWarnings("unused") Exception e) {
            // resource type name will be used as a fallback
        }
        CmsSelectWidgetOption option = new CmsSelectWidgetOption(
            CmsFormatterChangeSet.keyForType(typeName),
            false,
            getMessage(cms, Messages.GUI_SCHEMA_FORMATTER_OPTION_1, niceTypeName));
        return option;
    }
839539
public String getResourceTypeIcon(CmsFileInfo file) {

        String typeName = null;
        typeName = getIconMapping().get(file.getFileSuffix().toLowerCase());
        if (typeName == null) {
            typeName = getIconMapping().get("");
        }
        return typeName;
    }
1057445
public static String getResourceName(Resource resource) {
        String result = null;
        if (resource != null) {
            String name = resource.getName();
            if (ResourceUtil.CONTENT_NODE.equals(name)) {
                result = getResourceName(resource.getParent());
            } else {
                result = name;
            }
        }
        return result;
    }
1296748
void showVariationsWindow(String resource) {

        final Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
        CmsVariationsDialog variationsDialog = new CmsVariationsDialog(resource, new Runnable() {

            public void run() {

                window.close();

            }

        }, Mode.FlexCache);
        try {
            CmsResource resourceObject = getRootCms().readResource(CmsFlexCacheKey.getResourceName(resource));
            variationsDialog.displayResourceInfo(Collections.singletonList(resourceObject));
        } catch (CmsException e) {
            //
        }
        window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_VIEW_FLEX_VARIATIONS_1, resource));
        window.setContent(variationsDialog);
        UI.getCurrent().addWindow(window);
    }
458379
private Map<String, String> getComponentHtmlTagAttributes(String resourceType) {
    if (StringUtils.isNotEmpty(resourceType)) {
      Component component = componentManager().getComponent(resourceType);
      if (component != null && component.getHtmlTagAttributes() != null) {
        return component.getHtmlTagAttributes();
      }
    }
    return ImmutableMap.of();
  }
779431
def resource_type(resource)
      raise_unless_xpath!(resource)
      type = resource.xpath("string(command/ident/@value)")
      if type.empty?
        raise ArgumentError, "Provided AST node is not a resource"
      end
      type
    end
349676
private List<FormatterOption> getFormatterOptions(CmsObject cms, CmsResource resource) {

        List<FormatterOption> options = new ArrayList<FormatterOption>();
        Set<String> containerTypes = new HashSet<>();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_displayContainerTypeConfig)) {
            String types = null;

            if (CmsPropertyDefinition.PROPERTY_TEMPLATE_DISPLAY_TYPES.equals(m_displayContainerTypeConfig)) {
                try {
                    CmsProperty prop = cms.readPropertyObject(
                        resource,
                        CmsPropertyDefinition.PROPERTY_TEMPLATE_DISPLAY_TYPES,
                        true);
                    String propValue = prop.getValue();
                    if (!CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) {
                        types = propValue;
                    } else {
                        // look up template property
                        try {
                            CmsTemplateLoaderFacade loaderFacade = OpenCms.getResourceManager().getTemplateLoaderFacade(
                                cms,
                                null,
                                resource,
                                CmsPropertyDefinition.PROPERTY_TEMPLATE);
                            CmsResource template = loaderFacade.getLoaderStartResource();
                            if (template != null) {
                                prop = cms.readPropertyObject(
                                    template,
                                    CmsPropertyDefinition.PROPERTY_TEMPLATE_DISPLAY_TYPES,
                                    false);
                                propValue = prop.getValue();
                                if (!CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) {
                                    types = propValue;
                                }
                            }
                        } catch (Exception ex) {
                            LOG.debug(ex.getMessage(), ex);
                        }
                    }
                } catch (CmsException e) {
                    LOG.warn(e.getLocalizedMessage(), e);
                }
            } else {
                types = m_displayContainerTypeConfig;
            }
            if (types != null) {
                containerTypes.addAll(Arrays.asList(types.split(TYPES_SPLITTER)));
            }
        }
        CmsADEConfigData config = OpenCms.getADEManager().lookupConfiguration(cms, resource.getRootPath());

        if (config != null) {
            Locale wpLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
            for (I_CmsFormatterBean formatter : config.getDisplayFormatters(cms)) {
                if (!containerTypes.isEmpty()) {
                    if (Sets.intersection(containerTypes, formatter.getContainerTypes()).isEmpty()) {
                        continue;
                    }
                }
                for (String typeName : formatter.getResourceTypeNames()) {
                    String label = formatter.getNiceName(wpLocale)
                        + " ("
                        + CmsWorkplaceMessages.getResourceTypeName(wpLocale, typeName)
                        + ")";
                    options.add(
                        new FormatterOption(
                            typeName + CmsXmlDisplayFormatterValue.SEPARATOR + formatter.getId(),
                            typeName,
                            getDisplayType(formatter),
                            label,
                            formatter.getRank()));
                }
            }
        }
        Collections.sort(options, new FormatterComparator());
        return options;
    }
146727
@Pure
	public String getAutoGeneratedActionString(Resource resource) {
		TaskTags tags = getTaskTagProvider().getTaskTags(resource);
		String taskTag;
		if (tags != null && tags.getTaskTags() != null && !tags.getTaskTags().isEmpty()) {
			taskTag = tags.getTaskTags().get(0).getName();
		} else {
			taskTag = "TODO";
		}
		return taskTag + " Auto-generated code.";
	}
470640
protected int getResourceTypeId() {

        if (CmsStringUtil.isNotEmpty(getResourceType())) {
            try {
                return OpenCms.getResourceManager().getResourceType(getResourceType()).getTypeId();
            } catch (CmsException e) {
                // ignore, no valid resource type ID found
            }
        }
        return -1;
    }
665125
public static String getResourceURL(String resource) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        return cl.getResource(resource).toString();
    }
363869
public String getTypeTitle() {

        if (m_type == null) {
            return CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_STATS_ALL_RESOURCES_0);
        }

        String res = "";
        CmsExplorerTypeSettings typeSetting = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
            m_type.getTypeName());
        res = CmsVaadinUtils.getMessageText(typeSetting.getKey());
        return res;
    }
781320
public static String getResourceUri(Resource resource) {
        try {
            return resource.getURI().toString();
        } catch (FileNotFoundException e) {
            return resource.getDescription();
        } catch (IOException e) {
            throw new RuntimeException("Could not create URI for resource: " + resource, e);
        }
    }
977403
public static boolean isModelGroupResource(CmsResource resource) {

        return CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME.equals(
            OpenCms.getResourceManager().getResourceType(resource).getTypeName());
    }
979616
public I_CmsPreEditorActionDefinition getPreEditorConditionDefinition(I_CmsResourceType resourceType) {

        Iterator<I_CmsPreEditorActionDefinition> i = m_preEditorConditionDefinitions.iterator();
        I_CmsPreEditorActionDefinition result = null;
        int matchResult = -1;
        while (i.hasNext()) {
            I_CmsPreEditorActionDefinition currentDefinition = i.next();
            if (resourceType.getClass().isInstance(currentDefinition.getResourceType())) {
                // now determine the match count...
                int matchDistance = 0;
                Class<?> superClass = resourceType.getClass();
                while (true) {
                    // check if a super class is present
                    if (superClass == null) {
                        break;
                    }
                    if (superClass.getName().equals(currentDefinition.getResourceType().getClass().getName())) {
                        break;
                    }
                    matchDistance += 1;
                    superClass = superClass.getSuperclass();
                }
                if (matchResult != -1) {
                    if (matchDistance < matchResult) {
                        matchResult = matchDistance;
                        result = currentDefinition;
                    }
                } else {
                    matchResult = matchDistance;
                    result = currentDefinition;
                }
            }
        }
        return result;
    }
401336
private String getProviderName(String resourceType) {

        CmsDebugLog.consoleLog("getProviderName for " + resourceType);
        for (CmsResourceTypeBean typeBean : m_dialogBean.getTypes()) {
            if (typeBean.getType().equals(resourceType)) {
                return typeBean.getPreviewProviderName();
            }
        }
        return null;
    }
312177
public static String getPrimaryType(Resource resource) {
        String result = null;
        if (resource != null) {
            if (resource instanceof JcrResource) {
                // use the resource itself if it implements the JcrResource interface (maybe a version of a resource)
                result = ((JcrResource) resource).getPrimaryType();
            } else {
                Node node = resource.adaptTo(Node.class);
                if (node != null) {
                    try {
                        NodeType type = node.getPrimaryNodeType();
                        if (type != null) {
                            result = type.getName();
                        }
                    } catch (RepositoryException ignore) {
                    }
                }
                if (result == null) {
                    ValueMap values = resource.adaptTo(ValueMap.class);
                    if (values != null) {
                        result = values.get(JcrConstants.JCR_PRIMARYTYPE, (String) null);
                    }
                }
            }
        }
        return result;
    }