public String generateSource_AddElements(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); Buf buf = new Buf(); buf.putLine2("putElements(" + fieldTypeLocalPart + "Map);"); return buf.get(); }
public static Result createResult(Class<?> resultType) { Result result = new Result(); String resultName = resultType.getCanonicalName(); String simpleName = NameUtil.getSimpleName(resultName); result.setName(NameUtil.uncapName(simpleName)); String typeName = TypeUtil.getTypeFromClass(resultType); // Assert.notNull(typeName, "TypeName not found for: "+resultName); if (typeName == null) typeName = resultName; result.setType(typeName); return result; }
public String generateSource_SetElement(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); Buf buf = new Buf(); // buf.putLine2("synchronized (this."+fieldNameUncapped+") {"); buf.putLine2("this." + fieldNameUncapped + " = " + fieldTypeLocalPart + ";"); // buf.putLine2("}"); return buf.get(); }
protected String generateShowElementNodeMenu(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine4(" "); buf.putLine4(" "); buf.putLine4("<!--"); buf.putLine4(" ** show" + targetName + "TreeNodeMenu(event, nodeType)"); buf.putLine4(" ** Displays context-menu for " + targetName + " Tree node.."); buf.putLine4(" -->"); buf.putLine4(" "); buf.putLine4("function show" + targetName + "TreeNodeMenu(event, nodeType) {"); buf.putLine4(" var typeUncapped = uncapitalize(nodeType);"); buf.putLine4(" var menuName = mainFormId + ':' + typeUncapped + 'TreeMenu';"); buf.putLine4(" var menu = RichFaces.component(menuName);"); buf.putLine4(" if (menu != null) {"); buf.putLine4(" menu.show(event, {});"); buf.putLine4(" }"); // buf.putLine4(" //alert("+elementNameUncapped+"TreeState.nodeLabel)"); // buf.putLine4(" //TODO This currently has no effect, we are waiting for when it will work"); // buf.putLine4(" var menu = #{rich:component('"+targetNameUncapped+"TreeMenu')};"); // buf.putLine4(" menu.show(event, {});"); // buf.putLine4(" menu.show(event, {"); // buf.putLine4(" 'projectName': 'project1',"); // buf.putLine4(" 'canAdd': 'false'"); // buf.putLine4(" });"); buf.putLine4("}"); return buf.get(); }
public static String toString(PhoneLocation phoneLocation) { if (phoneLocation != null) { String name = phoneLocation.name().toLowerCase(); name = NameUtil.capName(name) + ":"; return name; } return ""; }
public static String generateCallToRemoteOperation( ActivityGenerator<?> generator, Service remoteService, Operation remoteOperation, String inputVariableName, String outputVariableName) { // get source code for method body Buf buf = new Buf(); // String portTypeName = TypeUtil.getTypeFromQName(portType.getQName()); // String portTypeLocalName = TypeUtil.getClassName(portTypeName); String portTypePackageName = ProjectLevelHelper.getPackageName(remoteService.getNamespace()); String portTypeLocalName = NameUtil.capName(remoteService.getName()); String portTypeClassName = portTypeLocalName + "Client"; buf.putLine2("ProxyLocator proxyLocator = BeanContext.get(\"org.aries.proxyLocator\");"); buf.putLine2(portTypeClassName + " proxy = proxyLocator.get(\"" + portTypeLocalName + "\");"); // buf.putLine2(portTypeClassName+" proxy = new "+portTypeClassName+"();"); buf.putLine2("proxy.setCorrelationId(getCorrelationId());"); Input input = remoteOperation.getInput(); QName qName = input.getMessage().getQName(); input.getMessage().getParts(); generator.addImportedClass("org.aries.process.ProxyLocator"); generator.addImportedClass(portTypePackageName + "." + portTypeClassName); if (outputVariableName != null) { buf.put2(outputVariableName + " = proxy." + remoteOperation.getName() + "("); } else { buf.put2("proxy." + remoteOperation.getName() + "("); } Message inputMessage = (Message) remoteOperation.getInput().getMessage(); @SuppressWarnings("unchecked") Collection<Part> parts = inputMessage.getParts().values(); Iterator<Part> iterator = parts.iterator(); for (int i = 0; iterator.hasNext(); i++) { Part part = iterator.next(); // String partName = NameUtil.uncapName(part.getName()); // String variableName = "this."+inputVariableName+"_"+part.getName(); // String variableName = CodeUtil.getVariableName(inputVariable); // String typeName = TypeUtil.getTypeFromMessagePart(part); // String packageName = TypeUtil.getPackageName(typeName); // String className = TypeUtil.getClassName(typeName); // ModelParameter parameter = new ModelParameter(); // parameter.setPackageName(packageName); // parameter.setClassName(className); // parameter.setName(partName); // modelOperation.addParameter(parameter); // if (TypeUtil.isImportedClassRequired(packageName, className)) // addImportedClass(packageName+"."+className); if (i > 0) buf.put(", "); buf.put(inputVariableName); } buf.putLine(");"); return buf.get(); }
public String generateSource_RemoveElements(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); String parameterName = fieldTypeLocalPart; String structure = modelField.getStructure(); if (structure.equals("list")) { parameterName = fieldTypeLocalPart + "List"; } else if (structure.equals("set")) { parameterName = fieldTypeLocalPart + "Set"; } else if (structure.equals("map")) { parameterName = fieldTypeLocalPart + "Map"; } Buf buf = new Buf(); buf.putLine2("synchronized (" + fieldNameUncapped + ") {"); buf.putLine2(" " + fieldNameUncapped + ".removeAll(" + parameterName + ");"); buf.putLine2("}"); return buf.get(); }
protected String getOpenElement(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine2(" "); buf.putLine2(" "); buf.putLine2("<!--"); buf.putLine2(" ** openElement()"); buf.putLine2(" ** Opens selected Element in various ways depending on user access rights."); buf.putLine2(" -->"); buf.putLine2(" "); return buf.get(); }
// NOT_USED protected String generateProcessElementNodeDoubleClick(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine4(" "); buf.putLine4(" "); buf.putLine4("<!--"); buf.putLine4(" ** process" + targetName + "NodeDoubleClick(event, rowKey, nodeId)"); buf.putLine4(" ** Handles double-click event on a " + targetName + " Node."); buf.putLine4(" -->"); buf.putLine4(" "); buf.putLine4("function process" + targetName + "NodeDoubleClick(event, rowKey, nodeId) {"); buf.putLine4(" try {"); buf.putLine4(" //show(event.currentTarget);"); buf.putLine4(" setCursorWait(event.target);"); buf.putLine4(" setCursorWait(event.currentTarget);"); buf.putLine4(" setCursorWait(#{rich:element('" + elementNameUncapped + "Tree')});"); // buf.putLine4(" //show"+elementClassName+"Page(source, 'Identification');"); buf.putLine4( " showProgress('Nam', '" + targetName + " #{" + targetNameUncapped + "InfoManager.selected" + targetName + ".name}', 'Preparing " + targetName + " \"summary\" view...');"); // buf.putLine4(" //showPage(source, // '"+elementPath+"/application/application.seam?section='+section);"); buf.putLine4(" view" + targetName + "('Overview', rowKey, nodeId);"); buf.putLine4(" } catch(e) {"); buf.putLine4(" alert(e);"); buf.putLine4(" }"); buf.putLine4("}"); return buf.get(); }
protected String getNewElement(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine2(" "); buf.putLine2(" "); buf.putLine2("<!--"); buf.putLine2(" ** newElement()"); buf.putLine2(" ** Creates new Element, and goes to Element Wizard Page."); buf.putLine2(" -->"); buf.putLine2(" "); buf.putLine2("<a4j:jsFunction "); buf.putLine2(" name=\"newElement\" "); buf.putLine2(" immediate=\"true\""); buf.putLine2(" execute=\"@this\" "); buf.putLine2(" bypassUpdates=\"true\""); buf.putLine2(" action=\"#{" + targetNameUncapped + "InfoManager.new" + targetName + "}\">"); buf.putLine2("</a4j:jsFunction>"); return buf.get(); }
protected String getEditElementFromTree(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine2(" "); buf.putLine2(" "); buf.putLine2("<!--"); buf.putLine2(" ** edit" + targetName + "FromTree()"); buf.putLine2( " ** Opens selected " + targetName + " for editing, and goes to " + targetName + " Wizard Page."); buf.putLine2(" -->"); buf.putLine2(" "); buf.putLine2("<a4j:jsFunction "); buf.putLine2(" name=\"edit" + targetName + "FromTree\""); buf.putLine2(" immediate=\"true\""); buf.putLine2(" execute=\"@this\" "); buf.putLine2(" bypassUpdates=\"true\""); buf.putLine2(" action=\"#{" + targetNameUncapped + "InfoManager.edit" + targetName + "}\">"); buf.putLine2(" "); buf.putLine2(" <!-- these values are passed-in -->"); buf.putLine2( " <a4j:param name=\"sectionName\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionName}\" />"); buf.putLine2( " <a4j:param name=\"selectedRowKey\" assignTo=\"#{" + elementNameUncapped + "TreeManager.selectedRowKey}\" /> "); buf.putLine2( " <a4j:param name=\"selectedNodeId\" assignTo=\"#{" + elementNameUncapped + "TreeManager.selectedNodeId}\" />"); buf.putLine2(" "); buf.putLine2(" <!-- these values are assigned here -->"); buf.putLine2( " <a4j:param name=\"sectionType\" value=\"" + targetNameUncapped + "\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionType}\" />"); buf.putLine2( " <a4j:param name=\"sectionTitle\" value=\"" + targetName + "\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionTitle}\" />"); buf.putLine2( " <a4j:param name=\"sectionIcon\" value=\"/icons/nam/" + targetName + "16.gif\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionIcon}\" />"); buf.putLine2(" "); buf.putLine2(" <!-- provide event queue settings -->"); buf.putLine2( " <a4j:attachQueue requestGroupingId=\"" + elementNameUncapped + "TreeEvents\" requestDelay=\"400\" />"); buf.putLine2("</a4j:jsFunction>"); return buf.get(); }
protected String getViewElementFromTree(Element element, String targetName) { String elementClassName = ModelLayerHelper.getElementClassName(element); String elementNameUncapped = ModelLayerHelper.getElementNameUncapped(element); String targetNameUncapped = NameUtil.uncapName(targetName); Buf buf = new Buf(); buf.putLine2(" "); buf.putLine2(" "); buf.putLine2("<!--"); buf.putLine2(" ** viewElementFromTree()"); buf.putLine2( " ** Opens selected Element for read-only view, and goes to Element Wizard Page."); buf.putLine2(" -->"); buf.putLine2(" "); buf.putLine2("<a4j:jsFunction "); buf.putLine2(" name=\"viewElementFromTree\""); buf.putLine2(" execute=\"@this\""); buf.putLine2(" immediate=\"true\""); buf.putLine2(" bypassUpdates=\"true\""); buf.putLine2(" limitRender=\"true\""); buf.putLine2(" action=\"#{" + targetNameUncapped + "InfoManager.viewElement}\""); buf.putLine2(" oncomplete=\"setCursorDefault(); hideProgress()\""); buf.putLine2(" render=\"" + elementNameUncapped + "ManagementViewer\">"); buf.putLine2(" "); buf.putLine2(" <!-- these values are passed-in -->"); buf.putLine2( " <a4j:param name=\"sectionName\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionName}\" />"); buf.putLine2( " <a4j:param name=\"selectedRowKey\" assignTo=\"#{" + elementNameUncapped + "TreeManager.selectedRowKey}\" /> "); buf.putLine2( " <a4j:param name=\"selectedNodeId\" assignTo=\"#{" + elementNameUncapped + "TreeManager.selectedNodeId}\" />"); buf.putLine2(" "); buf.putLine2(" <!-- these values are assigned here -->"); buf.putLine2( " <a4j:param name=\"sectionType\" value=\"" + targetNameUncapped + "\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionType}\" />"); buf.putLine2( " <a4j:param name=\"sectionTitle\" value=\"" + targetName + "\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionTitle}\" />"); buf.putLine2( " <a4j:param name=\"sectionIcon\" value=\"/icons/nam/" + targetName + "16.gif\" assignTo=\"#{" + elementNameUncapped + "TreeManager.sectionIcon}\" />"); buf.putLine2(" "); buf.putLine2(" <!-- provide event queue settings -->"); buf.putLine2( " <a4j:attachQueue requestGroupingId=\"" + elementNameUncapped + "TreeEvents\" requestDelay=\"400\" />"); buf.putLine2("</a4j:jsFunction>"); return buf.get(); }
protected void updateState(Transacted transacted) { String transactedName = NameUtil.capName(transacted.toString()); setSectionTitle(transactedName + " Transacted"); }
public void initializeView(String elementType, String viewTitle, String sectionName) { String pageManagerName = NameUtil.uncapName(elementType) + "PageManager"; PageManager<?> pageManager = BeanContext.getFromSession(pageManagerName); initializeView(pageManager, viewTitle, sectionName); }