Modified: 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=757081&r1=757080&r2=757081&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java Sat Mar 21 23:25:25 2009 @@ -53,14 +53,14 @@ import org.w3c.dom.Node; public class LabelManagerFactory { - + public static final String module = LabelManagerFactory.class.getName(); public static final String resource = "WebtoolsUiLabels"; - + public static final String keySeparator = "#"; - + 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; @@ -69,32 +69,32 @@ protected static Map<String, Map<String, Integer>> references = null; protected static List<LabelInfo> duplicatedLocalesLabelsList = null; protected static int duplicatedLocalesLabels = 0; - + protected static GenericDelegator delegator; protected static ModelReader entityModelReader; protected static DispatchContext dispatchContext; - + 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 { delegator = GenericDelegator.getGenericDelegator(delegatorName); entityModelReader = ModelReader.getModelReader(delegatorName); dispatchContext = new DispatchContext("LabelManagerFactoryDispCtx", null, this.getClass().getClassLoader(), null); prepareAll(); } - + private static void prepareAll() throws GeneralException { labels = new TreeMap<String, LabelInfo>(); fileNamesFound = new TreeMap<String, String>(); @@ -104,11 +104,11 @@ duplicatedLocalesLabelsList = FastList.newInstance(); references = null; int duplicatedLocales = 0; - + try { boolean sharkComponent = false; Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents(); - + for (ComponentConfig componentConfig : componentConfigs) { String componentName = componentConfig.getComponentName(); List<File> resourceFiles = FileUtil.findXmlFiles(componentConfig.getRootLocation(), null, "resource", null); @@ -119,20 +119,20 @@ Document resourceDocument = UtilXml.readXmlDocument(resourceFile.toURI().toURL()); Element resourceElem = resourceDocument.getDocumentElement(); String labelKeyComment = ""; - + for (Node propertyNode : UtilXml.childNodeList(resourceElem.getFirstChild())) { if (propertyNode instanceof Element) { Element propertyElem = (Element) propertyNode; String labelKey = StringUtil.defaultWebEncoder.canonicalize(propertyElem.getAttribute("key")); String labelComment = ""; - + for (Node valueNode : UtilXml.childNodeList(propertyElem.getFirstChild())) { if (valueNode instanceof Element) { Element valueElem = (Element) valueNode; String localeName = valueElem.getAttribute("xml:lang"); String labelValue = StringUtil.defaultWebEncoder.canonicalize(UtilXml.nodeValue(valueElem.getFirstChild())); LabelInfo label = labels.get(labelKey + keySeparator + fileName); - + if (UtilValidate.isEmpty(label)) { label = new LabelInfo(labelKey, labelKeyComment, fileName, componentName, localeName, labelValue, labelComment); labels.put(labelKey + keySeparator + fileName, label); @@ -166,7 +166,7 @@ } } } - + // get labels references from sources references = LabelReferences.getLabelReferences(); } catch (IOException ioe) { @@ -176,31 +176,31 @@ } duplicatedLocalesLabels = duplicatedLocales; } - + public static GenericDelegator getDelegator() { return delegator; } - + public static ModelReader getModelReader() { return entityModelReader; } - + public static DispatchContext getDispatchContext() { return dispatchContext; } - + 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)) { @@ -208,59 +208,59 @@ } return componentName; } - + public static Set<String> getComponentNamesFound() { return componentNamesFound; } - + public static Map<String, Map<String, Integer>> getReferences() { return references; } - + public static Set<String> getLabelsList() { return labels.keySet(); } - + public static Set<String> getReferencesList() { return references.keySet(); } - + public static int getLabelReferenceFile(String key) { int refFile = 0; boolean keyFound = false; - + if (key == null) { key = ""; } - + for (Map.Entry<String, String> e : fileNamesFound.entrySet()) { String keyToSearch = key + keySeparator + e.getKey(); - + if (labels.containsKey(keyToSearch)) { keyFound = true; break; } } - + if (!keyFound) { Map<String, Integer> reference = references.get(key); - + if (UtilValidate.isNotEmpty(reference)) { refFile = reference.size(); } } - + return refFile; } - + public static int getDuplicatedLocalesLabels() { return duplicatedLocalesLabels; } - + public static List<LabelInfo> getDuplicatedLocalesLabelsList() { return duplicatedLocalesLabelsList; } - + public static Map<String, Object> updateLabelKey(DispatchContext dctx, Map<String, ? extends Object> context) { String key = (String) context.get("key"); String keyComment = (String) context.get("keyComment"); @@ -272,13 +272,13 @@ List<String> localeValues = UtilGenerics.cast(context.get("localeValues")); List<String> localeComments = UtilGenerics.cast(context.get("localeComments")); Locale locale = (Locale) context.get("locale"); - + // Remove a Label if (UtilValidate.isNotEmpty(removeLabel)) { labels.remove(key + keySeparator + fileName); } else if (UtilValidate.isNotEmpty(confirm)) { LabelInfo label = labels.get(key + keySeparator + fileName); - + // Update a Label if (update_label.equalsIgnoreCase("Y")) { if (UtilValidate.isNotEmpty(label)) { @@ -300,10 +300,10 @@ } } } - + return ServiceUtil.returnSuccess(); } - + public static Map<String, Object> updateAndSaveLabelKey(DispatchContext dctx, Map<String, ? extends Object> context) { String key = (String) context.get("key"); String keyComment = (String) context.get("keyComment"); @@ -316,12 +316,12 @@ List<String> localeComments = UtilGenerics.cast(context.get("localeComments")); GenericValue userLogin = (GenericValue) context.get("userLogin"); LocalDispatcher dispatcher = dctx.getDispatcher(); - + Map<String, Object> contextInput = UtilMisc.toMap("key", key, "keyComment", keyComment, "update_label", update_label, "fileName", fileName, "confirm", confirm, "removeLabel", removeLabel, "localeNames", localeNames, "localeValues", localeValues, "localeComments", localeComments, "userLogin", userLogin); try { Map<String, Object> updatedKey = dispatcher.runSync("updateLabelKey", contextInput); - + if (ServiceUtil.isError(updatedKey)) { return updatedKey; } else { @@ -331,7 +331,7 @@ return ServiceUtil.returnError("error on saving label key :" + key); } } - + private static int updateLabelValue(List<String> localeNames, List<String> localeValues, List<String> localeComments, LabelInfo label, String key, String keyComment, String fileName) { int notEmptyLabels = 0; int i = 0; @@ -339,7 +339,7 @@ String localeName = localeNames.get(i); String localeValue = localeValues.get(i); String localeComment = localeComments.get(i); - + if (UtilValidate.isNotEmpty(localeValue) || UtilValidate.isNotEmpty(localeComment)) { if (label == null) { try { @@ -357,7 +357,7 @@ } i++; } - + return notEmptyLabels; } } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java?rev=757081&r1=757080&r2=757081&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java Sat Mar 21 23:25:25 2009 @@ -52,7 +52,7 @@ import org.w3c.dom.Element; public class LabelReferences { - + public static final String module = LabelReferences.class.getName(); private static final String uiLabelMap = "${uiLabelMap."; private static final String uiLabelMapInLayoutSettings = "uiLabelMap."; @@ -62,53 +62,53 @@ private static final String startExpression = "${"; private static final String endExpression = "}"; private static Map<String, Map<String, Integer>> references = null; - + public static Map<String, Map<String, Integer>> getLabelReferences() throws GeneralException { references = new TreeMap<String, Map<String, Integer>>(); - + // get labels from FTL files getLabelsFromFtlFiles(); - + // get labels from java files getLabelsFromJavaFiles(); - + // get labels from simple method files getLabelsFromSimpleMethodFiles(); - + // get labels from form widgets files getLabelsFromFormWidgets(); - + // get labels from screen widgets files getLabelsFromScreenWidgets(); - + // get labels from menu widgets files getLabelsFromMenuWidgets(); - + // get labels from tree widgets files getLabelsFromTreeWidgets(); - + // get labels from Ofbiz components files getLabelsFromOfbizComponents(); - + return references; } - + private static void getLabelsFromFtlFiles() throws GeneralException { try { List<File> ftlFiles = FileUtil.findFiles("ftl", null, null, uiLabelMap); - + for (File ftlFile : ftlFiles) { String fileNameURI = ftlFile.toURI().toString(); String inFile = FileUtil.readString("UTF-8", ftlFile); int pos = 0; while (pos >= 0) { pos = inFile.indexOf(uiLabelMap, pos); - + if (pos >= 0) { int endLabel = inFile.indexOf("}", pos); - + if (endLabel >= 0) { String labelKey = inFile.substring(pos + uiLabelMap.length(), endLabel); @@ -122,7 +122,7 @@ } /* * ftlFiles = FileUtil.findFiles("ftl", null, null, getEntityLabel); - * + * * for (File ftlFile: ftlFiles) { getFtlEntityLabels(ftlFile, * getEntityLabel); } */ @@ -130,12 +130,12 @@ throw new GeneralException(ioe.getMessage()); } } - + private static void getLabelsFromJavaFiles() throws GeneralException { try { List<File> javaFiles = FileUtil.findFiles("java", null, null, getMessage); - + for (File javaFile : javaFiles) { getJavaLabels(javaFile, getMessage); } @@ -143,7 +143,7 @@ throw new GeneralException(ioe.getMessage()); } } - + private static void getJavaLabels(File javaFile, String message) throws GeneralException { try { @@ -152,34 +152,34 @@ int pos = 0; while (pos >= 0) { pos = inFile.indexOf(message, pos); - + if (pos >= 0) { int offSet = (pos + 200 > inFile.length()) ? inFile .length() : pos + 200; String searchComma = inFile.substring(pos, offSet); int firstComma = searchComma.indexOf(",\"", 0); - + if (firstComma < 0) { firstComma = searchComma.indexOf(", \"", 0); pos = pos + firstComma + 3; } else { pos = pos + firstComma + 2; } - + if (firstComma >= 0) { offSet = (pos + 100 > inFile.length()) ? inFile .length() : pos + 100; searchComma = inFile.substring(pos, offSet); int secondComma = searchComma.indexOf("\",", 0); int endString = pos; - + if (secondComma < 0) { secondComma = searchComma.indexOf("\" ,", 0); endString = endString + secondComma + 1; } else { endString = endString + secondComma; } - + if (secondComma >= 0) { setLabelReference(inFile.substring(pos, endString), fileNameURI); @@ -193,7 +193,7 @@ throw new GeneralException(ioe.getMessage()); } } - + private static void getFtlEntityLabels(File javaFile, String message) throws GeneralException { try { @@ -202,14 +202,14 @@ int pos = 0; while (pos >= 0) { pos = inFile.indexOf(message, pos); - + if (pos >= 0) { int offSet = (pos + 200 > inFile.length()) ? inFile .length() : pos + 200; String searchDoubleQuote = inFile .substring(pos + 6, offSet); int firstComma = searchDoubleQuote.indexOf("\"", 0); - + if (firstComma >= 0) { offSet = (firstComma + 100 > inFile.length()) ? inFile .length() : firstComma + 100; @@ -217,7 +217,7 @@ firstComma, offSet); int endMethodName = searchLocale .indexOf(", locale)", 0); - + if (endMethodName < 0) { endMethodName = searchLocale.indexOf(",locale)", 0); } @@ -234,20 +234,20 @@ throw new GeneralException(ioe.getMessage()); } } - + private static void getLabelsFromSimpleMethodFiles() throws GeneralException { try { List<File> simpleMethodsFiles = FileUtil.findXmlFiles(null, null, "simple-methods", "http://ofbiz.apache.org/dtds/simple-methods.xsd"); - + for (File simpleMethodFile : simpleMethodsFiles) { String fileNameURI = simpleMethodFile.toURI().toString(); Document simpleMethodDocument = UtilXml .readXmlDocument(simpleMethodFile.toURI().toURL()); Element rootElem = simpleMethodDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkSimpleMethodTag(elem1, fileNameURI); for (Element elem2 : UtilXml.childElementList(elem1)) { @@ -276,7 +276,7 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkSimpleMethodTag(Element elem, String fileNameURI) throws GeneralException { // fail-property labels @@ -284,18 +284,18 @@ getFailPropertyTag(elem, fileNameURI); } } - + private static void getLabelsFromFormWidgets() throws GeneralException { try { List<File> formsFiles = FileUtil.findXmlFiles(null, null, "forms", "http://ofbiz.apache.org/dtds/widget-form.xsd"); - + for (File formsFile : formsFiles) { String fileNameURI = formsFile.toURI().toString(); Document formDocument = UtilXml.readXmlDocument(formsFile .toURI().toURL()); Element rootElem = formDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { Map<String, String> autoFieldsEntity = FastMap .newInstance(); @@ -328,7 +328,7 @@ setLabelReference(labelKey, fileNameURI); } } - + for (Map.Entry<String, String> entry : autoFieldsService .entrySet()) { if ("N".equals(entry.getValue())) { @@ -344,7 +344,7 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkFormsTag(Element elem, String fileNameURI, Map<String, String> autoFieldsEntity, Map<String, String> autoFieldsService) throws GeneralException { @@ -372,19 +372,19 @@ getDisplayEntityTag(elem, fileNameURI); } } - + private static void getLabelsFromScreenWidgets() throws GeneralException { try { List<File> screensFiles = FileUtil .findXmlFiles(null, null, "screens", "http://ofbiz.apache.org/dtds/widget-screen.xsd"); - + for (File screensFile : screensFiles) { String fileNameURI = screensFile.toURI().toString(); Document screenDocument = UtilXml.readXmlDocument(screensFile .toURI().toURL()); Element rootElem = screenDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkScreensTag(elem1, fileNameURI); for (Element elem2 : UtilXml.childElementList(elem1)) { @@ -456,7 +456,7 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkScreensTag(Element elem, String fileNameURI) { // set labels if ("set".equals(elem.getTagName())) { @@ -472,18 +472,18 @@ getLinkTag(elem, fileNameURI); } } - + private static void getLabelsFromMenuWidgets() throws GeneralException { try { List<File> menusFiles = FileUtil.findXmlFiles(null, null, "menus", "http://ofbiz.apache.org/dtds/widget-menu.xsd"); - + for (File menuFiles : menusFiles) { String fileNameURI = menuFiles.toURI().toString(); Document menuDocument = UtilXml.readXmlDocument(menuFiles .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkMenuTag(elem1, fileNameURI); for (Element elem2 : UtilXml.childElementList(elem1)) { @@ -508,25 +508,25 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkMenuTag(Element elem, String fileNameURI) { // menu-item labels if ("menu-item".equals(elem.getTagName())) { getMenuItemTag(elem, fileNameURI); } } - + private static void getLabelsFromTreeWidgets() throws GeneralException { try { List<File> treeFiles = FileUtil.findXmlFiles(null, null, "menus", "http://ofbiz.apache.org/dtds/widget-tree.xsd"); - + for (File treeFile : treeFiles) { String fileNameURI = treeFile.toURI().toString(); Document menuDocument = UtilXml.readXmlDocument(treeFile .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkTreeTag(elem1, fileNameURI); for (Element elem2 : UtilXml.childElementList(elem1)) { @@ -551,26 +551,26 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkTreeTag(Element elem, String fileNameURI) { // link labels if ("link".equals(elem.getTagName())) { getLinkTag(elem, fileNameURI); } } - + private static void getLabelsFromOfbizComponents() throws GeneralException { try { List<File> componentsFiles = FileUtil.findXmlFiles(null, null, "ofbiz-component", "http://ofbiz.apache.org/dtds/ofbiz-component.xsd"); - + for (File componentFile : componentsFiles) { String fileNameURI = componentFile.toURI().toString(); Document menuDocument = UtilXml.readXmlDocument(componentFile .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkOfbizComponentTag(elem1, fileNameURI); for (Element elem2 : UtilXml.childElementList(elem1)) { @@ -584,14 +584,14 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkOfbizComponentTag(Element elem, String fileNameURI) { // webapp labels if ("webapp".equals(elem.getTagName())) { getWebappTag(elem, fileNameURI); } } - + private static void setLabelReference(String labelKey, String fileNameURI) { Map<String, Integer> reference = references.get(labelKey); if (UtilValidate.isEmpty(reference)) { @@ -600,7 +600,7 @@ references.put(labelKey, reference); } else { Integer labelsInFile = reference.get(fileNameURI); - + if (UtilValidate.isEmpty(labelsInFile)) { labelsInFile = new Integer(1); } else { @@ -609,20 +609,20 @@ reference.put(fileNameURI, labelsInFile); } } - + private static boolean getLabelFromTag(Element element, String fileNameURI, String attributeValue, String stringToSearch) { boolean stringFound = false; - + if (UtilValidate.isNotEmpty(attributeValue)) { int pos = 0; - + while (pos >= 0) { pos = attributeValue.indexOf(stringToSearch, pos); - + if (pos >= 0) { int graph = attributeValue.indexOf("}", pos); - + if (graph >= 0) { String labelKey = attributeValue.substring(pos + stringToSearch.length(), graph); @@ -636,7 +636,7 @@ } return stringFound; } - + private static void getSetTag(Element element, String fileNameURI) { String setField = UtilFormatOut .checkNull(element.getAttribute("field")); @@ -644,7 +644,7 @@ .checkNull(element.getAttribute("value")); String fromField = UtilFormatOut.checkNull(element .getAttribute("from-field")); - + if (UtilValidate.isNotEmpty(setField)) { if (UtilValidate.isNotEmpty(setValue) && ("applicationTitle".equals(setField) @@ -669,11 +669,11 @@ } } } - + private static void getScreenletTag(Element element, String fileNameURI) { String screenTitle = UtilFormatOut.checkNull(element .getAttribute("title")); - + if (UtilValidate.isNotEmpty(screenTitle)) { // screenlet title with hardcoded labels if (!getLabelFromTag(element, fileNameURI, screenTitle, uiLabelMap)) { @@ -681,7 +681,7 @@ } } } - + private static void getAutoFieldsEntityTag(Element element, String fileNameURI, Map<String, String> autoFieldsEntity) throws GeneralException { @@ -690,13 +690,13 @@ .getAttribute("entity-name")); String defaultFieldType = UtilFormatOut.checkNull(element .getAttribute("default-field-type")); - + if (UtilValidate.isNotEmpty(entityName) && UtilValidate.isNotEmpty(defaultFieldType) && (!("hidden".equals(defaultFieldType)))) { ModelEntity entity = LabelManagerFactory.getModelReader() .getModelEntity(entityName); - + for (Iterator<ModelField> f = entity.getFieldsIterator(); f .hasNext();) { ModelField field = f.next(); @@ -707,7 +707,7 @@ throw new GeneralException(e.getMessage()); } } - + private static void getAutoFieldsServiceTag(Element element, String fileNameURI, Map<String, String> autoFieldsService) throws GeneralException { @@ -716,7 +716,7 @@ .getAttribute("service-name")); String defaultFieldType = UtilFormatOut.checkNull(element .getAttribute("default-field-type")); - + if (UtilValidate.isNotEmpty(serviceName) && (!("hidden".equals(defaultFieldType)))) { ModelService modelService = LabelManagerFactory @@ -724,7 +724,7 @@ List<ModelParam> modelParams = modelService .getInModelParamList(); Iterator<ModelParam> modelParamIter = modelParams.iterator(); - + while (modelParamIter.hasNext()) { ModelParam modelParam = modelParamIter.next(); // skip auto params that the service engine populates... @@ -733,7 +733,7 @@ || "timeZone".equals(modelParam.name)) { continue; } - + if (modelParam.formDisplay) { if (UtilValidate.isNotEmpty(modelParam.entityName) && UtilValidate @@ -743,11 +743,11 @@ modelEntity = LabelManagerFactory .getModelReader().getModelEntity( modelParam.entityName); - + if (modelEntity != null) { ModelField modelField = modelEntity .getField(modelParam.fieldName); - + if (modelField != null) { autoFieldsService.put(modelField .getName(), "N"); @@ -764,11 +764,11 @@ throw new GeneralException(e.getMessage()); } } - + private static void getHyperlinkTag(Element element, String fileNameURI) { String hyperlinkDescription = UtilFormatOut.checkNull(element .getAttribute("description")); - + if (UtilValidate.isNotEmpty(hyperlinkDescription)) { // hyperlink description with hardcoded labels if (!getLabelFromTag(element, fileNameURI, hyperlinkDescription, @@ -777,7 +777,7 @@ } } } - + private static void getFieldTag(Element element, String fileNameURI, Map<String, String> autoFieldsEntity, Map<String, String> autoFieldsService) { @@ -788,19 +788,19 @@ .getAttribute("title")); String tooltip = UtilFormatOut.checkNull(element .getAttribute("tooltip")); - + if (UtilValidate.isNotEmpty(autoFieldsEntity) && UtilValidate.isNotEmpty(autoFieldsEntity.get(fieldName))) { autoFieldsEntity.put(fieldName, "Y"); } - + if (UtilValidate.isNotEmpty(autoFieldsService) && UtilValidate.isNotEmpty(autoFieldsService.get(fieldName))) { autoFieldsService.put(fieldName, "Y"); } - + boolean escludeField = false; - + for (Element fieldTypeElem : UtilXml.childElementList(element)) { if ("hidden".equals(fieldTypeElem.getTagName())) { escludeField = true; @@ -808,7 +808,7 @@ escludeField = true; } } - + if (!escludeField) { // field name labels if (UtilValidate.isEmpty(fieldTitle)) { @@ -820,7 +820,7 @@ setLabelReference(fieldTitle, fileNameURI); } } - + if (UtilValidate.isNotEmpty(tooltip)) { // tooltip with hardcoded labels if (!getLabelFromTag(element, fileNameURI, tooltip, uiLabelMap)) { @@ -829,13 +829,13 @@ } } } - + private static void getLabelTag(Element element, String fileNameURI) { String labelText = UtilFormatOut .checkNull(element.getAttribute("text")); String labelValue = UtilFormatOut.checkNull(UtilXml .elementValue(element)); - + // label text labels if (UtilValidate.isNotEmpty(labelText)) { // label text with hardcoded labels @@ -850,11 +850,11 @@ } } } - + private static void getMenuItemTag(Element element, String fileNameURI) { String menuItemTitle = UtilFormatOut.checkNull(element .getAttribute("title")); - + if (UtilValidate.isNotEmpty(menuItemTitle)) { // menu item title with hardcoded labels if (!getLabelFromTag(element, fileNameURI, menuItemTitle, @@ -863,21 +863,21 @@ } } } - + private static void getFailPropertyTag(Element element, String fileNameURI) { String propertyValue = UtilFormatOut.checkNull(element .getAttribute("property")); - + if (UtilValidate.isNotEmpty(propertyValue)) { // fail-property labels setLabelReference(propertyValue, fileNameURI); } } - + private static void getOptionTag(Element element, String fileNameURI) { String description = UtilFormatOut.checkNull(element .getAttribute("description")); - + if (UtilValidate.isNotEmpty(description)) { // option description with hardcoded labels if (!getLabelFromTag(element, fileNameURI, description, uiLabelMap)) { @@ -885,10 +885,10 @@ } } } - + private static void getLinkTag(Element element, String fileNameURI) { String linkText = UtilFormatOut.checkNull(element.getAttribute("text")); - + if (UtilValidate.isNotEmpty(linkText)) { // link text with hardcoded labels if (!getLabelFromTag(element, fileNameURI, linkText, uiLabelMap)) { @@ -896,12 +896,12 @@ } } } - + private static void getWebappTag(Element element, String fileNameURI) { String title = UtilFormatOut.checkNull(element.getAttribute("title")); String appBarDisplay = UtilFormatOut.checkNull(element .getAttribute("app-bar-display")); - + // title labels if (UtilValidate.isNotEmpty(title) && UtilValidate.isNotEmpty(appBarDisplay) @@ -909,7 +909,7 @@ setLabelReference(title, fileNameURI); } } - + private static void getEntityOptionsTag(Element element, String fileNameURI) { String entityName = UtilFormatOut.checkNull(element .getAttribute("entity-name")); @@ -917,24 +917,24 @@ .getAttribute("description")); Set<String> fields = new TreeSet<String>(); Set<String> pkFields = new TreeSet<String>(); - + try { - + if (UtilValidate.isNotEmpty(entityName)) { GenericDelegator delegator = LabelManagerFactory.getDelegator(); ModelEntity entity = delegator.getModelEntity(entityName); - + if (UtilValidate.isNotEmpty(entity) && UtilValidate.isNotEmpty(entity .getDefaultResourceName())) { int pos = 0; while (pos >= 0) { pos = description.indexOf(startExpression, pos); - + if (pos >= 0) { int endLabel = description.indexOf(endExpression, pos); - + if (endLabel >= 0) { String fieldName = description.substring(pos + startExpression.length(), endLabel); @@ -955,7 +955,7 @@ } } } - + // Search primary keys of entity Iterator<ModelField> iter = entity.getPksIterator(); while (iter != null && iter.hasNext()) { @@ -979,7 +979,7 @@ String constraintValue = UtilFormatOut .checkNull(entityConstraintElem .getAttribute("value")); - + EntityComparisonOperator operator = new EntityComparisonOperator( EntityOperator.ID_EQUALS, "="); if ("between".equals(constraintValue)) { @@ -1012,26 +1012,26 @@ operator = new EntityComparisonOperator( EntityOperator.ID_NOT_EQUAL, "<>"); } - + exprs.add(EntityCondition.makeCondition( constraintName, operator, constraintValue)); } } - + EntityConditionList<EntityExpr> ecl = null; if (exprs.size() > 0) { ecl = EntityCondition.makeCondition(exprs, EntityOperator.AND); } - + StringBuilder keyBuffer = new StringBuilder(); keyBuffer.append(entityName); keyBuffer.append('.'); keyBuffer.append(fieldName); List<GenericValue> entityRecords = delegator.findList( entityName, ecl, pkFields, null, null, false); - + for (GenericValue entityRecord : entityRecords) { boolean pkFound = false; StringBuilder pkBuffer = new StringBuilder( @@ -1040,7 +1040,7 @@ while (itPkFields != null && itPkFields.hasNext()) { String pkField = itPkFields.next(); Object pkFieldValue = entityRecord.get(pkField); - + if (UtilValidate.isNotEmpty(pkFieldValue)) { pkBuffer.append('.'); pkBuffer.append(pkFieldValue); @@ -1060,7 +1060,7 @@ module); } } - + private static void getDisplayEntityTag(Element element, String fileNameURI) { String entityName = UtilFormatOut.checkNull(element .getAttribute("entity-name")); @@ -1068,24 +1068,24 @@ .getAttribute("description")); Set<String> fields = new TreeSet<String>(); Set<String> pkFields = new TreeSet<String>(); - + try { - + if (UtilValidate.isNotEmpty(entityName)) { GenericDelegator delegator = LabelManagerFactory.getDelegator(); ModelEntity entity = delegator.getModelEntity(entityName); - + if (UtilValidate.isNotEmpty(entity) && UtilValidate.isNotEmpty(entity .getDefaultResourceName())) { int pos = 0; while (pos >= 0) { pos = description.indexOf(startExpression, pos); - + if (pos >= 0) { int endLabel = description.indexOf(endExpression, pos); - + if (endLabel >= 0) { String fieldName = description.substring(pos + startExpression.length(), endLabel); @@ -1106,7 +1106,7 @@ } } } - + // Search primary keys of entity Iterator<ModelField> iter = entity.getPksIterator(); while (iter != null && iter.hasNext()) { @@ -1122,7 +1122,7 @@ keyBuffer.append(fieldName); List<GenericValue> entityRecords = delegator.findList( entityName, null, pkFields, null, null, false); - + for (GenericValue entityRecord : entityRecords) { boolean pkFound = false; StringBuilder pkBuffer = new StringBuilder( @@ -1131,7 +1131,7 @@ while (itPkFields != null && itPkFields.hasNext()) { String pkField = itPkFields.next(); Object pkFieldValue = entityRecord.get(pkField); - + if (UtilValidate.isNotEmpty(pkFieldValue)) { pkBuffer.append('.'); pkBuffer.append(pkFieldValue); Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelValue.java?rev=757081&r1=757080&r2=757081&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelValue.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelValue.java Sat Mar 21 23:25:25 2009 @@ -6,9 +6,9 @@ * 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 Modified: 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=757081&r1=757080&r2=757081&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java Sat Mar 21 23:25:25 2009 @@ -67,7 +67,7 @@ Document resourceDocument = UtilXml.makeEmptyXmlDocument("resource"); Element resourceElem = resourceDocument.getDocumentElement(); resourceElem.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - + for (String labelKey : labelsList) { LabelInfo labelInfo = (LabelInfo)labels.get(labelKey); @@ -77,7 +77,7 @@ Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument); propertyElem.setAttribute("key", StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKey(), true, true, false)); - + if (UtilValidate.isNotEmpty(labelInfo.getLabelKeyComment())) { Comment labelKeyComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKeyComment(), true, true, false)); Node parent = propertyElem.getParentNode(); @@ -90,7 +90,7 @@ if (UtilValidate.isNotEmpty(labelValue)) { Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", StringUtil.fromHtmlToSpecialChars(labelValue.getLabelValue(), true, true, false), resourceDocument); valueElem.setAttribute("xml:lang", localeFound); - + if (UtilValidate.isNotEmpty(labelValue.getLabelComment())) { Comment labelComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelValue.getLabelComment(), true, true, false)); Node parent = valueElem.getParentNode(); @@ -104,7 +104,7 @@ File outFile = new File(new URI(uri)); FileOutputStream fos = new FileOutputStream(outFile); OutputFormat format = new OutputFormat(resourceDocument.getDocumentElement().getOwnerDocument(), "UTF-8", true); - + try { format.setIndent(4); format.setOmitXMLDeclaration(true); @@ -112,23 +112,23 @@ } finally { if (UtilValidate.isNotEmpty(fos)) { fos.close(); - + // workaround to insert the Apache License Header at top of the file // because the comment on top the xml file has been not written String outBuffer = FileUtil.readString("UTF-8", outFile); String basePath = System.getProperty("ofbiz.home"); - + if (UtilValidate.isNotEmpty(basePath)) { String apacheHeaderFileName = basePath + "/framework/webtools/config/APACHE2_HEADER_FOR_XML"; String apacheHeaderBuffer = ""; File apacheHeaderFile = new File(apacheHeaderFileName); - + if (UtilValidate.isNotEmpty(apacheHeaderFile)) { apacheHeaderBuffer = FileUtil.readString("UTF-8", apacheHeaderFile); } - + FileUtil.writeString("UTF-8", apacheHeaderBuffer + outBuffer, outFile); - + // clear cache to see immediately the new labels and translations in OFBiz UtilCache.clearCache("properties.UtilPropertiesBundleCache"); } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java?rev=757081&r1=757080&r2=757081&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java Sat Mar 21 23:25:25 2009 @@ -6,9 +6,9 @@ * 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 |
Free forum by Nabble | Edit this page |