Author: jleroux
Date: Sun Jan 4 13:44:14 2009 New Revision: 731370 URL: http://svn.apache.org/viewvc?rev=731370&view=rev Log: A modified patch from Marco Risaliti "New tool to get labels information" (https://issues.apache.org/jira/browse/OFBIZ-2070) - OFBIZ-2070 I have already commited merged changes in labels files. I commented out for now the lines in SaveLabelsToXmlFile.java which write the XML changes. We have, at least, known 2 issued related to SaveLabelsToXmlFile : . adding the ASL header . taking care of labels sorting in a case described here https://issues.apache.org/jira/browse/OFBIZ-2070?focusedCommentId=12660632#action_12660632 Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl ofbiz/trunk/framework/webtools/widget/LabelManagerScreens.xml Modified: ofbiz/trunk/framework/webtools/data/WebtoolsSecurityData.xml ofbiz/trunk/framework/webtools/servicedef/services.xml ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl Modified: ofbiz/trunk/framework/webtools/data/WebtoolsSecurityData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/data/WebtoolsSecurityData.xml?rev=731370&r1=731369&r2=731370&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/data/WebtoolsSecurityData.xml (original) +++ ofbiz/trunk/framework/webtools/data/WebtoolsSecurityData.xml Sun Jan 4 13:44:14 2009 @@ -36,6 +36,12 @@ <SecurityGroupPermission groupId="FLEXADMIN" permissionId="ARTIFACT_INFO_VIEW"/> <SecurityGroupPermission groupId="VIEWADMIN" permissionId="ARTIFACT_INFO_VIEW"/> + <!-- Labels Info security --> + <SecurityPermission description="View the Labels Info pages." permissionId="LABEL_MANAGER_VIEW"/> + <SecurityGroupPermission groupId="FULLADMIN" permissionId="LABEL_MANAGER_VIEW"/> + <SecurityGroupPermission groupId="FLEXADMIN" permissionId="LABEL_MANAGER_VIEW"/> + <SecurityGroupPermission groupId="VIEWADMIN" permissionId="LABEL_MANAGER_VIEW"/> + <!-- Data File Maintenance security --> <SecurityPermission description="Use the Data File Maintenance pages." permissionId="DATAFILE_MAINT"/> <SecurityGroupPermission groupId="FULLADMIN" permissionId="DATAFILE_MAINT"/> Modified: ofbiz/trunk/framework/webtools/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/servicedef/services.xml?rev=731370&r1=731369&r2=731370&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/servicedef/services.xml (original) +++ ofbiz/trunk/framework/webtools/servicedef/services.xml Sun Jan 4 13:44:14 2009 @@ -20,9 +20,9 @@ <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd"> - <description>OFBiz WebTools Services</description> - <vendor>OFBiz</vendor> - <version>1.0</version> + <description>OFBiz WebTools Services</description> + <vendor>OFBiz</vendor> + <version>1.0</version> <!-- Entity Import Services Transacitons are turned off for these services because they set transactions and timeouts inside the services with txTimeout parameter --> @@ -123,4 +123,19 @@ <attribute name="eomodeldFullPath" type="java.lang.String" mode="IN" optional="false"/> <attribute name="serviceName" type="java.lang.String" mode="IN" optional="false"/> </service> + <service name="saveLabelsToXmlFile" engine="java" location="org.ofbiz.webtools.labelmanager.SaveLabelsToXmlFile" + invoke="saveLabelsToXmlFile" auth="true" use-transaction="false"> + <description>Save labels to xml file</description> + <attribute name="labelFileName" type="String" mode="IN" optional="true"/> + </service> + <service name="updateLabelKey" engine="java" location="org.ofbiz.webtools.labelmanager.LabelManagerFactory" + invoke="updateLabelKey" auth="true" use-transaction="false"> + <description>Update Label Key</description> + <attribute name="key" type="String" mode="IN" optional="true"/> + <attribute name="update_label" type="String" mode="IN" optional="false"/> + <attribute name="fileName" type="String" mode="IN" optional="false"/> + <attribute name="confirm" type="String" mode="IN" optional="true"/> + <attribute name="localeNames" type="List" mode="IN" optional="true"/> + <attribute name="localeValues" type="List" mode="IN" optional="true"/> + </service> </services> Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java (added) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java Sun Jan 4 13:44:14 2009 @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.webtools.labelmanager; + +import java.util.Map; + +import javolution.util.FastMap; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilValidate; + +public class LabelInfo { + + public static final String module = LabelInfo.class.getName(); + + protected String labelKey = ""; + protected String fileName = ""; + protected String componentName = ""; + protected Map<String, String> labelValues = FastMap.newInstance(); + + public LabelInfo(String labelKey, String fileName, String componentName, String localeStr, String labelValue) throws GeneralException { + this.labelKey = labelKey; + this.fileName = fileName; + this.componentName = componentName; + setLabelValue(localeStr, labelValue, false); + } + + public String getLabelKey() { + return labelKey; + } + + public String getFileName() { + return fileName; + } + + public String getComponentName() { + return componentName; + } + + public String getLabelValue(String localeStr) { + return (String)labelValues.get(localeStr); + } + + public int getLabelValueSize() { + return labelValues.size(); + } + + public boolean setLabelValue(String localeStr, String labelValue, boolean update) { + String localeFound = getLabelValue(localeStr); + boolean isDuplicatedLocales = false; + + if (UtilValidate.isEmpty(localeFound)) { + if (UtilValidate.isNotEmpty(labelValue)) { + labelValues.put(localeStr, labelValue); + } + } else { + if (update) { + if (UtilValidate.isNotEmpty(labelValue)) { + labelValues.put(localeStr, labelValue); + } else { + labelValues.remove(localeStr); + } + } else { + Debug.logWarning("Already found locale " + localeStr + " for label " + labelKey + " into the file " + fileName, module); + isDuplicatedLocales = true; + } + } + return isDuplicatedLocales; + } +} Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java (added) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java Sun Jan 4 13:44:14 2009 @@ -0,0 +1,233 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.webtools.labelmanager; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.util.FileUtil; +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilXml; + +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.cache.UtilCache; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class LabelManagerFactory { + + public static final String module = LabelManagerFactory.class.getName(); + public static final String resource = "WebtoolsUiLabels"; + + protected static UtilCache<String, LabelManagerFactory> labelManagerFactoryCache = new UtilCache<String, LabelManagerFactory>("LabelManagerFactory"); + + protected static Map<String, LabelInfo> labels = null; + protected static Map<String, String> fileNamesFound = null; + protected static Map<String, String> fileComponent = null; + protected static Set<String> localesFound = null; + protected static Set<String> componentNamesFound = null; + protected static int duplicatedLocalesLabels = 0; + + protected static String delegatorName; + + public static LabelManagerFactory getLabelManagerFactory(String delegatorName) throws GeneralException { + if (UtilValidate.isEmpty(delegatorName)) { + delegatorName = "default"; + } + + LabelManagerFactory lmf = labelManagerFactoryCache.get(delegatorName); + + if (lmf == null) { + lmf = new LabelManagerFactory(delegatorName); + labelManagerFactoryCache.put(delegatorName, lmf); + } + return lmf; + } + + protected LabelManagerFactory(String delegatorName) throws GeneralException { + LabelManagerFactory.delegatorName = delegatorName; + + prepareAll(); + } + + private static void prepareAll() throws GeneralException { + labels = new TreeMap<String, LabelInfo>(); + fileNamesFound = new TreeMap<String, String>(); + fileComponent = new TreeMap<String, String>(); + localesFound = new TreeSet<String>(); + componentNamesFound = new TreeSet<String>(); + int duplicatedLocales = 0; + + try { + Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents(); + + for (ComponentConfig componentConfig: componentConfigs) { + String componentName = componentConfig.getComponentName(); + List<File> resourceFiles = FileUtil.findXmlFiles(componentConfig.getRootLocation(), null, "resource", null); + + for (File resourceFile: resourceFiles) { + String fileName = resourceFile.getName(); + Document resourceDocument = UtilXml.readXmlDocument(resourceFile.toURI().toURL()); + Element resourceElem = resourceDocument.getDocumentElement(); + + for (Element propertyElem: UtilXml.childElementList(resourceElem, "property")) { + String labelKey = propertyElem.getAttribute("key"); + + for (Element valueElem: UtilXml.childElementList(propertyElem, "value")) { + String localeName = valueElem.getAttribute("xml:lang"); + String labelValue = UtilXml.elementValue(valueElem); + LabelInfo label = (LabelInfo)labels.get(labelKey + "_" + fileName); + + if (UtilValidate.isEmpty(label)) { + label = new LabelInfo(labelKey, fileName, componentName, localeName, labelValue); + labels.put(labelKey + "_" + fileName, label); + } else { + if (label.setLabelValue(localeName, labelValue, false)) { + duplicatedLocales++; + } + } + localesFound.add(localeName); + componentNamesFound.add(componentName); + fileNamesFound.put(fileName, resourceFile.toURI().toString()); + fileComponent.put(fileName, componentName); + } + } + } + } + } catch(IOException ioe) { + throw new GeneralException(ioe.getMessage()); + } catch(Exception e) { + throw new GeneralException(e.getMessage()); + } + duplicatedLocalesLabels = duplicatedLocales; + } + + public static Map<String, LabelInfo> getLabels() { + return labels; + } + + public static Set<String> getLocalesFound() { + return localesFound; + } + + public static Map<String, String> getFileNamesFound() { + return fileNamesFound; + } + + public static String getFileComponent(String fileName) { + String componentName = null; + if (UtilValidate.isNotEmpty(fileName)) { + componentName = fileComponent.get(fileName); + } + return componentName; + } + + public static Set<String> getComponentNamesFound() { + return componentNamesFound; + } + + public static Set<String> getLabelsList() { + return labels.keySet(); + } + + public static int getDuplicatedLocalesLabels() { + return duplicatedLocalesLabels; + } + + public static Map<String, Object> updateLabelKey(DispatchContext dctx, Map<String, ? extends Object> context) { + String key = (String)context.get("key"); + String update_label = (String)context.get("update_label"); + String fileName = (String)context.get("fileName"); + String confirm = (String)context.get("confirm"); + List<String> localeNames = UtilGenerics.cast(context.get("localeNames")); + List<String> localeValues = UtilGenerics.cast(context.get("localeValues")); + Locale locale = (Locale) context.get("locale"); + + if (UtilValidate.isNotEmpty(confirm)) { + LabelInfo label = labels.get(key + "_" + fileName); + + // Update a Label + if (update_label.equalsIgnoreCase("Y")) { + if (UtilValidate.isNotEmpty(label)) { + updateLabelValue(localeNames, localeValues, label, key, fileName); + } + // Insert a new Label + } else { + if (UtilValidate.isNotEmpty(label)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelExisting", UtilMisc.toMap("key", key, "fileName", fileName), locale)); + } else { + if (UtilValidate.isEmpty(key)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmptyKey", locale)); + } else { + int notEmptyLabels = updateLabelValue(localeNames, localeValues, null, key, fileName); + if (notEmptyLabels == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmpty", locale)); + } + } + } + } + } + + return ServiceUtil.returnSuccess(); + } + + private static int updateLabelValue(List<String> localeNames, List<String> localeValues, LabelInfo label, String key, String fileName) { + int notEmptyLabels = 0; + int i = 0; + while (i < localeNames.size()) { + String localeName = (String)localeNames.get(i); + String localeValue = (String)localeValues.get(i); + + if (UtilValidate.isNotEmpty(localeValue)) { + if (label == null) { + try { + String componentName = getFileComponent(fileName); + label = new LabelInfo(key, fileName, componentName, localeName, localeValue); + labels.put(key + "_" + fileName, label); + } catch(Exception e) { + e.printStackTrace(); + } + } + label.setLabelValue(localeName, localeValue, true); + notEmptyLabels++; + } + i++; + } + + if (UtilValidate.isNotEmpty(label) && label.getLabelValueSize() == 0) { + labels.remove(key + "_" + fileName); + } + + return notEmptyLabels; + } +} Added: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java (added) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java Sun Jan 4 13:44:14 2009 @@ -0,0 +1,113 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.ofbiz.webtools.labelmanager; + +import java.io.File; +import java.io.FileOutputStream; +import java.net.URI; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.apache.xml.serialize.OutputFormat; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.UtilXml; +import org.ofbiz.base.util.cache.UtilCache; + +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +import org.w3c.dom.Comment; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class SaveLabelsToXmlFile { + + private static final String resource = "WebtoolsUiLabels"; + private static final String module = SaveLabelsToXmlFile.class.getName(); + + public static Map<String, Object> saveLabelsToXmlFile(DispatchContext dctx, Map<String, ? extends Object> context) { + Locale locale = (Locale)context.get("locale"); + String labelFileName = (String)context.get("labelFileName"); + + try { + LabelManagerFactory.getLabelManagerFactory(dctx.getDelegator().getDelegatorName()); + Map<String, LabelInfo> labels = LabelManagerFactory.getLabels(); + Map<String, String> fileNamesFound = LabelManagerFactory.getFileNamesFound(); + Set<String> labelsList = LabelManagerFactory.getLabelsList(); + Set<String> localesFound = LabelManagerFactory.getLocalesFound(); + + for (String fileName : fileNamesFound.keySet()) { + if (UtilValidate.isNotEmpty(labelFileName) && !(labelFileName.equalsIgnoreCase(fileName))) { + continue; + } + + String uri = (String)fileNamesFound.get(fileName); + Document resourceDocument = UtilXml.makeEmptyXmlDocument("resource"); + Element resourceElem = resourceDocument.getDocumentElement(); + Comment comment = resourceDocument.createComment("A Document Comment"); + resourceElem.getParentNode().insertBefore(comment, resourceElem); + resourceElem.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + + for (String labelKey : labelsList) { + LabelInfo labelInfo = (LabelInfo)labels.get(labelKey); + + if (!(labelInfo.getFileName().equalsIgnoreCase(fileName))) { + continue; + } + + Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument); + propertyElem.setAttribute("key", labelInfo.getLabelKey()); + + for (String localeFound : localesFound) { + String labelValue = labelInfo.getLabelValue(localeFound); + + if (UtilValidate.isNotEmpty(labelValue)) { + Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", labelValue, resourceDocument); + valueElem.setAttribute("xml:lang", localeFound); + } + } + } + +// if (resourceElem != null && uri != null) { +// File outFile = new File(new URI(uri)); +// FileOutputStream fos = new FileOutputStream(outFile); +// +// try { +// OutputFormat format = new OutputFormat(resourceDocument.getDocumentElement().getOwnerDocument(), "UTF-8", true); +// format.setIndent(4); +// format.setOmitComments(false); +// UtilXml.writeXmlDocument(fos, resourceElem, format); +// } finally { +// if (fos != null) { +// fos.close(); +// } +// } +// } + UtilCache.clearCache("properties.UtilPropertiesBundleCache"); + } + } catch (Exception e) { + Debug.logError(e, "Exception during save labels to xml file:", module); + return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); + } + return ServiceUtil.returnSuccess(); + } +} Added: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy Sun Jan 4 13:44:14 2009 @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.webtools.labelmanager.*; + +LabelManagerFactory.getLabelManagerFactory(delegator.getDelegatorName()); +context.labels = LabelManagerFactory.getLabels(); +context.labelsList = LabelManagerFactory.getLabelsList(); +context.localesFound = LabelManagerFactory.getLocalesFound(); +context.fileNamesFound = LabelManagerFactory.getFileNamesFound(); +context.componentNamesFound = LabelManagerFactory.getComponentNamesFound(); +context.duplicatedLocalesLabels = LabelManagerFactory.getDuplicatedLocalesLabels(); Added: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy Sun Jan 4 13:44:14 2009 @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.webtools.labelmanager.*; + +LabelManagerFactory.getLabelManagerFactory(delegator.getDelegatorName()); +context.labels = LabelManagerFactory.getLabels(); +context.localesFound = LabelManagerFactory.getLocalesFound(); +context.fileNamesFound = LabelManagerFactory.getFileNamesFound(); +context.componentNamesFound = LabelManagerFactory.getComponentNamesFound(); + +if (parameters.sourceKey != null && parameters.sourceFileName != null) { + context.label = context.labels.get(parameters.sourceKey + "_" + parameters.sourceFileName); +} Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=731370&r1=731369&r2=731370&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Sun Jan 4 13:44:14 2009 @@ -461,7 +461,34 @@ </request-map> <!-- Artifact Info Requests --> - <request-map uri="ArtifactInfo"><security https="true" auth="true"/><response name="success" type="view" value="ArtifactInfo"/></request-map> + <request-map uri="ArtifactInfo"> + <security https="true" auth="true"/> + <response name="success" type="view" value="ArtifactInfo"/> + </request-map> + + <!-- Label Manager Requests --> + <request-map uri="SearchLabels"> + <security https="true" auth="true"/> + <response name="success" type="view" value="SearchLabels"/> + </request-map> + + <request-map uri="SaveLabelsToXmlFile"> + <security https="true" auth="true"/> + <event type="service" invoke="saveLabelsToXmlFile"/> + <response name="success" type="view" value="SearchLabels"/> + </request-map> + + <request-map uri="UpdateLabel"> + <security https="true" auth="true"/> + <response name="success" type="view" value="UpdateLabel"/> + </request-map> + + <request-map uri="UpdateLabelKey"> + <security https="true" auth="true"/> + <event type="service" invoke="updateLabelKey"/> + <response name="success" type="view" value="SearchLabels"/> + <response name="error" type="view" value="UpdateLabel"/> + </request-map> <!-- cert requests --> <request-map uri="myCertificates"> @@ -608,6 +635,10 @@ <!-- Artifact Info Views --> <view-map name="ArtifactInfo" type="screen" page="component://webtools/widget/ArtifactInfoScreens.xml#ArtifactInfo"/> + <!-- Label Manager Views --> + <view-map name="SearchLabels" type="screen" page="component://webtools/widget/LabelManagerScreens.xml#SearchLabels"/> + <view-map name="UpdateLabel" type="screen" page="component://webtools/widget/LabelManagerScreens.xml#UpdateLabel"/> + <!-- Temporal expression views --> <view-map name="editTemporalExpression" type="screen" page="component://webtools/widget/TempExprScreens.xml#EditTemporalExpression"/> <view-map name="findTemporalExpression" type="screen" page="component://webtools/widget/TempExprScreens.xml#FindTemporalExpression"/> Added: ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl Sun Jan 4 13:44:14 2009 @@ -0,0 +1,84 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<div class="screenlet-body"> + <form action="<@ofbizUrl>SearchLabels</@ofbizUrl>" method="post"> + <table class="basic-table"> + <tr> + <td align="right" class="label"> + ${uiLabelMap.WebtoolsLabelManagerKey} + </td> + <td align="left"> + <input type="text" name="labelKey" size="30" maxlength="70" value="${parameters.labelKey?if_exists}"> + </td> + <td align="right" class="label"> + ${uiLabelMap.WebtoolsLabelManagerComponentName} + </td> + <td align="left"> + <select name="labelComponentName"> + <option value="">${uiLabelMap.WebtoolsLabelManagerAllComponents}</option> + <#list componentNamesFound as componentNameFound> + <option <#if parameters.labelComponentName?exists && parameters.labelComponentName == componentNameFound>selected="selected"</#if> value="${componentNameFound}">${componentNameFound}</option> + </#list> + </select> + </td> + </tr> + <tr> + <td align="right" class="label"> + ${uiLabelMap.WebtoolsLabelManagerFileName} + </td> + <td align="left"> + <select name="labelFileName"> + <option value="">${uiLabelMap.WebtoolsLabelManagerAllFiles}</option> + <#assign fileNames = fileNamesFound.keySet()> + <#list fileNames as fileName> + <option <#if parameters.labelFileName?exists && parameters.labelFileName == fileName>selected="selected"</#if> value="${fileName}">${fileName}</option> + </#list> + </select> + </td> + <td align="right" class="label"> + ${uiLabelMap.WebtoolsLabelManagerLocale} + </td> + <td align="left"> + <select name="labelLocaleName"> + <option value="">${uiLabelMap.WebtoolsLabelManagerAllLocales}</option> + <#list localesFound as localeFound> + <#assign locale = Static["org.ofbiz.base.util.UtilMisc"].parseLocale(localeFound)?if_exists/> + <#assign langAttr = localeFound.toString()?replace("_", "-")> + <#assign langDir = "ltr"> + <#if "ar.iw"?contains(langAttr?substring(0, 2))> + <#assign langDir = "rtl"> + </#if> + <option <#if parameters.labelLocaleName?exists && parameters.labelLocaleName == localeFound>selected="selected"</#if> value="${localeFound}" lang="${langAttr}" dir="${langDir}"><#if locale?exists && locale?has_content>${locale.getDisplayName(locale)}<#else>${localeFound}</#if></option> + </#list> + </select> + </td> + </tr> + <tr> + <td colspan="4" align="center"> + <#if (duplicatedLocalesLabels > 0)> + <br/> + <b>${uiLabelMap.WebtoolsLabelManagerWarningMessage} (${duplicatedLocalesLabels})</b> + <#else> + <input type="submit" name="searchLabels" value="${uiLabelMap.CommonFind}"/> + </#if> + </td> + </tr> + </table> + </form> +</div> Added: ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl Sun Jan 4 13:44:14 2009 @@ -0,0 +1,97 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<div class="screenlet-body"> + <form method="post" action="<@ofbizUrl>UpdateLabelKey</@ofbizUrl>" name="UpdateLabelForm"> + <table class="basic-table" cellspacing="3"> + <tr> + <td colspan="2"> </td> + </tr> + <tr> + <td align="right"><b>${uiLabelMap.WebtoolsLabelManagerKey}</b></td> + <td align="left"> + <#if parameters.sourceKey?exists> + ${parameters.sourceKey} + <input type="hidden" name="key" value="${parameters.sourceKey}"> + <input type="hidden" name="update_label" value="Y"> + <#else> + <input type="text" name="key" size="70" value="${parameters.key?if_exists}" > + <input type="hidden" name="update_label" value="N"> + </#if> + </td> + </tr> + <tr> + <td align="right"><b>${uiLabelMap.WebtoolsLabelManagerFileName}</b></td> + <td align="left"> + <#if parameters.sourceFileName?exists> + ${parameters.sourceFileName} + <input type="hidden" name="fileName" value="${parameters.sourceFileName}"> + <#else> + <select name="fileName"> + <#assign fileNames = fileNamesFound.keySet()> + <#list fileNames as fileName> + <option <#if parameters.fileName?exists && parameters.fileName == fileName>selected="selected"</#if> value="${fileName}">${fileName}</option> + </#list> + </select> + </#if> + </td> + </tr> + <tr> + <td colspan="2"> </td> + </tr> + <#list localesFound as localeFound> + <#if parameters.sourceKey?exists> + <#assign labelVal = label.getLabelValue(localeFound)?if_exists> + <#else> + <#assign labelVal = ""> + </#if> + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + </#if> + <#if showLocale == true> + <tr> + <#assign locale = Static["org.ofbiz.base.util.UtilMisc"].parseLocale(localeFound)?if_exists/> + <#if locale?exists && locale?has_content> + <#assign langAttr = localeFound.toString()?replace("_", "-")> + <#assign langDir = "ltr"> + <#if "ar.iw"?contains(langAttr?substring(0, 2))> + <#assign langDir = "rtl"> + </#if> + <td align="right" lang="${langAttr}" dir="${langDir}"> + <b>${locale.getDisplayName(locale)}</b> + </td> + <#else> + <td align="right"><b>${localeFound}</b></td> + </#if> + <td align="left"> + <input type="hidden" name="localeNames" value="${localeFound}"> + <input type="text" name="localeValues" size="70" value="${labelVal?if_exists}"> + </td> + </tr> + </#if> + </#list> + <tr> + <td colspan="2" align="center"> + <input type="submit" value="${uiLabelMap.CommonConfirm}" name="confirm"/> + <input type="submit" value="${uiLabelMap.CommonCancel}"/> + </td> + </tr> + </table> + </form> +</div> Added: ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl (added) +++ ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl Sun Jan 4 13:44:14 2009 @@ -0,0 +1,94 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<div class="screenlet-body"> + <#if parameters.searchLabels?exists> + <a href="<@ofbizUrl>UpdateLabel</@ofbizUrl>" class="buttontext">${uiLabelMap.WebtoolsLabelManagerAddNew}</a> + <a href="<@ofbizUrl>SaveLabelsToXmlFile?labelFileName=${parameters.labelFileName?if_exists}</@ofbizUrl>" class="buttontext">${uiLabelMap.WebtoolsLabelManagerUpdateFile}</a> + </#if> + <table class="basic-table hover-bar" cellspacing="3"> + <tr class="header-row"> + <td>${uiLabelMap.WebtoolsLabelManagerKey}</td> + <td>${uiLabelMap.WebtoolsLabelManagerFileName}</td> + <#list localesFound as localeFound> + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + </#if> + <#if showLocale == true> + <#assign locale = Static["org.ofbiz.base.util.UtilMisc"].parseLocale(localeFound)?if_exists/> + <#if locale?exists && locale?has_content> + <#assign langAttr = localeFound.toString()?replace("_", "-")> + <#assign langDir = "ltr"> + <#if "ar.iw"?contains(langAttr?substring(0, 2))> + <#assign langDir = "rtl"> + </#if> + <td lang="${langAttr}" dir="${langDir}"> + ${locale.getDisplayName(locale)} + </td> + <#else> + <td>${localeFound}</td> + </#if> + </#if> + </#list> + </tr> + <#if parameters.searchLabels?exists> + <#assign rowNum = "2"> + <#assign previousKey = ""> + <#list labelsList as labelList> + <#assign label = labels.get(labelList)> + <#assign showLabel = true> + <#if parameters.labelKey?exists && parameters.labelKey != "" && parameters.labelKey != label.labelKey> + <#assign showLabel = false> + </#if> + <#if showLabel && parameters.labelFileName?exists && parameters.labelFileName != "" && parameters.labelFileName != label.fileName> + <#assign showLabel = false> + </#if> + <#if showLabel && parameters.labelComponentName?exists && parameters.labelComponentName != "" && parameters.labelComponentName != label.componentName> + <#assign showLabel = false> + </#if> + <#if showLabel == true> + <tr <#if rowNum == "1">class="alternate-row"</#if>> + <td><a href="<@ofbizUrl>UpdateLabel?sourceKey=${label.labelKey}&sourceFileName=${label.fileName}</@ofbizUrl>" <#if previousKey == label.labelKey>class="submenutext"</#if>>${label.labelKey}</a></td> + <td>${label.fileName}</td> + <#list localesFound as localeFound> + <#assign labelVal = label.getLabelValue(localeFound)?if_exists> + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + </#if> + <#if showLocale == true> + <#if labelVal?has_content> + <td>${labelVal}</td> + <#else> + <td> </td> + </#if> + </#if> + </#list> + </tr> + <#if rowNum == "2"> + <#assign rowNum = "1"> + <#else> + <#assign rowNum = "2"> + </#if> + <#assign previousKey = label.labelKey> + </#if> + </#list> + </#if> + </table> +</div> Modified: ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl?rev=731370&r1=731369&r2=731370&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl Sun Jan 4 13:44:14 2009 @@ -70,13 +70,17 @@ <#if security.hasPermission("ARTIFACT_INFO_VIEW", session)> <li><h3>${uiLabelMap.WebtoolsGeneralArtifactInfoTools}</h3></li> <li><a href="<@ofbizUrl>ArtifactInfo</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsArtifactInfo}</a></li> - <li><a href="<@ofbizUrl>entityref</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReference} - Interactive</a></li> + <li><a href="<@ofbizUrl>entityref</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceInteractiveVersion}</a></li> <li><a href="<@ofbizUrl>ServiceList</@ofbizUrl>">${uiLabelMap.WebtoolsServiceReference}</a></li> </#if> + <#if security.hasPermission("LABEL_MANAGER_VIEW", session)> + <li><h3>${uiLabelMap.WebtoolsLabelManager}</h3></li> + <li><a href="<@ofbizUrl>SearchLabels</@ofbizUrl>">${uiLabelMap.WebtoolsLabelManager}</a></li> + </#if> <#if security.hasPermission("ENTITY_MAINT", session)> <li><h3>${uiLabelMap.WebtoolsEntityEngineTools}</h3></li> <li><a href="<@ofbizUrl>entitymaint</@ofbizUrl>">${uiLabelMap.WebtoolsEntityDataMaintenance}</a></li> - <li><a href="<@ofbizUrl>entityref</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReference} - Interactive</a></li> + <li><a href="<@ofbizUrl>entityref</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceInteractiveVersion}</a></li> <li><a href="<@ofbizUrl>entityref?forstatic=true</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceStaticVersion}</a></li> <li><a href="<@ofbizUrl>entityrefReport</@ofbizUrl>" target="_blank">${uiLabelMap.WebtoolsEntityReferencePdf}</a></li> <li><a href="<@ofbizUrl>EntitySQLProcessor</@ofbizUrl>">${uiLabelMap.PageTitleEntitySQLProcessor}</a></li> Added: ofbiz/trunk/framework/webtools/widget/LabelManagerScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/LabelManagerScreens.xml?rev=731370&view=auto ============================================================================== --- ofbiz/trunk/framework/webtools/widget/LabelManagerScreens.xml (added) +++ ofbiz/trunk/framework/webtools/widget/LabelManagerScreens.xml Sun Jan 4 13:44:14 2009 @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd"> + <screen name="SearchLabels"> + <section> + <condition> + <if-has-permission permission="LABEL_MANAGER_VIEW"/> + </condition> + <actions> + <set field="titleProperty" value="WebtoolsLabelManager"/> + <script location="component://webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy"/> + </actions> + <widgets> + <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <screenlet id="SearchLabelsPanel" title="${uiLabelMap.WebtoolsLabelManagerSearchBy}" collapsible="true"> + <platform-specific><html><html-template location="component://webtools/webapp/webtools/labelmanager/SearchLabels.ftl"/></html></platform-specific> + </screenlet> + <screenlet id="ViewLabelsPanel" title="${uiLabelMap.WebtoolsLabelManager}" collapsible="false"> + <platform-specific><html><html-template location="component://webtools/webapp/webtools/labelmanager/ViewLabels.ftl"/></html></platform-specific> + </screenlet> + </decorator-section> + </decorator-screen> + </widgets> + <fail-widgets> + <label style="h3">${uiLabelMap.WebtoolsLabelManagerSecuryError}</label> + </fail-widgets> + </section> + </screen> + <screen name="UpdateLabel"> + <section> + <condition> + <if-has-permission permission="LABEL_MANAGER_VIEW"/> + </condition> + <actions> + <set field="titleProperty" value="WebtoolsLabelManagerUpdate"/> + <script location="component://webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy"/> + </actions> + <widgets> + <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <screenlet id="UpdateLabelPanel" title="${uiLabelMap.WebtoolsLabelManagerUpdate}"> + <platform-specific><html><html-template location="component://webtools/webapp/webtools/labelmanager/UpdateLabel.ftl"/></html></platform-specific> + </screenlet> + </decorator-section> + </decorator-screen> + </widgets> + <fail-widgets> + <label style="h3">${uiLabelMap.WebtoolsLabelManagerSecuryError}</label> + </fail-widgets> + </section> + </screen> +</screens> |
Free forum by Nabble | Edit this page |