Author: tfennelly
Date: 2009-12-02 07:51:13 -0500 (Wed, 02 Dec 2009)
New Revision: 18987
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties
Log:
Some changes for
https://jira.jboss.org/jira/browse/JBIDE-5311
Need to work with Dart on one part of it.
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-02
12:42:26 UTC (rev 18986)
+++
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-02
12:51:13 UTC (rev 18987)
@@ -80,53 +80,28 @@
if (editorPart instanceof SmooksGraphicalEditorPart) {
resourceListType = ((SmooksGraphicalEditorPart)
editorPart).getSmooksResourceListType();
}
- List<Object> models = createJavaBeanModel(type, wizard.getJavaBeanModel(),
wizard.getBindings(),
- 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>();
-
- if (collections instanceof FeatureMap.Entry) {
- for (Iterator<?> iterator = models.iterator(); iterator.hasNext();) {
- Object object = (Object) iterator.next();
- creationModels.add(FeatureMapUtil.createEntry(((FeatureMap.Entry) collections)
- .getEStructuralFeature(), object));
+
+ JavaBeanModel javaBeanModel = wizard.getJavaBeanModel();
+ if(javaBeanModel != null) {
+ List<Object> models = createJavaBeanModel(type, javaBeanModel,
wizard.getBindings(),
+ resourceListType, new ArrayList<String>());
+ String figureID = null;
+ int index = 0;
+ List<Object> creationModels = new ArrayList<Object>();
+
+ if (collections instanceof FeatureMap.Entry) {
+ for (Iterator<?> iterator = models.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ creationModels.add(FeatureMapUtil.createEntry(((FeatureMap.Entry) collections)
+ .getEStructuralFeature(), object));
+ }
}
+ collections = creationModels;
+
+ emfCommand = AddCommand.create(domain, owner, feature, creationModels);
+ } else {
+ // TODO: There is no "model" e.g. for a Collection type... what do we
do??
}
- collections = creationModels;
-
- emfCommand = AddCommand.create(domain, owner, feature, creationModels);
} else {
throw new IgnoreException();
}
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java 2009-12-02
12:42:26 UTC (rev 18986)
+++
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/JavaBeanCreationWizardPage.java 2009-12-02
12:51:13 UTC (rev 18987)
@@ -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
@@ -465,23 +465,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 +559,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 +577,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:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties 2009-12-02
12:42:26 UTC (rev 18986)
+++
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/messages.properties 2009-12-02
12:51:13 UTC (rev 18987)
@@ -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