public ResourceBundle getMergeResourceBundle(String[] names) { ResourceBundleService service = (ResourceBundleService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(ResourceBundleService.class); ResourceBundle res = service.getResourceBundle(names, locale_); return res; }
/** * Get resource bundle from given resource file * * @param name : resource file name * @param key : key * @param cl : ClassLoader to load resource file * @return */ public static String getResourceBundle(String name, String key, ClassLoader cl) { Locale locale = WebuiRequestContext.getCurrentInstance().getLocale(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); ResourceBundle resourceBundle = resourceBundleService.getResourceBundle(name, locale, cl); try { return resourceBundle.getString(key); } catch (MissingResourceException ex) { return key; } }
public void loadResources() throws Exception { try { ResourceBundleService resBundleServ = getApplicationComponent(ResourceBundleService.class); org.exoplatform.services.resources.Query lastQuery_ = new org.exoplatform.services.resources.Query(null, null); PageList pageList = resBundleServ.findResourceDescriptions(lastQuery_); UIVirtualList virtualList = getChild(UIVirtualList.class); virtualList.dataBind(pageList); } catch (Exception e) { UIApplication uiApp = Util.getPortalRequestContext().getUIApplication(); uiApp.addMessage(new ApplicationMessage("UISearchForm.msg.empty", null)); } }
/** * @param orgNode Processed node * @param propertyName which property used for editing * @param inputType input type for editing: TEXT, TEXTAREA, WYSIWYG * @param cssClass class name for CSS, should implement: cssClass, [cssClass]Title Edit[cssClass] * as relative css Should create the function: * InlineEditor.presentationRequestChange[cssClass] to request the rest-service * @param isGenericProperty set as true to use generic javascript function, other wise, must * create the correctspond function InlineEditor.presentationRequestChange[cssClass] * @param arguments Extra parameter for Input component (toolbar, width, height,.. for * CKEditor/TextArea) * @return String that can be put on groovy template * @throws Exception * @author vinh_nguyen */ public static String getInlineEditingField( Node orgNode, String propertyName, String defaultValue, String inputType, String idGenerator, String cssClass, boolean isGenericProperty, String... arguments) throws Exception { HashMap<String, String> parsedArguments = parseArguments(arguments); String height = parsedArguments.get(HEIGHT); String bDirection = parsedArguments.get(BUTTON_DIR); String publishLink = parsedArguments.get(FAST_PUBLISH_LINK); Locale locale = WebuiRequestContext.getCurrentInstance().getLocale(); String language = locale.getLanguage(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); ResourceBundle resourceBundle; resourceBundle = resourceBundleService.getResourceBundle(LOCALE_WEBUI_DMS, locale); PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance(); String draft = INLINE_DRAFT; String published = INLINE_PUBLISHED; try { draft = portletRequestContext.getApplicationResourceBundle().getString("PublicationStates.draft"); published = portletRequestContext .getApplicationResourceBundle() .getString("PublicationStates.published"); } catch (MissingResourceException ex) { if (LOG.isWarnEnabled()) { LOG.warn(ex.getMessage()); } } String portletRealID = org.exoplatform.wcm.webui.Utils.getRealPortletId( (PortletRequestContext) WebuiRequestContext.getCurrentInstance()); StringBuffer sb = new StringBuffer(); StringBuffer actionsb = new StringBuffer(); String repo = ((ManageableRepository) orgNode.getSession().getRepository()).getConfiguration().getName(); String workspace = orgNode.getSession().getWorkspace().getName(); String uuid = orgNode.getUUID(); String strSuggestion = ""; String acceptButton = ""; String cancelButton = ""; portletRealID = portletRealID.replace('-', '_'); String showBlockId = "Current" + idGenerator + "_" + portletRealID; String editBlockEditorID = "Edit" + idGenerator + "_" + portletRealID; String editFormID = "Edit" + idGenerator + "Form_" + portletRealID; String newValueInputId = "new" + idGenerator + "_" + portletRealID; String currentValueID = "old" + idGenerator + "_" + portletRealID; String siteName = org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getPortalOwner(); String currentValue = StringUtils.replace(defaultValue, "{portalName}", siteName); try { strSuggestion = resourceBundle.getString("UIPresentation.label.EditingSuggestion"); acceptButton = resourceBundle.getString("UIPresentation.title.AcceptButton"); cancelButton = resourceBundle.getString("UIPresentation.title.CancelButton"); } catch (MissingResourceException e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } actionsb.append(" return InlineEditor.presentationRequestChange"); if (isGenericProperty) { actionsb .append("Property") .append("('") .append("/property?', '") .append(propertyName) .append("', '"); } else { actionsb.append(cssClass).append("('"); } actionsb .append(currentValueID) .append("', '") .append(newValueInputId) .append("', '") .append(repo) .append("', '") .append(workspace) .append("', '") .append(uuid) .append("', '") .append(editBlockEditorID) .append("', '") .append(showBlockId) .append("', '") .append(siteName) .append("', '") .append(language); if (inputType.equals(INPUT_WYSIWYG)) { actionsb.append("', 1);"); } else { actionsb.append("');"); } String strAction = actionsb.toString(); if (orgNode.hasProperty(propertyName)) { try { if (propertyName.equals(EXO_TITLE)) return ContentReader.getXSSCompatibilityContent( orgNode.getProperty(propertyName).getString()); if (org.exoplatform.wcm.webui.Utils.getCurrentMode().equals(WCMComposer.MODE_LIVE)) return StringUtils.replace( orgNode.getProperty(propertyName).getString(), "{portalName}", siteName); else return "<div class=\"WCMInlineEditable\" contenteditable=\"true\" propertyName=\"" + propertyName + "\" repo=\"" + repo + "\" workspace=\"" + workspace + "\"" + " uuid=\"" + uuid + "\" siteName=\"" + siteName + "\" publishedMsg=\"" + published + "\" draftMsg=\"" + draft + "\" fastpublishlink=\"" + publishLink + "\" language=\"" + language + "\" >" + orgNode.getProperty(propertyName).getString() + "</div>"; } catch (Exception e) { if (org.exoplatform.wcm.webui.Utils.getCurrentMode().equals(WCMComposer.MODE_LIVE)) return currentValue; else return "<div class=\"WCMInlineEditable\" contenteditable=\"true\" propertyName=\"" + propertyName + "\" repo=\"" + repo + "\" workspace=\"" + workspace + "\" " + "uuid=\"" + uuid + "\" siteName=\"" + siteName + "\" publishedMsg=\"" + published + "\" draftMsg=\"" + draft + "\" fastpublishlink=\"" + publishLink + "\" language=\"" + language + "\" >" + defaultValue + "</div>"; } } sb.append("<div class=\"InlineEditing\" >\n"); sb.append("\n<div rel=\"tooltip\" data-placement=\"bottom\" id=\"") .append(showBlockId) .append("\" Class=\"") .append(cssClass) .append("\""); sb.append("title=\"").append(strSuggestion).append("\""); sb.append(" onClick=\"InlineEditor.presentationSwitchBlock('") .append(showBlockId) .append("', '") .append(editBlockEditorID) .append("');\""); sb.append("onmouseout=\"this.className='") .append(cssClass) .append("';\" onblur=\"this.className='") .append(cssClass) .append("';\" onfocus=\"this.className='") .append(cssClass) .append("Hover") .append("';\" onmouseover=\"this.className='") .append(cssClass) .append("Hover';\">") .append(currentValue) .append("</div>\n"); sb.append("\t<div id=\"") .append(editBlockEditorID) .append("\" class=\"Edit") .append(cssClass) .append("\">\n"); sb.append("\t\t<form name=\"") .append(editFormID) .append("\" id=\"") .append(editFormID) .append("\" onSubmit=\"") .append(strAction) .append("\">\n"); sb.append("<DIV style=\"display:none; visible:hidden\" id=\"") .append(currentValueID) .append("\" name=\"") .append(currentValueID) .append("\">") .append(currentValue) .append("</DIV>"); if (bDirection != null && bDirection.equals(LEFT2RIGHT)) { sb.append("\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\"") .append(" class =\"AcceptButton\" style=\"float:left\" onclick=\"") .append(strAction) .append("\" title=\"" + acceptButton + "\"> </a>\n"); sb.append( "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"CancelButton\" style=\"float:left\" ") .append("onClick=\"InlineEditor.presentationSwitchBlock('"); sb.append(editBlockEditorID) .append("', '") .append(showBlockId) .append("');\" title=\"" + cancelButton + "\"> </a>\n"); } else { sb.append( "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"CancelButton\" ") .append("onClick=\"InlineEditor.presentationSwitchBlock('"); sb.append(editBlockEditorID) .append("', '") .append(showBlockId) .append("');\" title=\"" + cancelButton + "\"> </a>\n"); sb.append( "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"AcceptButton\" onclick=\"") .append(strAction) .append("\" title=\"" + acceptButton + "\"> </a>\n"); } sb.append("\t\t<div class=\"Edit").append(cssClass).append("Input\">\n "); sb.append("\n\t\t</div>\n\t</form>\n</div>\n\n</div>"); return sb.toString(); }