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=754649&r1=754648&r2=754649&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 Sun Mar 15 10:36:41 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,56 @@ 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 { + + 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; + + return references; } - + private static void getLabelsFromFtlFiles() throws GeneralException { try { - List<File> ftlFiles = FileUtil.findFiles("ftl", null, null, uiLabelMap); - - for (File ftlFile: ftlFiles) { + 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); + String labelKey = inFile.substring(pos + + uiLabelMap.length(), endLabel); setLabelReference(labelKey, fileNameURI); pos = endLabel; } else { @@ -118,64 +121,68 @@ } } /* - ftlFiles = FileUtil.findFiles("ftl", null, null, getEntityLabel); - - for (File ftlFile: ftlFiles) { - getFtlEntityLabels(ftlFile, getEntityLabel); - } - */ + * ftlFiles = FileUtil.findFiles("ftl", null, null, getEntityLabel); + * + * for (File ftlFile: ftlFiles) { getFtlEntityLabels(ftlFile, + * getEntityLabel); } + */ } catch (IOException ioe) { 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) { + List<File> javaFiles = FileUtil.findFiles("java", null, null, + getMessage); + + for (File javaFile : javaFiles) { getJavaLabels(javaFile, getMessage); } } catch (IOException ioe) { throw new GeneralException(ioe.getMessage()); } } - - private static void getJavaLabels(File javaFile, String message) throws GeneralException { + + private static void getJavaLabels(File javaFile, String message) + throws GeneralException { try { String fileNameURI = javaFile.toURI().toString(); String inFile = FileUtil.readString("UTF-8", javaFile); int pos = 0; while (pos >= 0) { pos = inFile.indexOf(message, pos); - + if (pos >= 0) { - int offSet = (pos + 200 > inFile.length()) ? inFile.length() : pos + 200; + 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; + 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); + setLabelReference(inFile.substring(pos, endString), + fileNameURI); pos = endString; } } @@ -186,30 +193,37 @@ throw new GeneralException(ioe.getMessage()); } } - - private static void getFtlEntityLabels(File javaFile, String message) throws GeneralException { + + private static void getFtlEntityLabels(File javaFile, String message) + throws GeneralException { try { String fileNameURI = javaFile.toURI().toString(); String inFile = FileUtil.readString("UTF-8", javaFile); 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 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; - String searchLocale = searchDoubleQuote.substring(firstComma, offSet); - int endMethodName = searchLocale.indexOf(", locale)", 0); - + offSet = (firstComma + 100 > inFile.length()) ? inFile + .length() : firstComma + 100; + String searchLocale = searchDoubleQuote.substring( + firstComma, offSet); + int endMethodName = searchLocale + .indexOf(", locale)", 0); + if (endMethodName < 0) { endMethodName = searchLocale.indexOf(",locale)", 0); } if (endMethodName >= 0) { - setLabelReference(inFile.substring(pos + 6, pos + 6 + firstComma), fileNameURI); + setLabelReference(inFile.substring(pos + 6, pos + 6 + + firstComma), fileNameURI); pos = pos + 6; } } @@ -220,27 +234,34 @@ throw new GeneralException(ioe.getMessage()); } } - - private static void getLabelsFromSimpleMethodFiles() throws GeneralException { + + 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) { + 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()); + Document simpleMethodDocument = UtilXml + .readXmlDocument(simpleMethodFile.toURI().toURL()); Element rootElem = simpleMethodDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { + + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkSimpleMethodTag(elem1, fileNameURI); - for (Element elem2: UtilXml.childElementList(elem1)) { + for (Element elem2 : UtilXml.childElementList(elem1)) { checkSimpleMethodTag(elem2, fileNameURI); - for (Element elem3: UtilXml.childElementList(elem2)) { + for (Element elem3 : UtilXml.childElementList(elem2)) { checkSimpleMethodTag(elem3, fileNameURI); - for (Element elem4: UtilXml.childElementList(elem3)) { + for (Element elem4 : UtilXml + .childElementList(elem3)) { checkSimpleMethodTag(elem4, fileNameURI); - for (Element elem5: UtilXml.childElementList(elem4)) { + for (Element elem5 : UtilXml + .childElementList(elem4)) { checkSimpleMethodTag(elem5, fileNameURI); - for (Element elem6: UtilXml.childElementList(elem5)) { + for (Element elem6 : UtilXml + .childElementList(elem5)) { checkSimpleMethodTag(elem6, fileNameURI); } } @@ -255,52 +276,65 @@ throw new GeneralException(e.getMessage()); } } - - private static void checkSimpleMethodTag(Element elem, String fileNameURI) throws GeneralException { + + private static void checkSimpleMethodTag(Element elem, String fileNameURI) + throws GeneralException { // fail-property labels if ("fail-property".equals(elem.getTagName())) { 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) { - Map<String, String> autoFieldsEntity = FastMap.newInstance(); - Map<String, String> autoFieldsService = FastMap.newInstance(); + 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()); + Document formDocument = UtilXml.readXmlDocument(formsFile + .toURI().toURL()); Element rootElem = formDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { - checkFormsTag(elem1, fileNameURI, autoFieldsEntity, autoFieldsService); - for (Element elem2: UtilXml.childElementList(elem1)) { - checkFormsTag(elem2, fileNameURI, autoFieldsEntity, autoFieldsService); - for (Element elem3: UtilXml.childElementList(elem2)) { - checkFormsTag(elem3, fileNameURI, autoFieldsEntity, autoFieldsService); - for (Element elem4: UtilXml.childElementList(elem3)) { - checkFormsTag(elem4, fileNameURI, autoFieldsEntity, autoFieldsService); - for (Element elem5: UtilXml.childElementList(elem4)) { - checkFormsTag(elem5, fileNameURI, autoFieldsEntity, autoFieldsService); + + for (Element elem1 : UtilXml.childElementList(rootElem)) { + Map<String, String> autoFieldsEntity = FastMap + .newInstance(); + Map<String, String> autoFieldsService = FastMap + .newInstance(); + checkFormsTag(elem1, fileNameURI, autoFieldsEntity, + autoFieldsService); + for (Element elem2 : UtilXml.childElementList(elem1)) { + checkFormsTag(elem2, fileNameURI, autoFieldsEntity, + autoFieldsService); + for (Element elem3 : UtilXml.childElementList(elem2)) { + checkFormsTag(elem3, fileNameURI, autoFieldsEntity, + autoFieldsService); + for (Element elem4 : UtilXml + .childElementList(elem3)) { + checkFormsTag(elem4, fileNameURI, + autoFieldsEntity, autoFieldsService); + for (Element elem5 : UtilXml + .childElementList(elem4)) { + checkFormsTag(elem5, fileNameURI, + autoFieldsEntity, autoFieldsService); } } } } - } - - for (Map.Entry<String, String> entry: autoFieldsEntity.entrySet()) { - if ("N".equals(entry.getValue())) { - String labelKey = formFieldTitle + entry.getKey(); - setLabelReference(labelKey, fileNameURI); + for (Map.Entry<String, String> entry : autoFieldsEntity + .entrySet()) { + if ("N".equals(entry.getValue())) { + String labelKey = formFieldTitle + entry.getKey(); + setLabelReference(labelKey, fileNameURI); + } } - } - - for (Map.Entry<String, String> entry: autoFieldsService.entrySet()) { - if ("N".equals(entry.getValue())) { - String labelKey = formFieldTitle + entry.getKey(); - setLabelReference(labelKey, fileNameURI); + + for (Map.Entry<String, String> entry : autoFieldsService + .entrySet()) { + if ("N".equals(entry.getValue())) { + String labelKey = formFieldTitle + entry.getKey(); + setLabelReference(labelKey, fileNameURI); + } } } } @@ -310,70 +344,97 @@ throw new GeneralException(e.getMessage()); } } - - private static void checkFormsTag(Element elem, String fileNameURI, Map<String, String> autoFieldsEntity, Map<String, String> autoFieldsService) throws GeneralException { + + private static void checkFormsTag(Element elem, String fileNameURI, + Map<String, String> autoFieldsEntity, + Map<String, String> autoFieldsService) throws GeneralException { // auto fields entity labels if ("auto-fields-entity".equals(elem.getTagName())) { getAutoFieldsEntityTag(elem, fileNameURI, autoFieldsEntity); - // auto fields service labels + // auto fields service labels } else if ("auto-fields-service".equals(elem.getTagName())) { getAutoFieldsServiceTag(elem, fileNameURI, autoFieldsService); - // field labels + // field labels } else if ("field".equals(elem.getTagName())) { getFieldTag(elem, fileNameURI, autoFieldsEntity, autoFieldsService); - // option description labels + // option description labels } else if ("option".equals(elem.getTagName())) { getOptionTag(elem, fileNameURI); - // hyperlink/sub-hyperlink description labels - } else if ("hyperlink".equals(elem.getTagName()) || - "sub-hyperlink".equals(elem.getTagName())) { + // hyperlink/sub-hyperlink description labels + } else if ("hyperlink".equals(elem.getTagName()) + || "sub-hyperlink".equals(elem.getTagName())) { getHyperlinkTag(elem, fileNameURI); - // entity-options labels + // entity-options labels } else if ("entity-options".equals(elem.getTagName())) { getEntityOptionsTag(elem, fileNameURI); - // display-entity labels + // display-entity labels } else if ("display-entity".equals(elem.getTagName())) { 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) { + 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()); + Document screenDocument = UtilXml.readXmlDocument(screensFile + .toURI().toURL()); Element rootElem = screenDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { + + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkScreensTag(elem1, fileNameURI); - for (Element elem2: UtilXml.childElementList(elem1)) { + for (Element elem2 : UtilXml.childElementList(elem1)) { checkScreensTag(elem2, fileNameURI); - for (Element elem3: UtilXml.childElementList(elem2)) { + for (Element elem3 : UtilXml.childElementList(elem2)) { checkScreensTag(elem3, fileNameURI); - for (Element elem4: UtilXml.childElementList(elem3)) { + for (Element elem4 : UtilXml + .childElementList(elem3)) { checkScreensTag(elem4, fileNameURI); - for (Element elem5: UtilXml.childElementList(elem4)) { + for (Element elem5 : UtilXml + .childElementList(elem4)) { checkScreensTag(elem5, fileNameURI); - for (Element elem6: UtilXml.childElementList(elem5)) { + for (Element elem6 : UtilXml + .childElementList(elem5)) { checkScreensTag(elem6, fileNameURI); - for (Element elem7: UtilXml.childElementList(elem6)) { + for (Element elem7 : UtilXml + .childElementList(elem6)) { checkScreensTag(elem7, fileNameURI); - for (Element elem8: UtilXml.childElementList(elem7)) { - checkScreensTag(elem8, fileNameURI); - for (Element elem9: UtilXml.childElementList(elem8)) { - checkScreensTag(elem9, fileNameURI); - for (Element elem10: UtilXml.childElementList(elem9)) { - checkScreensTag(elem10, fileNameURI); - for (Element elem11: UtilXml.childElementList(elem10)) { - checkScreensTag(elem11, fileNameURI); - for (Element elem12: UtilXml.childElementList(elem11)) { - checkScreensTag(elem12, fileNameURI); - for (Element elem13: UtilXml.childElementList(elem12)) { - checkScreensTag(elem13, fileNameURI); - for (Element elem14: UtilXml.childElementList(elem13)) { - checkScreensTag(elem14, fileNameURI); + for (Element elem8 : UtilXml + .childElementList(elem7)) { + checkScreensTag(elem8, + fileNameURI); + for (Element elem9 : UtilXml + .childElementList(elem8)) { + checkScreensTag(elem9, + fileNameURI); + for (Element elem10 : UtilXml + .childElementList(elem9)) { + checkScreensTag(elem10, + fileNameURI); + for (Element elem11 : UtilXml + .childElementList(elem10)) { + checkScreensTag( + elem11, + fileNameURI); + for (Element elem12 : UtilXml + .childElementList(elem11)) { + checkScreensTag( + elem12, + fileNameURI); + for (Element elem13 : UtilXml + .childElementList(elem12)) { + checkScreensTag( + elem13, + fileNameURI); + for (Element elem14 : UtilXml + .childElementList(elem13)) { + checkScreensTag( + elem14, + fileNameURI); } } } @@ -395,41 +456,45 @@ throw new GeneralException(e.getMessage()); } } - + private static void checkScreensTag(Element elem, String fileNameURI) { // set labels if ("set".equals(elem.getTagName())) { getSetTag(elem, fileNameURI); - // screenlet labels + // screenlet labels } else if ("screenlet".equals(elem.getTagName())) { getScreenletTag(elem, fileNameURI); - // label labels + // label labels } else if ("label".equals(elem.getTagName())) { getLabelTag(elem, fileNameURI); - // link labels + // link labels } else if ("link".equals(elem.getTagName())) { 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) { + 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()); + Document menuDocument = UtilXml.readXmlDocument(menuFiles + .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { + + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkMenuTag(elem1, fileNameURI); - for (Element elem2: UtilXml.childElementList(elem1)) { + for (Element elem2 : UtilXml.childElementList(elem1)) { checkMenuTag(elem2, fileNameURI); - for (Element elem3: UtilXml.childElementList(elem2)) { + for (Element elem3 : UtilXml.childElementList(elem2)) { checkMenuTag(elem3, fileNameURI); - for (Element elem4: UtilXml.childElementList(elem3)) { + for (Element elem4 : UtilXml + .childElementList(elem3)) { checkMenuTag(elem4, fileNameURI); - for (Element elem5: UtilXml.childElementList(elem4)) { + for (Element elem5 : UtilXml + .childElementList(elem4)) { checkMenuTag(elem5, fileNameURI); } } @@ -443,32 +508,36 @@ 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) { + 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()); + Document menuDocument = UtilXml.readXmlDocument(treeFile + .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { + + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkTreeTag(elem1, fileNameURI); - for (Element elem2: UtilXml.childElementList(elem1)) { + for (Element elem2 : UtilXml.childElementList(elem1)) { checkTreeTag(elem2, fileNameURI); - for (Element elem3: UtilXml.childElementList(elem2)) { + for (Element elem3 : UtilXml.childElementList(elem2)) { checkTreeTag(elem3, fileNameURI); - for (Element elem4: UtilXml.childElementList(elem3)) { + for (Element elem4 : UtilXml + .childElementList(elem3)) { checkTreeTag(elem4, fileNameURI); - for (Element elem5: UtilXml.childElementList(elem4)) { + for (Element elem5 : UtilXml + .childElementList(elem4)) { checkTreeTag(elem5, fileNameURI); } } @@ -482,26 +551,29 @@ 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) { + 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()); + Document menuDocument = UtilXml.readXmlDocument(componentFile + .toURI().toURL()); Element rootElem = menuDocument.getDocumentElement(); - - for (Element elem1: UtilXml.childElementList(rootElem)) { + + for (Element elem1 : UtilXml.childElementList(rootElem)) { checkOfbizComponentTag(elem1, fileNameURI); - for (Element elem2: UtilXml.childElementList(elem1)) { + for (Element elem2 : UtilXml.childElementList(elem1)) { checkOfbizComponentTag(elem2, fileNameURI); } } @@ -512,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)) { @@ -528,31 +600,32 @@ references.put(labelKey, reference); } else { Integer labelsInFile = reference.get(fileNameURI); - + if (UtilValidate.isEmpty(labelsInFile)) { labelsInFile = new Integer(1); - } - else { + } else { labelsInFile = new Integer(labelsInFile.intValue() + 1); } reference.put(fileNameURI, labelsInFile); } } - - private static boolean getLabelFromTag(Element element, String fileNameURI, String attributeValue, String stringToSearch) { + + 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); + String labelKey = attributeValue.substring(pos + + stringToSearch.length(), graph); setLabelReference(labelKey, fileNameURI); stringFound = true; pos = graph; @@ -563,38 +636,44 @@ } return stringFound; } - + private static void getSetTag(Element element, String fileNameURI) { - String setField = UtilFormatOut.checkNull(element.getAttribute("field")); - String setValue = UtilFormatOut.checkNull(element.getAttribute("value")); - String fromField = UtilFormatOut.checkNull(element.getAttribute("from-field")); - + String setField = UtilFormatOut + .checkNull(element.getAttribute("field")); + String setValue = UtilFormatOut + .checkNull(element.getAttribute("value")); + String fromField = UtilFormatOut.checkNull(element + .getAttribute("from-field")); + if (UtilValidate.isNotEmpty(setField)) { - if (UtilValidate.isNotEmpty(setValue) && - ("applicationTitle".equals(setField) || - "titleProperty".equals(setField) || - "title".equals(setField))) { + if (UtilValidate.isNotEmpty(setValue) + && ("applicationTitle".equals(setField) + || "titleProperty".equals(setField) || "title" + .equals(setField))) { // set field with hardcoded labels if (!getLabelFromTag(element, fileNameURI, setValue, uiLabelMap)) { setLabelReference(setValue, fileNameURI); } - } else if (UtilValidate.isNotEmpty(fromField) && - ("layoutSettings.companyName".equals(setField) || - "layoutSettings.companySubtitle".equals(setField))) { + } else if (UtilValidate.isNotEmpty(fromField) + && ("layoutSettings.companyName".equals(setField) || "layoutSettings.companySubtitle" + .equals(setField))) { // set field labels if (fromField.startsWith(uiLabelMapInLayoutSettings)) { - setLabelReference(fromField.substring(uiLabelMapInLayoutSettings.length(), fromField.length()), fileNameURI); - // set field with hardcoded labels + setLabelReference(fromField.substring( + uiLabelMapInLayoutSettings.length(), fromField + .length()), fileNameURI); + // set field with hardcoded labels } else { setLabelReference(fromField, fileNameURI); } } } } - + private static void getScreenletTag(Element element, String fileNameURI) { - String screenTitle = UtilFormatOut.checkNull(element.getAttribute("title")); - + String screenTitle = UtilFormatOut.checkNull(element + .getAttribute("title")); + if (UtilValidate.isNotEmpty(screenTitle)) { // screenlet title with hardcoded labels if (!getLabelFromTag(element, fileNameURI, screenTitle, uiLabelMap)) { @@ -602,16 +681,24 @@ } } } - - private static void getAutoFieldsEntityTag(Element element, String fileNameURI, Map<String, String> autoFieldsEntity) throws GeneralException { + + private static void getAutoFieldsEntityTag(Element element, + String fileNameURI, Map<String, String> autoFieldsEntity) + throws GeneralException { try { - String entityName = UtilFormatOut.checkNull(element.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();) { + String entityName = UtilFormatOut.checkNull(element + .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(); autoFieldsEntity.put(field.getName(), "N"); } @@ -620,43 +707,56 @@ throw new GeneralException(e.getMessage()); } } - - private static void getAutoFieldsServiceTag(Element element, String fileNameURI, Map<String, String> autoFieldsService) throws GeneralException { + + private static void getAutoFieldsServiceTag(Element element, + String fileNameURI, Map<String, String> autoFieldsService) + throws GeneralException { try { - String serviceName = UtilFormatOut.checkNull(element.getAttribute("service-name")); - String defaultFieldType = UtilFormatOut.checkNull(element.getAttribute("default-field-type")); - - if (UtilValidate.isNotEmpty(serviceName) && (!("hidden".equals(defaultFieldType)))) { - ModelService modelService = LabelManagerFactory.getDispatchContext().getModelService(serviceName); - List<ModelParam> modelParams = modelService.getInModelParamList(); + String serviceName = UtilFormatOut.checkNull(element + .getAttribute("service-name")); + String defaultFieldType = UtilFormatOut.checkNull(element + .getAttribute("default-field-type")); + + if (UtilValidate.isNotEmpty(serviceName) + && (!("hidden".equals(defaultFieldType)))) { + ModelService modelService = LabelManagerFactory + .getDispatchContext().getModelService(serviceName); + List<ModelParam> modelParams = modelService + .getInModelParamList(); Iterator<ModelParam> modelParamIter = modelParams.iterator(); - + while (modelParamIter.hasNext()) { - ModelParam modelParam = (ModelParam) modelParamIter.next(); + ModelParam modelParam = modelParamIter.next(); // skip auto params that the service engine populates... - if ("userLogin".equals(modelParam.name) || "locale".equals(modelParam.name) || "timeZone".equals(modelParam.name)) { + if ("userLogin".equals(modelParam.name) + || "locale".equals(modelParam.name) + || "timeZone".equals(modelParam.name)) { continue; } - + if (modelParam.formDisplay) { - if (UtilValidate.isNotEmpty(modelParam.entityName) && UtilValidate.isNotEmpty(modelParam.fieldName)) { + if (UtilValidate.isNotEmpty(modelParam.entityName) + && UtilValidate + .isNotEmpty(modelParam.fieldName)) { ModelEntity modelEntity; try { - modelEntity = LabelManagerFactory.getModelReader().getModelEntity(modelParam.entityName); - + modelEntity = LabelManagerFactory + .getModelReader().getModelEntity( + modelParam.entityName); + if (modelEntity != null) { - ModelField modelField = modelEntity.getField(modelParam.fieldName); - + ModelField modelField = modelEntity + .getField(modelParam.fieldName); + if (modelField != null) { - autoFieldsService.put(modelField.getName(), "N"); + autoFieldsService.put(modelField + .getName(), "N"); } } } catch (GenericEntityException e) { Debug.logError(e, module); } } - - setLabelReference(formFieldTitle + modelParam.name, fileNameURI); } } } @@ -664,53 +764,63 @@ throw new GeneralException(e.getMessage()); } } - + private static void getHyperlinkTag(Element element, String fileNameURI) { - String hyperlinkDescription = UtilFormatOut.checkNull(element.getAttribute("description")); - + String hyperlinkDescription = UtilFormatOut.checkNull(element + .getAttribute("description")); + if (UtilValidate.isNotEmpty(hyperlinkDescription)) { // hyperlink description with hardcoded labels - if (!getLabelFromTag(element, fileNameURI, hyperlinkDescription, uiLabelMap)) { + if (!getLabelFromTag(element, fileNameURI, hyperlinkDescription, + uiLabelMap)) { setLabelReference(hyperlinkDescription, fileNameURI); } } } - - private static void getFieldTag(Element element, String fileNameURI, Map<String, String> autoFieldsEntity, Map<String, String> autoFieldsService) { - String fieldName = UtilFormatOut.checkNull(element.getAttribute("name")); + + private static void getFieldTag(Element element, String fileNameURI, + Map<String, String> autoFieldsEntity, + Map<String, String> autoFieldsService) { + String fieldName = UtilFormatOut + .checkNull(element.getAttribute("name")); String labelKey = formFieldTitle + fieldName; - String fieldTitle = UtilFormatOut.checkNull(element.getAttribute("title")); - String tooltip = UtilFormatOut.checkNull(element.getAttribute("tooltip")); - - if (UtilValidate.isNotEmpty(autoFieldsEntity) && UtilValidate.isNotEmpty(autoFieldsEntity.get(fieldName))) { + String fieldTitle = UtilFormatOut.checkNull(element + .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))) { + + if (UtilValidate.isNotEmpty(autoFieldsService) + && UtilValidate.isNotEmpty(autoFieldsService.get(fieldName))) { autoFieldsService.put(fieldName, "Y"); } - + boolean escludeField = false; - - for (Element fieldTypeElem: UtilXml.childElementList(element)) { + + for (Element fieldTypeElem : UtilXml.childElementList(element)) { if ("hidden".equals(fieldTypeElem.getTagName())) { escludeField = true; - } else if ("ignore".equals(fieldTypeElem.getTagName())) { + } else if ("ignored".equals(fieldTypeElem.getTagName())) { escludeField = true; } } - + if (!escludeField) { // field name labels if (UtilValidate.isEmpty(fieldTitle)) { setLabelReference(labelKey, fileNameURI); } else { // field title with hardcoded labels - if (!getLabelFromTag(element, fileNameURI, fieldTitle, uiLabelMap)) { + if (!getLabelFromTag(element, fileNameURI, fieldTitle, + uiLabelMap)) { setLabelReference(fieldTitle, fileNameURI); } } - + if (UtilValidate.isNotEmpty(tooltip)) { // tooltip with hardcoded labels if (!getLabelFromTag(element, fileNameURI, tooltip, uiLabelMap)) { @@ -719,18 +829,20 @@ } } } - + private static void getLabelTag(Element element, String fileNameURI) { - String labelText = UtilFormatOut.checkNull(element.getAttribute("text")); - String labelValue = UtilFormatOut.checkNull(UtilXml.elementValue(element)); - + 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 if (!getLabelFromTag(element, fileNameURI, labelText, uiLabelMap)) { setLabelReference(labelText, fileNameURI); } - // label value labels + // label value labels } else if (UtilValidate.isNotEmpty(labelValue)) { // label value with hardcoded labels if (!getLabelFromTag(element, fileNameURI, labelValue, uiLabelMap)) { @@ -738,30 +850,34 @@ } } } - + private static void getMenuItemTag(Element element, String fileNameURI) { - String menuItemTitle = UtilFormatOut.checkNull(element.getAttribute("title")); - + String menuItemTitle = UtilFormatOut.checkNull(element + .getAttribute("title")); + if (UtilValidate.isNotEmpty(menuItemTitle)) { // menu item title with hardcoded labels - if (!getLabelFromTag(element, fileNameURI, menuItemTitle, uiLabelMap)) { + if (!getLabelFromTag(element, fileNameURI, menuItemTitle, + uiLabelMap)) { setLabelReference(menuItemTitle, fileNameURI); } } } - + private static void getFailPropertyTag(Element element, String fileNameURI) { - String propertyValue = UtilFormatOut.checkNull(element.getAttribute("property")); - + 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")); - + String description = UtilFormatOut.checkNull(element + .getAttribute("description")); + if (UtilValidate.isNotEmpty(description)) { // option description with hardcoded labels if (!getLabelFromTag(element, fileNameURI, description, uiLabelMap)) { @@ -769,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)) { @@ -780,42 +896,54 @@ } } } - + private static void getWebappTag(Element element, String fileNameURI) { String title = UtilFormatOut.checkNull(element.getAttribute("title")); - String appBarDisplay = UtilFormatOut.checkNull(element.getAttribute("app-bar-display")); + String appBarDisplay = UtilFormatOut.checkNull(element + .getAttribute("app-bar-display")); // title labels - if (UtilValidate.isNotEmpty(title) && UtilValidate.isNotEmpty(appBarDisplay) && "true".equalsIgnoreCase(appBarDisplay)) { + if (UtilValidate.isNotEmpty(title) + && UtilValidate.isNotEmpty(appBarDisplay) + && "true".equalsIgnoreCase(appBarDisplay)) { setLabelReference(title, fileNameURI); } } - + private static void getEntityOptionsTag(Element element, String fileNameURI) { - String entityName = UtilFormatOut.checkNull(element.getAttribute("entity-name")); - String description = UtilFormatOut.checkNull(element.getAttribute("description")); + String entityName = UtilFormatOut.checkNull(element + .getAttribute("entity-name")); + String description = UtilFormatOut.checkNull(element + .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())) { + + 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); - + int endLabel = description.indexOf(endExpression, + pos); + if (endLabel >= 0) { - String fieldName = description.substring(pos + startExpression.length(), endLabel); - if (!fieldName.startsWith(uiLabelMapInLayoutSettings)) { - for (Map.Entry<String, LabelInfo> e: LabelManagerFactory.getLabels().entrySet()) { - String keyToSearch = entityName + "." + fieldName; + String fieldName = description.substring(pos + + startExpression.length(), endLabel); + if (!fieldName + .startsWith(uiLabelMapInLayoutSettings)) { + for (Map.Entry<String, LabelInfo> e : LabelManagerFactory + .getLabels().entrySet()) { + String keyToSearch = entityName + "." + + fieldName; if (e.getKey().startsWith(keyToSearch)) { fields.add(fieldName); } @@ -827,7 +955,7 @@ } } } - + // Search primary keys of entity Iterator<ModelField> iter = entity.getPksIterator(); while (iter != null && iter.hasNext()) { @@ -838,54 +966,81 @@ while (fieldsIt != null && fieldsIt.hasNext()) { String fieldName = fieldsIt.next(); List<EntityExpr> exprs = FastList.newInstance(); - for (Element entityConstraintElem: UtilXml.childElementList(element)) { - if ("entity-constraint".equals(entityConstraintElem.getTagName())) { - String constraintName = UtilFormatOut.checkNull(entityConstraintElem.getAttribute("name")); - String constraintOperator = UtilFormatOut.checkNull(entityConstraintElem.getAttribute("operator")); - String constraintValue = UtilFormatOut.checkNull(entityConstraintElem.getAttribute("value")); - - EntityComparisonOperator operator = new EntityComparisonOperator(EntityOperator.ID_EQUALS, "="); + for (Element entityConstraintElem : UtilXml + .childElementList(element)) { + if ("entity-constraint".equals(entityConstraintElem + .getTagName())) { + String constraintName = UtilFormatOut + .checkNull(entityConstraintElem + .getAttribute("name")); + String constraintOperator = UtilFormatOut + .checkNull(entityConstraintElem + .getAttribute("operator")); + String constraintValue = UtilFormatOut + .checkNull(entityConstraintElem + .getAttribute("value")); + + EntityComparisonOperator operator = new EntityComparisonOperator( + EntityOperator.ID_EQUALS, "="); if ("between".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_BETWEEN, "BETWEEN"); - } else if ("greater-equals".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_GREATER_THAN_EQUAL_TO, ">="); + operator = new EntityComparisonOperator( + EntityOperator.ID_BETWEEN, + "BETWEEN"); + } else if ("greater-equals" + .equals(constraintValue)) { + operator = new EntityComparisonOperator( + EntityOperator.ID_GREATER_THAN_EQUAL_TO, + ">="); } else if ("greater".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_GREATER_THAN, ">"); + operator = new EntityComparisonOperator( + EntityOperator.ID_GREATER_THAN, ">"); } else if ("in".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_IN, "IN"); - } else if ("less-equals".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_LESS_THAN_EQUAL_TO, "<="); + operator = new EntityComparisonOperator( + EntityOperator.ID_IN, "IN"); + } else if ("less-equals" + .equals(constraintValue)) { + operator = new EntityComparisonOperator( + EntityOperator.ID_LESS_THAN_EQUAL_TO, + "<="); } else if ("less".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_LESS_THAN, "<"); + operator = new EntityComparisonOperator( + EntityOperator.ID_LESS_THAN, "<"); } else if ("like".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_LIKE, "LIKE"); + operator = new EntityComparisonOperator( + EntityOperator.ID_LIKE, "LIKE"); } else if ("not-equals".equals(constraintValue)) { - operator = new EntityComparisonOperator(EntityOperator.ID_NOT_EQUAL, "<>"); + operator = new EntityComparisonOperator( + EntityOperator.ID_NOT_EQUAL, "<>"); } - - exprs.add(EntityCondition.makeCondition(constraintName, operator, constraintValue)); + + exprs.add(EntityCondition.makeCondition( + constraintName, operator, + constraintValue)); } } - + EntityConditionList<EntityExpr> ecl = null; if (exprs.size() > 0) { - ecl = EntityCondition.makeCondition(exprs, EntityOperator.AND); + 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) { + List<GenericValue> entityRecords = delegator.findList( + entityName, ecl, pkFields, null, null, false); + + for (GenericValue entityRecord : entityRecords) { boolean pkFound = false; - StringBuilder pkBuffer = new StringBuilder(keyBuffer.toString()); - Iterator <String> itPkFields = pkFields.iterator(); + StringBuilder pkBuffer = new StringBuilder( + keyBuffer.toString()); + Iterator<String> itPkFields = pkFields.iterator(); while (itPkFields != null && itPkFields.hasNext()) { String pkField = itPkFields.next(); Object pkFieldValue = entityRecord.get(pkField); - + if (UtilValidate.isNotEmpty(pkFieldValue)) { pkBuffer.append('.'); pkBuffer.append(pkFieldValue); @@ -893,42 +1048,53 @@ } } if (pkFound) { - setLabelReference(pkBuffer.toString(), fileNameURI); + setLabelReference(pkBuffer.toString(), + fileNameURI); } } } } } } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting records from " + entityName, module); + Debug.logError(e, "Problem getting records from " + entityName, + module); } } - + private static void getDisplayEntityTag(Element element, String fileNameURI) { - String entityName = UtilFormatOut.checkNull(element.getAttribute("entity-name")); - String description = UtilFormatOut.checkNull(element.getAttribute("description")); + String entityName = UtilFormatOut.checkNull(element + .getAttribute("entity-name")); + String description = UtilFormatOut.checkNull(element + .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())) { + + 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); - + int endLabel = description.indexOf(endExpression, + pos); + if (endLabel >= 0) { - String fieldName = description.substring(pos + startExpression.length(), endLabel); - if (!fieldName.startsWith(uiLabelMapInLayoutSettings)) { - for (Map.Entry<String, LabelInfo> e: LabelManagerFactory.getLabels().entrySet()) { - String keyToSearch = entityName + "." + fieldName; + String fieldName = description.substring(pos + + startExpression.length(), endLabel); + if (!fieldName + .startsWith(uiLabelMapInLayoutSettings)) { + for (Map.Entry<String, LabelInfo> e : LabelManagerFactory + .getLabels().entrySet()) { + String keyToSearch = entityName + "." + + fieldName; if (e.getKey().startsWith(keyToSearch)) { fields.add(fieldName); } @@ -940,7 +1106,7 @@ } } } - + // Search primary keys of entity Iterator<ModelField> iter = entity.getPksIterator(); while (iter != null && iter.hasNext()) { @@ -954,16 +1120,18 @@ keyBuffer.append(entityName); keyBuffer.append('.'); keyBuffer.append(fieldName); - List<GenericValue> entityRecords = delegator.findList(entityName, null, pkFields, null, null, false); - - for (GenericValue entityRecord: entityRecords) { + List<GenericValue> entityRecords = delegator.findList( + entityName, null, pkFields, null, null, false); + + for (GenericValue entityRecord : entityRecords) { boolean pkFound = false; - StringBuilder pkBuffer = new StringBuilder(keyBuffer.toString()); - Iterator <String> itPkFields = pkFields.iterator(); + StringBuilder pkBuffer = new StringBuilder( + keyBuffer.toString()); + Iterator<String> itPkFields = pkFields.iterator(); while (itPkFields != null && itPkFields.hasNext()) { String pkField = itPkFields.next(); Object pkFieldValue = entityRecord.get(pkField); - + if (UtilValidate.isNotEmpty(pkFieldValue)) { pkBuffer.append('.'); pkBuffer.append(pkFieldValue); @@ -971,14 +1139,16 @@ } } if (pkFound) { - setLabelReference(pkBuffer.toString(), fileNameURI); + setLabelReference(pkBuffer.toString(), + fileNameURI); } } } } } } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting records from " + entityName, module); + Debug.logError(e, "Problem getting records from " + entityName, + module); } } } 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=754649&r1=754648&r2=754649&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Sun Mar 15 10:36:41 2009 @@ -492,7 +492,7 @@ <request-map uri="UpdateAndSaveLabelKey"> <security https="true" auth="true"/> - <event type="service" invoke="UpdateAndSaveLabelKey"/> + <event type="service" invoke="updateAndSaveLabelKey"/> <response name="success" type="view" value="SearchLabels"/> <response name="error" type="view" value="UpdateLabel"/> </request-map> Modified: 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=754649&r1=754648&r2=754649&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl Sun Mar 15 10:36:41 2009 @@ -16,6 +16,12 @@ specific language governing permissions and limitations under the License. --> +<script language="JavaScript" type="text/javascript"> + function updateAndSaveLabel() { + document.UpdateLabelForm.action="<@ofbizUrl>UpdateAndSaveLabelKey</@ofbizUrl>"; + document.UpdateLabelForm.submit(); + } +</script> <div class="screenlet-body"> <form method="post" action="<@ofbizUrl>UpdateLabelKey</@ofbizUrl>" name="UpdateLabelForm"> <table class="basic-table" cellspacing="3"> @@ -63,8 +69,10 @@ <#if parameters.sourceKey?exists> <input type="submit" value="${uiLabelMap.CommonUpdate}" name="confirm"/> <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerRemove}" name="removeLabel"/> + <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerUpdateAndSave}" name="confirm" onclick="javascript:updateAndSaveLabel()"/> <#else> <input type="submit" value="${uiLabelMap.CommonAdd}" name="confirm"/> + <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerUpdateAndSave}" name="confirm" onclick="javascript:updateAndSaveLabel()"/> </#if> </td> </tr> @@ -111,8 +119,10 @@ <#if parameters.sourceKey?exists> <input type="submit" value="${uiLabelMap.CommonUpdate}" name="confirm"/> <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerRemove}" name="removeLabel"/> + <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerUpdateAndSave}" name="confirm" onclick="javascript:updateAndSaveLabel()"/> <#else> <input type="submit" value="${uiLabelMap.CommonAdd}" name="confirm"/> + <input type="submit" value="${uiLabelMap.WebtoolsLabelManagerUpdateAndSave}" name="confirm" onclick="javascript:updateAndSaveLabel()"/> </#if> </td> </tr> |
Free forum by Nabble | Edit this page |