Author: DartPeng
Date: 2009-06-19 01:31:30 -0400 (Fri, 19 Jun 2009)
New Revision: 16061
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_uncheck.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertiesProposalProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SelectorValidator.java
Log:
JBIDE-4511
done
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif
===================================================================
(Binary files differ)
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_checked.gif 2009-06-19
05:31:30 UTC (rev 16061)
@@ -0,0 +1,4 @@
+GIF89a
+�MЀ
+
+���""#�%%$�M�H��GA
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/checkbox_uncheck.gif
===================================================================
(Binary files differ)
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -45,7 +45,6 @@
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModel;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModelFactory;
-import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import
org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
@@ -243,7 +242,6 @@
if (extType != null) {
IJavaProject project = SmooksUIUtils.getJavaProject(extType);
try {
- ProjectClassLoader classLoader = new ProjectClassLoader(project);
List<InputType> inputLists = extType.getInput();
for (Iterator<?> iterator = inputLists.iterator(); iterator.hasNext();) {
InputType inputType = (InputType) iterator.next();
@@ -253,8 +251,8 @@
path = path.trim();
if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
try {
- JavaBeanModel model =
JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(classLoader
- .loadClass(path));
+ Class<?> clazz = SmooksUIUtils.loadClass(path, project);
+ JavaBeanModel model = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
if (model != null) {
list.add(model);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -16,6 +16,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -137,6 +138,14 @@
String s = clazz.getComponentType().getName();
return s + "[]"; //$NON-NLS-1$
}
+// if(this.isList()){
+// String cs = "<"+System.currentTimeMillis()+">";
+// Class componentClazz = this.getComponentClass();
+// if(componentClazz != null){
+// cs = "<" + componentClazz.getName() +">";
+// }
+// return clazz.getName() + cs;
+// }
return clazz.getName();
}
@@ -172,9 +181,23 @@
Type returnType = rmethod.getGenericReturnType();
if (returnType instanceof ParameterizedType) {
Type gtype = ((ParameterizedType) returnType).getActualTypeArguments()[0];
- Class beanType = (Class) gtype;
- componentClass = beanType;
- setGenericType(true);
+ if(gtype instanceof Class){
+ Class beanType = (Class) gtype;
+ componentClass = beanType;
+ setGenericType(true);
+ }
+ if(gtype instanceof WildcardType){
+ Type[] upperBounds = ((WildcardType)gtype).getUpperBounds();
+ Type[] lowerBounds = ((WildcardType)gtype).getLowerBounds();
+ if(upperBounds.length != 0){
+ componentClass = (Class<?>) upperBounds[0];
+ setGenericType(true);
+ }
+ if(lowerBounds.length != 0){
+ componentClass = (Class<?>) lowerBounds[0];
+ setGenericType(true);
+ }
+ }
}
}
}
@@ -509,6 +532,10 @@
}
public Object getID() {
+ Class<?> clazz = getBeanClass();
+ if(Collection.class.isAssignableFrom(clazz)){
+ return getBeanClassString() + getName();
+ }
return getBeanClass();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -15,15 +15,14 @@
import java.util.ArrayList;
import java.util.List;
-
/**
* @author Dart Peng
*
*/
public class JavaBeanModelFactory {
-
+
private static final List<Object> PRIMITIVE_CLASSES = new
ArrayList<Object>();
- static{
+ static {
PRIMITIVE_CLASSES.add(Integer.class);
PRIMITIVE_CLASSES.add(Double.class);
PRIMITIVE_CLASSES.add(Float.class);
@@ -37,25 +36,25 @@
PRIMITIVE_CLASSES.add(Byte.class);
PRIMITIVE_CLASSES.add(java.util.Calendar.class);
}
-
+
/**
* @param beanClass
* @param modelName
* @return
*/
- public synchronized static JavaBeanModel getJavaBeanModelWithLazyLoad(Class<?>
beanClass ) {
- JavaBeanModel m = new JavaBeanModel(beanClass,true);
+ public synchronized static JavaBeanModel getJavaBeanModelWithLazyLoad(Class<?>
beanClass) {
+ JavaBeanModel m = new JavaBeanModel(beanClass, true);
m.setRootClassModel(true);
return m;
}
-
+
/**
* @deprecated
* @param beanClass
* @return
*/
- public synchronized static JavaBeanModel getJavaBeanModel(Class<?> beanClass ) {
- JavaBeanModel m = new JavaBeanModel(beanClass,false);
+ public synchronized static JavaBeanModel getJavaBeanModel(Class<?> beanClass) {
+ JavaBeanModel m = new JavaBeanModel(beanClass, false);
m.setRootClassModel(true);
return m;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -140,7 +140,7 @@
gd.horizontalSpan = 2;
listViewerComposite.setLayoutData(gd);
- listViewer = new TableViewer(listViewerComposite, SWT.BORDER);
+ listViewer = new TableViewer(listViewerComposite, SWT.BORDER |SWT.FULL_SELECTION);
TableColumn nameColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
nameColumn.setText("Class");
TableColumn isArrayColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -41,6 +41,7 @@
import org.jboss.tools.smooks.configuration.editors.uitls.IFieldDialog;
import org.jboss.tools.smooks.configuration.editors.uitls.IModelProcsser;
import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -61,34 +62,24 @@
public Object open(Shell shell) {
String errorMessage = "";
- if(project == null){
+ if (project == null) {
errorMessage = "Please make sure the project is the 'Java
Project'";
}
try {
if (project != null && className != null) {
- Class<?> clazz = null;
- ProjectClassLoader classLoader;
-
- classLoader = new ProjectClassLoader(project);
-
- if (className.endsWith("[]")) {
- String arrayClassName = className.substring(0, className.length() - 2);
- clazz = classLoader.loadClass(arrayClassName);
- Object arrayInstance = Array.newInstance(clazz, 0);
- clazz = arrayInstance.getClass();
- } else {
- clazz = classLoader.loadClass(className);
- }
- JavaBeanModel beanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
- PropertySelectionDialog dialog = new PropertySelectionDialog(shell, project,
beanModel);
- if (dialog.open() == Dialog.OK) {
- JavaBeanModel pd = (JavaBeanModel) dialog.getCurrentSelection();
- if(pd == null){
+ Class<?> clazz = SmooksUIUtils.loadClass(className, project);
+ if (clazz != null) {
+ JavaBeanModel beanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ PropertySelectionDialog dialog = new PropertySelectionDialog(shell, project,
beanModel);
+ if (dialog.open() == Dialog.OK) {
+ JavaBeanModel pd = (JavaBeanModel) dialog.getCurrentSelection();
+ if (pd == null) {
+ return null;
+ }
+ return pd.getName();
+ } else {
return null;
}
- return pd.getName();
- } else {
- return null;
}
}
} catch (JavaModelException e) {
@@ -96,7 +87,8 @@
} catch (ClassNotFoundException e) {
errorMessage = "'" + className + "' can't be found.";
}
- MessageDialog.openInformation(shell, "Can't open dialog", "Can't
get properties of '" + className + "'.\n" + errorMessage);
+ MessageDialog.openInformation(shell, "Can't open dialog", "Can't
get properties of '" + className + "'.\n"
+ + errorMessage);
return null;
}
@@ -128,7 +120,7 @@
fl.marginHeight = 10;
fl.marginWidth = 10;
composite.setLayout(fl);
- viewer = new TableViewer(composite, SWT.BORDER|SWT.FULL_SELECTION);
+ viewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
Table table = viewer.getTable();
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
nameColumn.setWidth(100);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -21,7 +21,6 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IEditorInput;
@@ -142,8 +141,8 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
if (selection != null) {
Object obj = selection.getFirstElement();
- if (obj instanceof JavaProject) {
- this.project = (JavaProject) obj;
+ if (obj instanceof IJavaProject) {
+ this.project = (IJavaProject) obj;
}
if (obj instanceof IResource) {
IProject project = ((IResource) obj).getProject();
@@ -169,7 +168,15 @@
JavaBeanModel javaBeanModel = (JavaBeanModel) iterator.next();
Class<?> clazz = javaBeanModel.getBeanClass();
if (clazz != null) {
- buffer.append(clazz.getName());
+ boolean isArray = "array".equals(javaBeanModel
+ .getExtendProperty("many"));
+// boolean isList = "list".equals(javaBeanModel
+// .getExtendProperty("many"));
+ String cname = clazz.getName();
+ if(isArray){
+ cname = cname+ "[]";
+ }
+ buffer.append(cname);
}
}
return buffer.toString();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertiesProposalProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertiesProposalProvider.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertiesProposalProvider.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -35,19 +35,7 @@
public JavaPropertiesProposalProvider(IProject project,String className){
try {
if (project != null && className != null) {
- Class<?> clazz = null;
- ProjectClassLoader classLoader;
-
- classLoader = new ProjectClassLoader(JavaCore.create(project));
-
- if (className.endsWith("[]")) {
- String arrayClassName = className.substring(0, className.length() - 2);
- clazz = classLoader.loadClass(arrayClassName);
- Object arrayInstance = Array.newInstance(clazz, 0);
- clazz = arrayInstance.getClass();
- } else {
- clazz = classLoader.loadClass(className);
- }
+ Class<?> clazz = SmooksUIUtils.loadClass(className, project);
beanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
}
} catch (JavaModelException e) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
@@ -401,7 +402,7 @@
}
public static String parseFilePath(String path) throws InvocationTargetException {
- if(new File(path).exists()){
+ if (new File(path).exists()) {
return path;
}
int index = path.indexOf(FILE_PRIX);
@@ -771,14 +772,30 @@
return fieldEditPart;
}
- public static Class<?> loadClass(String className, IResource resource) throws
JavaModelException,
+ public static Class<?> loadClass(String className, Object resource) throws
JavaModelException,
ClassNotFoundException {
if (resource == null)
return null;
-
- IProject project = resource.getProject();
- if (project != null) {
- ProjectClassLoader loader = new ProjectClassLoader(JavaCore.create(project));
+ IJavaProject jp = null;
+ if (resource instanceof IJavaProject) {
+ jp = (IJavaProject) resource;
+ }
+ if (resource instanceof IResource) {
+ IProject project = ((IResource) resource).getProject();
+ if (project != null) {
+ jp = JavaCore.create(project);
+ }
+ }
+ if (jp != null) {
+ ProjectClassLoader loader = new ProjectClassLoader(jp);
+ if(className.endsWith("[]")){
+ className = className.substring(0,className.length() - 2);
+ Class<?> clazz = loader.loadClass(className);
+ Object arrayInstance = Array.newInstance(clazz, 0);
+ clazz = arrayInstance.getClass();
+ arrayInstance = null;
+ return clazz;
+ }
return loader.loadClass(className);
}
@@ -1935,7 +1952,11 @@
if (usedNodeMap.get(child.getID()) != null) {
continue;
}
- result = localXMLNodeWithNodeName(name, child, usedNodeMap);
+ try {
+ result = localXMLNodeWithNodeName(name, child, usedNodeMap);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
if (result != null) {
return result;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SelectorValidator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SelectorValidator.java 2009-06-19
02:41:43 UTC (rev 16060)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SelectorValidator.java 2009-06-19
05:31:30 UTC (rev 16061)
@@ -23,6 +23,7 @@
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.configuration.editors.SelectoreSelectionDialog;
import org.jboss.tools.smooks.configuration.editors.groovy.GroovyUICreator;
@@ -137,7 +138,7 @@
node = SmooksUIUtils
.localXMLNodeWithPath(path, (IXMLStructuredObject) obj, sperator, false);
} catch (Throwable e) {
- // ignore
+ SmooksConfigurationActivator.getDefault().log(e);
}
}
if (node != null) {