Author: tfennelly
Date: 2009-12-03 05:05:32 -0500 (Thu, 03 Dec 2009)
New Revision: 19016
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-5311
Changes for the Java Bean Creation Wizard
Merged from CR1 Branch
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03
08:23:39 UTC (rev 19015)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03
10:05:32 UTC (rev 19016)
@@ -78,36 +78,6 @@
resourceListType, new ArrayList<String>());
String figureID = null;
int index = 0;
- // for (Iterator<?> iterator = models.iterator();
- // iterator.hasNext();) {
- // Object object = (Object) iterator.next();
- // if (object instanceof EObject) {
- // figureID =
- // SmooksGraphUtil.generateFigureIDViaModel((EObject)
- // object);
- // if (figureID != null && editorPart instanceof
- // SmooksGraphicalEditorPart) {
- // SmooksGraphicsExtType ext = ((SmooksGraphicalEditorPart)
- // editorPart)
- // .getSmooksGraphicsExtType();
- // GraphType graph = ext.getGraph();
- // if (graph != null) {
- // FigureType figureType =
- // SmooksGraphUtil.findFigureType(graph, figureID);
- // if (figureType == null) {
- // figureType = GraphFactory.eINSTANCE.createFigureType();
- // graph.getFigure().add(figureType);
- // figureType.setId(figureID);
- // }
- // String x = String.valueOf(this.x + index);
- // String y = String.valueOf(this.y + index);
- // figureType.setX(x);
- // figureType.setY(y);
- // index += 20;
- // }
- // }
- // }
- // }
List<Object> creationModels = new ArrayList<Object>();
@@ -143,7 +113,7 @@
if (parent instanceof BeanType) {
((BeanType) parent).setBeanId(beanID);
((BeanType) parent).setClass(parentBeanModel.getBeanClassString());
- if (properties != null) {
+ if (properties != null && properties.length > 0) {
for (int i = 0; i < properties.length; i++) {
Object pro = properties[i];
if (pro instanceof JavaBeanModel && belongsToMe(parentBeanModel,
(JavaBeanModel) pro)) {
@@ -167,6 +137,9 @@
}
}
}
+ } else if(parentBeanModel.isList()) {
+ WiringType value = Javabean12Factory.eINSTANCE.createWiringType();
+ ((BeanType) parent).getWiring().add(value);
}
}
// if (parent instanceof BindingsType) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java 2009-12-03
08:23:39 UTC (rev 19015)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java 2009-12-03
10:05:32 UTC (rev 19016)
@@ -125,7 +125,7 @@
createBeanClassControls(mainComposite);
- createBeanTypeControls(mainComposite);
+ //createBeanTypeControls(mainComposite);
Label seperator = new Label(mainComposite, SWT.HORIZONTAL
| SWT.SEPARATOR);
@@ -261,7 +261,7 @@
private void createBeanTypeControls(Composite mainComposite) {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ GridData gd;
Label beanTypeLabel = new Label(mainComposite, SWT.NONE);
beanTypeLabel
@@ -408,32 +408,17 @@
ProjectClassLoader loader = new ProjectClassLoader(project);
javaBeanModel = null;
isCollection = isCollectionClass(beanClass);
- if (isCollection) {
- if (collectionClass != null) {
- Class<?> clazz = loader.loadClass(beanClass);
- Class<?> cclazz = loader.loadClass(collectionClass);
- javaBeanModel = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(clazz);
- javaBeanModel.setComponentClass(cclazz);
- } else {
- viewer.setInput(""); //$NON-NLS-1$
- }
- } else {
- Class<?> clazz = loader.loadClass(beanClass);
- if (isArray) {
- Object arrayInstance = Array.newInstance(clazz, 0);
- clazz = arrayInstance.getClass();
- }
- javaBeanModel = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(clazz);
- }
+ Class<?> clazz = loader.loadClass(beanClass);
+
+ javaBeanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
if (javaBeanModel != null) {
if (beanID != null) {
javaBeanModel.setName(beanID);
}
- viewer.setInput(javaBeanModel.getChildren());
- viewer.setCheckedElements(javaBeanModel.getChildren()
- .toArray());
+ if(!isCollection) {
+ viewer.setInput(javaBeanModel.getChildren());
+ }
+ viewer.setCheckedElements(javaBeanModel.getChildren().toArray());
} else {
viewer.setInput(""); //$NON-NLS-1$
}
@@ -465,23 +450,11 @@
public void modifyText(ModifyEvent e) {
Text t = (Text) e.getSource();
- arrayButton.setEnabled(true);
beanClass = t.getText();
if (beanClass != null) {
beanClass = beanClass.trim();
}
isCollection = isCollectionClass(beanClass);
- if (isCollection) {
- isArray = false;
- arrayButton.setSelection(false);
- arrayButton.setEnabled(false);
- collectionClassBrowseButton.setEnabled(true);
- colllectionClassText.setEnabled(true);
- } else {
- collectionClassBrowseButton.setEnabled(false);
- colllectionClassText.setEnabled(false);
- colllectionClassText.setText(""); //$NON-NLS-1$
- }
refreshJavaBeanModel();
updateWizardPageStatus();
}
@@ -571,14 +544,14 @@
ProjectClassLoader loader = new ProjectClassLoader(project);
Class<?> clazz = loader.loadClass(beanClass);
if (Modifier.isAbstract(clazz.getModifiers())) {
- error = "The class can't be abstract";
+ error = "Class is Abstract. Cannot be instantiated.";
} else {
try {
- Constructor<?> constructor = clazz.getConstructor(null);
+ clazz.getConstructor(null);
} catch (SecurityException e) {
- error = "The class can't be instanced";
+ error = "Unable to determine if the class can be instantiated.";
} catch (NoSuchMethodException e) {
- error = "The class can't be instanced";
+ error = "Class does not have a Public Default Constructor.";
}
}
} catch (JavaModelException e) {
@@ -589,34 +562,6 @@
}
}
- if (isCollection) {
- if (collectionClass == null || "".equals(collectionClass.trim())) {
//$NON-NLS-1$
- error =
Messages.JavaBeanCreationWizardPage_CollectionComponentClassEmptyErrorMessage;
- } else {
- try {
- ProjectClassLoader loader = new ProjectClassLoader(project);
- Class<?> clazz = loader.loadClass(collectionClass);
- if (Modifier.isAbstract(clazz.getModifiers())) {
- error = "The collection component class can't be abstract";
- } else {
- try {
- Constructor<?> constructor = clazz
- .getConstructor(null);
- } catch (SecurityException e) {
- error = "The collection component class can't be instanced";
- } catch (NoSuchMethodException e) {
- error = "The collection component class can't be instanced";
- }
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- error = Messages.JavaBeanCreationWizardPage_CatFindClassErrorMessage1
- + beanClass;
- }
- }
- }
-
this.setErrorMessage(error);
this.setPageComplete(error == null);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties 2009-12-03
08:23:39 UTC (rev 19015)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties 2009-12-03
10:05:32 UTC (rev 19016)
@@ -1,7 +1,7 @@
JavaBeanCreationWizardPage_27="
JavaBeanCreationWizardPage_ArrayButtonText=Array
-JavaBeanCreationWizardPage_BeanClassEmptyErrorMessage=Bean Class is empty
-JavaBeanCreationWizardPage_BeanClassLabel=Bean Class :
+JavaBeanCreationWizardPage_BeanClassEmptyErrorMessage=Java Class must be configured
+JavaBeanCreationWizardPage_BeanClassLabel=Java Class :
JavaBeanCreationWizardPage_BeanIDDuplicateErrorMessage1=Bean ID '
JavaBeanCreationWizardPage_BeanIDDuplicateErrorMessage2=' is duplicate
JavaBeanCreationWizardPage_BeanIDEmptyErrorMessage=Bean ID is empty
@@ -12,5 +12,5 @@
JavaBeanCreationWizardPage_CollectionButtonLabel=Collection
JavaBeanCreationWizardPage_CollectionClassLabel=Collection Class :
JavaBeanCreationWizardPage_CollectionComponentClassEmptyErrorMessage=Colletion component
class is empty
-JavaBeanCreationWizardPage_WizardDes=Create a Java Bean model
-JavaBeanCreationWizardPage_WizardTitle=Java Bean Creation
+JavaBeanCreationWizardPage_WizardDes=Add a Java Bean instance to the Smooks Bean Context
+JavaBeanCreationWizardPage_WizardTitle=Add Java Bean Instance