Author: DartPeng
Date: 2008-10-29 03:19:52 -0400 (Wed, 29 Oct 2008)
New Revision: 11264
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
Log:
JBIDE-2992
add new check actions for the xml2java analyzer.
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2008-10-28
21:57:00 UTC (rev 11263)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2008-10-29
07:19:52 UTC (rev 11264)
@@ -27,8 +27,8 @@
super();
Assert.isNotNull(error);
this.error = error;
- while(error != null && error instanceof InvocationTargetException){
- error = ((InvocationTargetException)error).getTargetException();
+ while(this.error != null && this.error instanceof InvocationTargetException){
+ this.error = ((InvocationTargetException)this.error).getTargetException();
}
}
@@ -57,7 +57,9 @@
.get(SmooksGraphConstants.IMAGE_ERROR));
Label messageLabel = new Label(errorComposite, SWT.NONE);
- messageLabel.setText(error.getLocalizedMessage());
+ String errorMessage = error.getLocalizedMessage();
+ if(errorMessage == null ) errorMessage = "unknown error happen";
+ messageLabel.setText(errorMessage);
gd = new GridData(GridData.FILL_HORIZONTAL);
messageLabel.setLayoutData(gd);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-28
21:57:00 UTC (rev 11263)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-29
07:19:52 UTC (rev 11264)
@@ -1289,7 +1289,7 @@
SWT.NONE);
Menu menu = new Menu(getSite().getShell(), SWT.POP_UP);
List<ResolveCommand> list = result.getResolveProblem();
- for (Iterator iterator2 = list.iterator(); iterator2.hasNext();) {
+ for (Iterator<ResolveCommand> iterator2 = list.iterator();
iterator2.hasNext();) {
final ResolveCommand resolveCommand = (ResolveCommand) iterator2
.next();
MenuItem item = new MenuItem(menu, SWT.NONE);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-10-28
21:57:00 UTC (rev 11263)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-10-29
07:19:52 UTC (rev 11264)
@@ -2,7 +2,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -15,7 +14,6 @@
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.layout.FillLayout;
@@ -165,29 +163,70 @@
TargetModel targetModel = (TargetModel) iterator.next();
Object refObj = targetModel.getReferenceEntityModel();
if (refObj instanceof JavaBeanModel) {
- Class clazz = ((JavaBeanModel) refObj).getBeanClass();
- if (clazz != null && (clazz.isInterface())) {
- DesignTimeAnalyzeResult result = new DesignTimeAnalyzeResult();
- result
- .setErrorMessage("Java model \""
- + ((JavaBeanModel) refObj).getName()
- + "\" can't be instanced case its instance class is interface or
abstractclass");
- if (List.class.isAssignableFrom(clazz)) {
+ if (!targetModel.getModelTargetConnections().isEmpty()) {
+ String instanceName = ((JavaBeanModel) refObj)
+ .getBeanClassString();
+ Class instanceClazz = null;
+ if(((JavaBeanModel) refObj).isPrimitive()) {
+ // TODO process primitive type
+ continue;
+ }
+ String errorMessage = "";
+ try {
+ ClassLoader loader = newProjectClassLoader(context
+ .getSmooksConfigFile());
+ instanceClazz = loader.loadClass(instanceName);
+ } catch (Exception e) {
+ errorMessage = e.toString();
+ }
+ if (instanceClazz == null) {
+ DesignTimeAnalyzeResult result = new DesignTimeAnalyzeResult();
+ result.setErrorMessage("The instance class of \""
+ + ((JavaBeanModel) refObj).getName()
+ + "\" can't be loaded. Instance name is \"" +
instanceName + "\"");
JavaModelResolveCommand command = new JavaModelResolveCommand(
context);
command
- .setResolveDescription("Change the instance class to
\"java.util.ArrayList\"");
- command.setInstanceName("java.util.ArrayList");
+ .setResolveDescription("Change the instance class to \""
+ + ((JavaBeanModel) refObj)
+ .getBeanClass()
+ .getCanonicalName() + "\"");
+ command.setInstanceName(((JavaBeanModel)
refObj).getBeanClass().getCanonicalName());
command.setJavaBean((JavaBeanModel) refObj);
result.addResolveCommand(command);
+ resultList.add(result);
}
- resultList.add(result);
+ if (instanceClazz != null && instanceClazz.isInterface()) {
+ DesignTimeAnalyzeResult result = new DesignTimeAnalyzeResult();
+ result
+ .setErrorMessage("Java model \""
+ + ((JavaBeanModel) refObj).getName()
+ + "\" can't be instanced. Instance name is \"" +
instanceName + "\"");
+ if (List.class.isAssignableFrom(instanceClazz)) {
+ JavaModelResolveCommand command = new JavaModelResolveCommand(
+ context);
+ command
+ .setResolveDescription("Change the instance class to
\"java.util.ArrayList\"");
+ command.setInstanceName("java.util.ArrayList");
+ command.setJavaBean((JavaBeanModel) refObj);
+ result.addResolveCommand(command);
+ }
+ resultList.add(result);
+ }
}
}
}
return resultList;
}
+ public static ClassLoader newProjectClassLoader(IFile file)
+ throws Exception {
+ IProject p = file.getProject();
+ IJavaProject jp = JavaCore.create(p);
+ ProjectClassLoader loader = new ProjectClassLoader(jp);
+ return loader;
+ }
+
public static Status createErrorStatus(Throwable throwable, String message) {
while (throwable != null
&& throwable instanceof InvocationTargetException) {
Show replies by date