Example usage for com.liferay.portal.util PropsValues DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED

List of usage examples for com.liferay.portal.util PropsValues DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED.

Prototype

boolean DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED

To view the source code for com.liferay.portal.util PropsValues DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED.

Click Source Link

Usage

From source file:com.liferay.document.library.web.internal.display.context.logic.UIItemsBuilder.java

License:Open Source License

public void addOpenInMsOfficeMenuItem(List<MenuItem> menuItems) throws PortalException {

    if (!isOpenInMsOfficeActionAvailable()) {
        return;/*from  w w w.  ja v a2 s . co m*/
    }

    String webDavURL = DLUtil.getWebDavURL(_themeDisplay, _fileEntry.getFolder(), _fileEntry,
            PropsValues.DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED, true);

    String onClick = getNamespace() + "openDocument('" + webDavURL + "');";

    JavaScriptMenuItem javascriptMenuItem = _addJavaScriptUIItem(new JavaScriptMenuItem(), menuItems,
            DLUIItemKeys.OPEN_IN_MS_OFFICE, "open-in-ms-office", onClick);

    String javaScript = "/com/liferay/document/library/web/display/context/dependencies"
            + "/open_in_ms_office_js.ftl";

    Class<?> clazz = getClass();

    URLTemplateResource urlTemplateResource = new URLTemplateResource(javaScript,
            clazz.getResource(javaScript));

    Template template = TemplateManagerUtil.getTemplate(TemplateConstants.LANG_TYPE_FTL, urlTemplateResource,
            false);

    template.put("errorMessage", UnicodeLanguageUtil.get(_resourceBundle,
            "cannot-open-the-requested-document-due-to-the-following-" + "reason"));
    template.put("namespace", getNamespace());

    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    template.processTemplate(unsyncStringWriter);

    javascriptMenuItem.setJavaScript(unsyncStringWriter.toString());
}

From source file:com.liferay.document.library.web.internal.display.context.logic.UIItemsBuilder.java

License:Open Source License

public void addOpenInMsOfficeToolbarItem(List<ToolbarItem> toolbarItems) throws PortalException {

    if (!isOpenInMsOfficeActionAvailable()) {
        return;//ww w.jav a2 s.  c  om
    }

    String webDavURL = DLUtil.getWebDavURL(_themeDisplay, _fileEntry.getFolder(), _fileEntry,
            PropsValues.DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED);

    StringBundler sb = new StringBundler(4);

    sb.append(getNamespace());
    sb.append("openDocument('");
    sb.append(webDavURL);
    sb.append("');");

    _addJavaScriptUIItem(new JavaScriptToolbarItem(), toolbarItems, DLUIItemKeys.OPEN_IN_MS_OFFICE,
            LanguageUtil.get(_resourceBundle, "open-in-ms-office"), sb.toString());
}

From source file:com.liferay.document.library.web.internal.portlet.configuration.icon.OpenInMSOfficeFileEntryPortletConfigurationIcon.java

License:Open Source License

@Override
public String getOnClick(PortletRequest portletRequest, PortletResponse portletResponse) {

    StringBundler sb = new StringBundler(4);

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {//w  w w .  j  a  v  a  2s. c o  m
        FileEntry fileEntry = ActionUtil.getFileEntry(portletRequest);

        String webDavURL = DLUtil.getWebDavURL(themeDisplay, fileEntry.getFolder(), fileEntry,
                PropsValues.DL_FILE_ENTRY_OPEN_IN_MS_OFFICE_MANUAL_CHECK_IN_REQUIRED);

        PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

        sb.append(portletDisplay.getNamespace());

        sb.append("openDocument('");
        sb.append(webDavURL);
        sb.append("');");
    } catch (Exception e) {
    }

    return sb.toString();
}