List of usage examples for org.apache.commons.lang StringUtils uncapitalize
public static String uncapitalize(String str)
Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .
From source file:org.eclipse.wb.internal.core.xml.model.description.rules.CreatePropertiesPropertyDescriptorRule.java
private void addSingleProperty(ComponentDescription componentDescription, PropertyDescriptor propertyDescriptor) throws Exception { Method setMethod = propertyDescriptor.getWriteMethod(); if (setMethod == null) { return;//from w ww . j a va 2 s . co m } if (!ReflectionUtils.isPublic(setMethod)) { return; } // prepare description parts String title = propertyDescriptor.getName(); String attribute = StringUtils.substringBeforeLast(StringUtils.uncapitalize(title), "("); Method getMethod = propertyDescriptor.getReadMethod(); Class<?> propertyType = resolvePropertyType(componentDescription, setMethod); // prepare property parts String id = setMethod.getName() + "(" + ReflectionUtils.getFullyQualifiedName(propertyType, false) + ")"; ExpressionAccessor accessor = new MethodExpressionAccessor(attribute, setMethod, getMethod); ExpressionConverter converter = DescriptionPropertiesHelper.getConverterForType(propertyType); PropertyEditor editor = DescriptionPropertiesHelper.getEditorForType(propertyType); // create property GenericPropertyDescription property = new GenericPropertyDescription(id, title, propertyType, accessor); property.setConverter(converter); property.setEditor(editor); // add property componentDescription.addProperty(property); }
From source file:org.eclipse.wb.internal.rcp.databinding.model.ControllerSupport.java
public static String automaticWizardPerformSubstitutions(AutomaticDatabindingFirstPage firstWizardPage, String code, ImportsManager imports, IJavaProject javaProject, ClassLoader classLoader, Class<?> beanClass, List<PropertyAdapter> properties, Map<PropertyAdapter, AbstractDescriptor[]> propertyToEditor) throws Exception { InputStream controllerStream = Activator.getFile("templates/Controller.jvt"); String controllerCode = IOUtils.toString(controllerStream); IOUtils.closeQuietly(controllerStream); ////from www . ja v a 2s . c om String hostClassName = ClassUtils.getShortClassName(firstWizardPage.getTypeName()); String hostVariable = StringUtils.uncapitalize(hostClassName); String hostField = "m_" + hostVariable; // controllerCode = StringUtils.replace(controllerCode, "%HostClass%", hostClassName); controllerCode = StringUtils.replace(controllerCode, "%HostVariable%", hostVariable); controllerCode = StringUtils.replace(controllerCode, "%HostField%", hostField); // String begin = ""; String end = "\t\t"; String widgetStart = ""; boolean blockMode = SwtDatabindingProvider.useBlockMode(); if (blockMode) { begin = "\t\t{\r\n"; end = "\t\t}"; widgetStart = "\t"; } // prepare imports Collection<String> hostImportList = Sets.newHashSet(); hostImportList.add(SWT.class.getName()); hostImportList.add("org.eclipse.swt.widgets.Label"); hostImportList.add("org.eclipse.swt.layout.GridLayout"); hostImportList.add("org.eclipse.swt.layout.GridData"); // Collection<String> controllerImportList = Sets.newHashSet(); controllerImportList.add(SWT.class.getName()); controllerImportList.add("org.eclipse.jface.databinding.swt.SWTObservables"); controllerImportList.add("org.eclipse.core.databinding.observable.value.IObservableValue"); controllerImportList.add("org.eclipse.core.databinding.UpdateValueStrategy"); // DataBindingsCodeUtils.ensureDBLibraries(javaProject); // IAutomaticWizardStub automaticWizardStub = GlobalFactoryHelper.automaticWizardCreateStub(javaProject, classLoader, beanClass); // String observeMethod = null; if (automaticWizardStub == null) { if (ObservableInfo.isPojoBean(beanClass)) { String pojoClassName = DataBindingsCodeUtils.getPojoObservablesClass(); observeMethod = "ObserveValue = " + ClassUtils.getShortClassName(pojoClassName) + ".observeValue("; controllerImportList.add(pojoClassName); } else { observeMethod = "ObserveValue = BeansObservables.observeValue("; controllerImportList.add("org.eclipse.core.databinding.beans.BeansObservables"); } } else { automaticWizardStub.addImports(controllerImportList); } // prepare bean String beanClassName = CoreUtils.getClassName(beanClass); String beanClassShortName = ClassUtils.getShortClassName(beanClassName); String fieldPrefix = JavaCore.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES); String fieldName = fieldPrefix + StringUtils.uncapitalize(beanClassShortName); controllerCode = StringUtils.replace(controllerCode, "%BeanClass%", beanClassName); // if (ReflectionUtils.getConstructorBySignature(beanClass, "<init>()") == null) { controllerCode = StringUtils.replace(controllerCode, "%BeanField%", fieldName); } else { controllerCode = StringUtils.replace(controllerCode, "%BeanField%", fieldName + " = new " + beanClassName + "()"); } // IPreferenceStore preferences = ToolkitProvider.DESCRIPTION.getPreferences(); String accessPrefix = preferences.getBoolean(FieldUniqueVariableSupport.P_PREFIX_THIS) ? "this." : ""; controllerCode = StringUtils.replace(controllerCode, "%BeanFieldAccess%", accessPrefix + fieldName); // controllerCode = StringUtils.replace(controllerCode, "%BeanName%", StringUtils.capitalize(beanClassShortName)); // prepare code StringBuffer widgetFields = new StringBuffer(); StringBuffer widgets = new StringBuffer(); String swtContainer = StringUtils.substringBetween(code, "%Widgets%", "%"); String swtContainerWithDot = "this".equals(swtContainer) ? "" : swtContainer + "."; // StringBuffer observables = new StringBuffer(); StringBuffer bindings = new StringBuffer(); StringBuffer widgetGetters = new StringBuffer(); // hostImportList.add(GridLayout.class.getName()); widgets.append("\t\t" + swtContainerWithDot + "setLayout(new GridLayout(2, false));\r\n"); if (!blockMode) { widgets.append("\t\t\r\n"); } // for (Iterator<PropertyAdapter> I = properties.iterator(); I.hasNext();) { PropertyAdapter property = I.next(); Object[] editorData = propertyToEditor.get(property); SwtWidgetDescriptor widgetDescriptor = (SwtWidgetDescriptor) editorData[0]; JFaceBindingStrategyDescriptor strategyDescriptor = (JFaceBindingStrategyDescriptor) editorData[1]; // String propertyName = property.getName(); String widgetClassName = widgetDescriptor.getClassName(); String widgetFieldName = fieldPrefix + propertyName + widgetClassName; String widgetFieldAccess = accessPrefix + widgetFieldName; String widgetAccessor = "get" + StringUtils.capitalize(propertyName) + widgetClassName + "()"; String widgetControllerAccessor = hostField + "." + widgetAccessor; // getter widgetGetters.append("method\n\tpublic " + widgetClassName + " " + widgetAccessor + " {\n\t\treturn " + widgetFieldName + ";\n\t}\n\n"); // field widgetFields.append("\r\nfield\r\n\tprivate " + widgetClassName + " " + widgetFieldName + ";"); // widget widgets.append(begin); widgets.append(widgetStart + "\t\tnew Label(" + swtContainer + ", SWT.NONE).setText(\"" + StringUtils.capitalize(propertyName) + ":\");\r\n"); widgets.append(end + "\r\n"); // widgets.append(begin); widgets.append( "\t\t" + widgetFieldAccess + " = " + widgetDescriptor.getCreateCode(swtContainer) + ";\r\n"); widgets.append(widgetStart + "\t\t" + widgetFieldAccess + ".setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r\n"); widgets.append(end); // observables observables.append("\t\tIObservableValue " + propertyName + "ObserveWidget = " + widgetDescriptor.getBindingCode(widgetControllerAccessor) + ";\r\n"); if (automaticWizardStub == null) { observables.append("\t\tIObservableValue " + propertyName + observeMethod + fieldName + ", \"" + propertyName + "\");"); } else { observables.append(automaticWizardStub.createSourceCode(fieldName, propertyName)); } // bindings bindings.append("\t\tbindingContext.bindValue(" + propertyName + "ObserveWidget, " + propertyName + "ObserveValue, " + strategyDescriptor.getTargetStrategyCode() + ", " + strategyDescriptor.getModelStrategyCode() + ");"); // if (I.hasNext()) { widgetFields.append("\r\n"); widgets.append("\r\n"); observables.append("\r\n"); bindings.append("\r\n"); } // hostImportList.add(widgetDescriptor.getFullClassName()); } // replace template patterns String controllerClass = hostClassName + "Controller"; code = StringUtils.replace(code, "%ControllerClass%", controllerClass); code = StringUtils.replace(code, "%WidgetFields%", widgetFields.toString()); code = StringUtils.replace(code, "%Widgets%" + swtContainer + "%", widgets.toString()); code = StringUtils.replace(code, "%WidgetGetters%", widgetGetters.toString()); // controllerCode = StringUtils.replace(controllerCode, "%Observables%", observables.toString()); controllerCode = StringUtils.replace(controllerCode, "%Bindings%", bindings.toString()); // add imports for (String qualifiedTypeName : hostImportList) { imports.addImport(qualifiedTypeName); } StringBuffer controllerImportString = new StringBuffer(); for (String controllerImport : controllerImportList) { controllerImportString.append("import " + controllerImport + ";\n"); } controllerCode = StringUtils.replace(controllerCode, "%imports%", controllerImportString.toString()); // IPackageFragment packageFragment = firstWizardPage.getPackageFragment(); // String packageString = packageFragment.getElementName(); if (packageString.length() > 0) { packageString = "package " + packageString + ";"; } controllerCode = StringUtils.replace(controllerCode, "%package%", packageString); // IPath packagePath = packageFragment.getPath().removeFirstSegments(1); IFile controllerFile = javaProject.getProject().getFile(packagePath.append(controllerClass + ".java")); IOUtils2.setFileContents(controllerFile, controllerCode); // return code; }
From source file:org.eclipse.wb.internal.rcp.databinding.model.ControllerSupport.java
private static void convertJavaInfosToGetters(DatabindingsProvider provider, AstEditor editor, TypeDeclaration rootNode) throws Exception { provider.setController(true);//from www .j a va2 s .c om provider.setControllerViewerField("m_" + StringUtils.uncapitalize(rootNode.getName().getIdentifier())); // List<IBindingInfo> bindings = provider.getBindings(); for (IBindingInfo binding : bindings) { convertJavaInfoToGetter(provider, binding.getModel()); convertJavaInfoToGetter(provider, binding.getTarget()); } editor.commitChanges(); }
From source file:org.eclipse.wb.internal.rcp.databinding.model.ControllerSupport.java
private static void createContollerClass(DatabindingsProvider provider, AstEditor editor, TypeDeclaration rootNode) throws Exception { String endOfLine = editor.getGeneration().getEndOfLine(); ///*from ww w.j a v a 2s .co m*/ StringBuffer controllerCode = new StringBuffer(); // IType hostType = editor.getJavaProject().findType(AstNodeUtils.getFullyQualifiedName(rootNode, false)); IPackageFragment packageFragment = hostType.getPackageFragment(); // String hostClass = rootNode.getName().getIdentifier(); String controllerClass = hostClass + "Controller"; String hostVariable = StringUtils.uncapitalize(hostClass); String hostField = "m_" + hostVariable; String fullControllerClass = controllerClass; // String packageString = packageFragment.getElementName(); if (packageString.length() > 0) { controllerCode.append("package " + packageString + ";" + endOfLine + endOfLine); fullControllerClass = packageString + "." + controllerClass; } // controllerCode.append("public class " + controllerClass + " {" + endOfLine); controllerCode.append("\tprivate " + hostClass + " " + hostField + ";" + endOfLine + endOfLine); controllerCode .append("\tpublic " + controllerClass + "(" + hostClass + " " + hostVariable + ") {" + endOfLine); controllerCode.append("\t\t" + hostField + " = " + hostVariable + ";" + endOfLine); controllerCode.append("\t}" + endOfLine); controllerCode.append("}"); // IPath packagePath = packageFragment.getPath().removeFirstSegments(1); IFile controllerFile = editor.getJavaProject().getProject() .getFile(packagePath.append(controllerClass + ".java")); IOUtils2.setFileContents(controllerFile, controllerCode.toString()); // ProjectUtils.waitForAutoBuild(); // IType controllerType = editor.getJavaProject().findType(fullControllerClass); ICompilationUnit controllerUnit = controllerType.getCompilationUnit(); AstEditor controllerASTEditor = new AstEditor(controllerUnit); // create controller EditorState EditorState thisEditorState = EditorState.get(provider.getAstEditor()); EditorState controllerEditorState = EditorState.get(controllerASTEditor); controllerEditorState.initialize(thisEditorState.getToolkitId(), thisEditorState.getEditorLoader()); controllerEditorState.setFlowDescription(thisEditorState.getFlowDescription()); // prepare controller root AST node TypeDeclaration controllerRootNode = DomGenerics.types(controllerASTEditor.getAstUnit()).get(0); // provider.setAstEditor(controllerASTEditor); provider.setRootNode(controllerRootNode); }
From source file:org.eclipse.wb.internal.rcp.databinding.wizards.autobindings.SwtDatabindingProvider.java
public String performSubstitutions(String code, ImportsManager imports) throws Exception { // prepare properties final List<PropertyAdapter> properties = Lists.newArrayList(); Display.getDefault().syncExec(new Runnable() { public void run() { CollectionUtils.addAll(properties, m_propertiesViewer.getCheckedElements()); }/*w w w .j a va 2s . c o m*/ }); // if (m_firstPage.isCreateControlClass()) { return ControllerSupport.automaticWizardPerformSubstitutions(m_firstPage, code, imports, m_javaProject, m_classLoader, m_beanClass, properties, m_propertyToEditor); } // String begin = ""; String end = "\t\t"; String widgetStart = ""; boolean blockMode = useBlockMode(); if (blockMode) { begin = "\t\t{\r\n"; end = "\t\t}"; widgetStart = "\t"; } // prepare imports Collection<String> importList = Sets.newHashSet(); importList.add(SWT.class.getName()); importList.add("org.eclipse.jface.databinding.swt.SWTObservables"); importList.add("org.eclipse.core.databinding.observable.value.IObservableValue"); importList.add("org.eclipse.core.databinding.UpdateValueStrategy"); importList.add("org.eclipse.swt.widgets.Label"); importList.add("org.eclipse.swt.layout.GridLayout"); importList.add("org.eclipse.swt.layout.GridData"); // DataBindingsCodeUtils.ensureDBLibraries(m_javaProject); // IAutomaticWizardStub automaticWizardStub = GlobalFactoryHelper.automaticWizardCreateStub(m_javaProject, m_classLoader, m_beanClass); // String observeMethod = null; if (automaticWizardStub == null) { if (ObservableInfo.isPojoBean(m_beanClass)) { String pojoClass = DataBindingsCodeUtils.getPojoObservablesClass(); observeMethod = "ObserveValue = " + ClassUtils.getShortClassName(pojoClass) + ".observeValue("; importList.add(pojoClass); } else { observeMethod = "ObserveValue = BeansObservables.observeValue("; importList.add("org.eclipse.core.databinding.beans.BeansObservables"); } } else { automaticWizardStub.addImports(importList); } // prepare bean String beanClassName = CoreUtils.getClassName(m_beanClass); String beanClassShortName = ClassUtils.getShortClassName(beanClassName); String fieldPrefix = JavaCore.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES); String fieldName = fieldPrefix + StringUtils.uncapitalize(beanClassShortName); code = StringUtils.replace(code, "%BeanClass%", beanClassName); // if (ReflectionUtils.getConstructorBySignature(m_beanClass, "<init>()") == null) { code = StringUtils.replace(code, "%BeanField%", fieldName); } else { code = StringUtils.replace(code, "%BeanField%", fieldName + " = new " + beanClassName + "()"); } // IPreferenceStore preferences = ToolkitProvider.DESCRIPTION.getPreferences(); String accessPrefix = preferences.getBoolean(FieldUniqueVariableSupport.P_PREFIX_THIS) ? "this." : ""; code = StringUtils.replace(code, "%BeanFieldAccess%", accessPrefix + fieldName); // code = StringUtils.replace(code, "%BeanName%", StringUtils.capitalize(beanClassShortName)); // prepare code StringBuffer widgetFields = new StringBuffer(); StringBuffer widgets = new StringBuffer(); String swtContainer = StringUtils.substringBetween(code, "%Widgets%", "%"); String swtContainerWithDot = "this".equals(swtContainer) ? "" : swtContainer + "."; // StringBuffer observables = new StringBuffer(); StringBuffer bindings = new StringBuffer(); // importList.add(GridLayout.class.getName()); widgets.append("\t\t" + swtContainerWithDot + "setLayout(new GridLayout(2, false));\r\n"); if (!blockMode) { widgets.append("\t\t\r\n"); } // for (Iterator<PropertyAdapter> I = properties.iterator(); I.hasNext();) { PropertyAdapter property = I.next(); Object[] editorData = m_propertyToEditor.get(property); SwtWidgetDescriptor widgetDescriptor = (SwtWidgetDescriptor) editorData[0]; JFaceBindingStrategyDescriptor strategyDescriptor = (JFaceBindingStrategyDescriptor) editorData[1]; // String propertyName = property.getName(); String widgetClassName = widgetDescriptor.getClassName(); String widgetFieldName = fieldPrefix + propertyName + widgetClassName; String widgetFieldAccess = accessPrefix + widgetFieldName; // field widgetFields.append("\r\nfield\r\n\tprivate " + widgetClassName + " " + widgetFieldName + ";"); // widget widgets.append(begin); widgets.append(widgetStart + "\t\tnew Label(" + swtContainer + ", SWT.NONE).setText(\"" + StringUtils.capitalize(propertyName) + ":\");\r\n"); widgets.append(end + "\r\n"); // widgets.append(begin); widgets.append( "\t\t" + widgetFieldAccess + " = " + widgetDescriptor.getCreateCode(swtContainer) + ";\r\n"); widgets.append(widgetStart + "\t\t" + widgetFieldAccess + ".setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r\n"); widgets.append(end); // observables observables.append("\t\tIObservableValue " + propertyName + "ObserveWidget = " + widgetDescriptor.getBindingCode(widgetFieldName) + ";\r\n"); if (automaticWizardStub == null) { observables.append("\t\tIObservableValue " + propertyName + observeMethod + fieldName + ", \"" + propertyName + "\");"); } else { observables.append(automaticWizardStub.createSourceCode(fieldName, propertyName)); } // bindings bindings.append("\t\tbindingContext.bindValue(" + propertyName + "ObserveWidget, " + propertyName + "ObserveValue, " + getStrategyValue(strategyDescriptor.getTargetStrategyCode()) + ", " + getStrategyValue(strategyDescriptor.getModelStrategyCode()) + ");"); // if (I.hasNext()) { widgetFields.append("\r\n"); widgets.append("\r\n"); observables.append("\r\n"); bindings.append("\r\n"); } // importList.add(widgetDescriptor.getFullClassName()); } // replace template patterns code = StringUtils.replace(code, "%WidgetFields%", widgetFields.toString()); code = StringUtils.replace(code, "%Widgets%" + swtContainer + "%", widgets.toString()); // code = StringUtils.replace(code, "%Observables%", observables.toString()); code = StringUtils.replace(code, "%Bindings%", bindings.toString()); // add imports for (String qualifiedTypeName : importList) { imports.addImport(qualifiedTypeName); } // return code; }
From source file:org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.XmlObjectReferenceProvider.java
public static void generateName(XmlObjectInfo objectInfo) throws Exception { if (getName(objectInfo) == null) { final Set<String> variables = Sets.newHashSet(); ////from w w w . ja va2 s . c o m DocumentElement rootElement = objectInfo.getElement().getRoot(); final String[] xName = new String[1]; // for (DocumentAttribute attribute : rootElement.getDocumentAttributes()) { String name = attribute.getName(); String value = attribute.getValue(); if (name.startsWith(BeansObserveTypeContainer.NAMESPACE_KEY)) { if (value.equals("http://www.eclipse.org/xwt")) { xName[0] = name.substring(BeansObserveTypeContainer.NAMESPACE_KEY.length()) + ":Name"; break; } } } // rootElement.accept(new DocumentModelVisitor() { @Override public void visit(DocumentAttribute attribute) { if (attribute.getName().equalsIgnoreCase(xName[0])) { variables.add(attribute.getValue()); } } }); // String baseVariable = StringUtils .uncapitalize(ClassUtils.getShortClassName(objectInfo.getDescription().getComponentClass())); String variable = baseVariable; int variableIndex = 1; // ensure unique while (variables.contains(variable)) { variable = baseVariable + "_" + Integer.toString(variableIndex++); } // Property property = objectInfo.getPropertyByTitle("Name"); property.setValue(variable); } }
From source file:org.eclipse.wb.internal.swing.databinding.wizards.autobindings.SwingDatabindingProvider.java
public String performSubstitutions(String code, ImportsManager imports) throws Exception { // calculate states boolean blockMode = useBlockMode(); boolean lazyVariables = createLazyVariables(); ////from w w w . j a v a 2 s . c om DataBindingsCodeUtils.ensureDBLibraries(m_javaProject); CodeGenerationSupport generationSupport = new CodeGenerationSupport(CoreUtils.useGenerics(m_javaProject)); // prepare imports Collection<String> importList = Sets.newHashSet(); importList.add("java.awt.GridBagLayout"); importList.add("java.awt.GridBagConstraints"); importList.add("java.awt.Insets"); importList.add("javax.swing.JLabel"); importList.add("org.jdesktop.beansbinding.AutoBinding"); importList.add("org.jdesktop.beansbinding.Bindings"); importList.add("org.jdesktop.beansbinding.BeanProperty"); // if (!generationSupport.useGenerics()) { importList.add("org.jdesktop.beansbinding.Property"); } // bean class, field, name, field access String beanClassName = m_beanClass.getName().replace('$', '.'); String beanClassShortName = ClassUtils.getShortClassName(beanClassName); String fieldPrefix = JavaCore.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES); String fieldName = fieldPrefix + StringUtils.uncapitalize(beanClassShortName); // code = StringUtils.replace(code, "%BeanClass%", beanClassName); // if (ReflectionUtils.getConstructorBySignature(m_beanClass, "<init>()") == null) { code = StringUtils.replace(code, "%BeanField%", fieldName); } else { code = StringUtils.replace(code, "%BeanField%", fieldName + " = new " + beanClassName + "()"); } // IPreferenceStore preferences = ToolkitProvider.DESCRIPTION.getPreferences(); String accessPrefix = preferences.getBoolean(FieldUniqueVariableSupport.P_PREFIX_THIS) ? "this." : ""; String beanFieldAccess = accessPrefix + fieldName; // code = StringUtils.replace(code, "%BeanName%", StringUtils.capitalize(beanClassShortName)); code = StringUtils.replace(code, "%BeanFieldAccess%", accessPrefix + fieldName); // prepare properties final List<PropertyAdapter> properties = Lists.newArrayList(); Display.getDefault().syncExec(new Runnable() { public void run() { CollectionUtils.addAll(properties, m_propertiesViewer.getCheckedElements()); } }); // prepare code StringBuffer componentFields = new StringBuffer(); StringBuffer components = new StringBuffer(); String swingContainer = StringUtils.substringBetween(code, "%Components%", "%"); String swingContainerWithDot = "this".equals(swingContainer) ? "" : swingContainer + "."; // int propertiesCount = properties.size(); int lastPropertyIndex = propertiesCount - 1; StringBuffer bindings = new StringBuffer(); // prepare layout code components.append("\t\tGridBagLayout gridBagLayout = new GridBagLayout();\r\n"); components.append("\t\tgridBagLayout.columnWidths = new int[]{0, 0, 0};\r\n"); components.append("\t\tgridBagLayout.rowHeights = new int[]{" + StringUtils.repeat("0, ", propertiesCount) + "0};\r\n"); components.append("\t\tgridBagLayout.columnWeights = new double[]{0.0, 1.0, 1.0E-4};\r\n"); components.append("\t\tgridBagLayout.rowWeights = new double[]{" + StringUtils.repeat("0.0, ", propertiesCount) + "1.0E-4};\r\n"); components.append("\t\t" + swingContainerWithDot + "setLayout(gridBagLayout);\r\n"); // StringBuffer group = new StringBuffer(); generationSupport.generateLocalName("bindingGroup"); // StringBuffer lazy = new StringBuffer(); // for (int i = 0; i < propertiesCount; i++) { String index = Integer.toString(i); // PropertyAdapter property = properties.get(i); Object[] editorData = m_propertyToEditor.get(property); SwingComponentDescriptor componentDescriptor = (SwingComponentDescriptor) editorData[0]; // String propertyName = property.getName(); // label addLabelCode(componentFields, components, lazy, swingContainerWithDot, blockMode, lazyVariables, propertyName, index); // String componentClassName = componentDescriptor.getComponentClass(); String componentShortClassName = ClassUtils.getShortClassName(componentClassName); String componentFieldName = fieldPrefix + propertyName + componentShortClassName; String componentFieldAccess = accessPrefix + componentFieldName; String componentLazyAccess = "get" + StringUtils.capitalize(propertyName) + componentShortClassName + "()"; String componentAccess = lazyVariables ? componentLazyAccess : componentFieldAccess; // importList.add(componentClassName); // field componentFields .append("\r\nfield\r\n\tprivate " + componentShortClassName + " " + componentFieldName + ";"); // component addComponentCode(components, lazy, swingContainerWithDot, blockMode, lazyVariables, componentShortClassName, componentFieldAccess, componentLazyAccess, index); // binding properties AutoBindingUpdateStrategyDescriptor strategyDescriptor = (AutoBindingUpdateStrategyDescriptor) editorData[1]; // String modelPropertyName = generationSupport.generateLocalName(propertyName, "Property"); String targetPropertyName = generationSupport.generateLocalName(componentDescriptor.getName(1), "Property"); String bindingName = generationSupport.generateLocalName("autoBinding"); String modelGeneric = null; String targetGeneric = null; // if (generationSupport.useGenerics()) { modelGeneric = beanClassName + ", " + GenericUtils.convertPrimitiveType(property.getType().getName()); bindings.append("\t\tBeanProperty<" + modelGeneric + "> "); } else { bindings.append("\t\tProperty "); } bindings.append(modelPropertyName + " = BeanProperty.create(\"" + propertyName + "\");\r\n"); // if (generationSupport.useGenerics()) { targetGeneric = componentDescriptor.getComponentClass() + ", " + componentDescriptor.getPropertyClass(); bindings.append("\t\tBeanProperty<" + targetGeneric + "> "); } else { bindings.append("\t\tProperty "); } bindings.append( targetPropertyName + " = BeanProperty.create(\"" + componentDescriptor.getName(1) + "\");\r\n"); // binding bindings.append("\t\tAutoBinding"); if (generationSupport.useGenerics()) { bindings.append("<" + modelGeneric + ", " + targetGeneric + ">"); } bindings.append(" " + bindingName + " = Bindings.createAutoBinding(" + strategyDescriptor.getSourceCode() + ", " + beanFieldAccess + ", " + modelPropertyName + ", " + componentAccess + ", " + targetPropertyName + ");\r\n"); bindings.append("\t\t" + bindingName + ".bind();"); // group.append("\t\tbindingGroup.addBinding(" + bindingName + ");"); // if (i < lastPropertyIndex) { componentFields.append("\r\n"); components.append("\r\n"); bindings.append("\r\n\t\t//\r\n"); group.append("\r\n"); } // } // replace template patterns code = StringUtils.replace(code, "%ComponentFields%", componentFields.toString()); code = StringUtils.replace(code, "%Components%" + swingContainer + "%", components.toString()); code = StringUtils.replace(code, "%Bindings%", bindings.toString()); code = StringUtils.replace(code, "%Group%", group.toString()); code = StringUtils.replace(code, "%LAZY%", lazy.toString()); // add imports for (String qualifiedTypeName : importList) { imports.addImport(qualifiedTypeName); } // return code; }
From source file:org.eclipse.wb.internal.xwt.model.jface.ViewerInfo.java
/** * @return the name of property which corresponds to the given getter {@link Method}. *//*from w w w. j ava2s.co m*/ private static String getPropertyName(Method method) { String property = StringUtils.removeStart(method.getName(), "get"); return StringUtils.uncapitalize(property); }
From source file:org.entando.edo.builder.ControllerFileBuilder.java
public static String getActionXmlFilePath(EdoBean bean) { String filename = StringUtils.uncapitalize(bean.getName()) + ".xml"; String finalfile = ControllerFileBuilder.getActionFolder(bean) + filename; return finalfile; }
From source file:org.entando.edo.builder.ControllerFileBuilder.java
public static String getJspListFilePath(EdoBean bean) { String filename = StringUtils.uncapitalize(bean.getName()) + "-list.jsp"; String finalfile = getApsAdminJspFolder(bean) + bean.getName().toLowerCase() + File.separator + filename; return finalfile; }