Author: DartPeng
Date: 2009-01-13 21:10:34 -0500 (Tue, 13 Jan 2009)
New Revision: 13025
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanLinePaintLitener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/LinePaintListener.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.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/ui/editors/SmooksNormalContentEditFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/CurveLineConnection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/ILineFigurePaintListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XML2XMLLinePaintListener.java
Log:
JBIDE-3429
change the graphical model and source page text when the page was changed
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-01-14 01:47:11 UTC (rev
13024)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-01-14 02:10:34 UTC (rev
13025)
@@ -266,5 +266,15 @@
sourceId="org.jboss.tools.smooks.xml.viewerInitor.xml"
targetId="org.jboss.tools.smooks.xml.viewerInitor.xml">
</linePaintListener>
+ <linePaintListener
+
class="org.jboss.tools.smooks.javabean.ui.JavaBeanLinePaintLitener"
+ sourceId="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </linePaintListener>
+ <linePaintListener
+
class="org.jboss.tools.smooks.javabean.ui.JavaBeanLinePaintLitener"
+ sourceId="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </linePaintListener>
</extension>
</plugin>
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -65,7 +65,7 @@
*/
public class JavaBeanAnalyzer implements IMappingAnalyzer,
ISourceModelAnalyzer, ITargetModelAnalyzer {
-
+
private ClassLoader currentClassLoader = null;
public static final String BEANPOPULATOR = "org.milyn.javabean.BeanPopulator";
//$NON-NLS-1$
@@ -184,7 +184,7 @@
public void setCurrentClassLoader(ClassLoader currentClassLoader) {
this.currentClassLoader = currentClassLoader;
}
-
+
private void setConnectionUsed(Object connection) {
usedConnectionList.add(connection);
}
@@ -441,6 +441,12 @@
*/
private void checkRootNodeConnected(
SmooksConfigurationFileGenerateContext context) {
+
+ // test
+
+ if (true)
+ return;
+
GraphRootModel root = context.getGraphicalRootModel();
List sourceList = root.loadSourceModelList();
List targetList = root.loadTargetModelList();
@@ -704,7 +710,7 @@
}
}
} else {
- sourceModel = findModelWithSelectorString(selector, source);
+ sourceModel = localJavaBeanModelWithSelector(selector, source);
}
if (sourceModel != null) {
MappingModel model = new MappingModel(sourceModel,
@@ -720,7 +726,7 @@
protected JavaBeanModel findModelWithResourceConfig(
ResourceConfigType config, JavaBeanModel parentModel) {
String newSelector = config.getSelector();
- JavaBeanModel model = findTheChildJavaBeanModel(newSelector,
+ JavaBeanModel model = localJavaBeanModelWithSelector(newSelector,
parentModel);
if (model == null) {
model = loadJavaBeanWithResourceConfig(config);
@@ -728,6 +734,56 @@
return model;
}
+ public static JavaBeanModel localJavaBeanModelWithSelector(String selector,
+ JavaBeanModel model) {
+ if (selector == null || model == null)
+ return null;
+ String[] selectors = selector.trim().split(SPACE_STRING);
+ if (selectors != null && selectors.length > 0) {
+ // to find the first node
+ String firstNode = selectors[0];
+ JavaBeanModel firstModel = localJavaBeanModelFromRootNode(
+ firstNode, model);
+ // first time , we search the node via context
+ if(firstModel == null){
+ firstModel = localJavaBeanModelFromRootNode(
+ firstNode, model.getRootParent());
+ }
+ // if we can't find the node , to find it from the Root Parent node
+ if (firstModel == null) {
+ throw new RuntimeException("Can't find the node : " +firstNode);
+ }
+ for (int i = 1; i < selectors.length; i++) {
+ firstModel = findTheChildJavaBeanModel(selectors[i], firstModel);
+ if (firstModel == null)
+ throw new RuntimeException("Can't find the node : "
+ + selectors[i] + " from parent node "
+ + selectors[i - 1]);
+ }
+
+ return firstModel;
+ }
+ return model;
+ }
+
+ public static JavaBeanModel localJavaBeanModelFromRootNode(String name,
+ JavaBeanModel rootParent) {
+ if (name == null || rootParent == null)
+ return null;
+ if (name.equalsIgnoreCase(rootParent.getSelectorString()))
+ return rootParent;
+
+ List children = rootParent.getProperties();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ JavaBeanModel result = localJavaBeanModelFromRootNode(name, child);
+ if (result != null)
+ return result;
+ }
+ return null;
+
+ }
+
protected JavaBeanModel findModelWithSelectorString(String selector,
JavaBeanModel parentModel) {
String[] s = selector.trim().split(SPACE_STRING);
@@ -848,9 +904,7 @@
} else {
model = new JavaBeanModel(null, rootClassName);
model.setRootClassModel(true);
- model
- .setError(Messages
- .getString("JavaBeanAnalyzer.ClassNotExist") + rootClassName);
//$NON-NLS-1$
+ model.setError(Messages.getString("JavaBeanAnalyzer.ClassNotExist") +
rootClassName); //$NON-NLS-1$
model.setProperties(new ArrayList());
isError = true;
}
@@ -872,13 +926,14 @@
// rootClassName = this.getDataSourceClass(graphInfo, TARGET_DATA);
// TODO if there isn't any BeanPopulater throws exception
// MODIFY by Dart 2008.11.17
- try{
- if (classLoader == null) {
- IProject project = sourceFile.getProject();
- classLoader = new ProjectClassLoader(JavaCore.create(project));
- }
- String classString = getDataSourceClass(graphInfo, TARGET_DATA);
- if (classString != null && classLoader != null) {
+ try {
+ if (classLoader == null) {
+ IProject project = sourceFile.getProject();
+ classLoader = new ProjectClassLoader(JavaCore
+ .create(project));
+ }
+ String classString = getDataSourceClass(graphInfo, SOURCE_DATA);
+ if (classString != null && classLoader != null) {
String[] classes = classString.split(";");
if (classes != null) {
for (int i = 0; i < classes.length; i++) {
@@ -889,13 +944,13 @@
}
return list;
}
- }
- }catch (ClassNotFoundException e) {
+ }
+ } catch (ClassNotFoundException e) {
// TODO if can't find the class throws exception
// MODIFY by Dart 2008.11.12
- throw new RuntimeException("Can't find the class : \""
- + rootClassName
- + "\" to create the JavaBean model");
+ // throw new RuntimeException("Can't find the class : \""
+ // + rootClassName
+ // + "\" to create the JavaBean model");
} catch (JavaModelException e) {
e.printStackTrace();
}
@@ -903,8 +958,8 @@
// "Can't load Java bean model form the config file.");
}
// if can't load the source from GraphicalInformation , return NULL
- if (current == null && rootClassName == null)
- return list;
+// if (current == null && rootClassName == null)
+// return list;
return list;
}
@@ -920,7 +975,7 @@
}
public Object buildSourceInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile , Object viewer )
+ SmooksResourceListType listType, IFile sourceFile, Object viewer)
throws InvocationTargetException {
UIUtils.checkSelector(listType);
return this.buildSourceInputObjects(graphInfo, listType, sourceFile,
@@ -928,7 +983,7 @@
}
public Object buildTargetInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile , Object viewer)
+ SmooksResourceListType listType, IFile sourceFile, Object viewer)
throws InvocationTargetException {
UIUtils.checkSelector(listType);
return this.buildTargetInputObjects(graphInfo, listType, sourceFile,
@@ -987,7 +1042,7 @@
return list;
}
} catch (Exception e) {
- throw new RuntimeException(e);
+ // throw new RuntimeException(e);
}
}
// throw new RuntimeException(
@@ -998,8 +1053,10 @@
return list;
int startIndex = resourceConfigList.indexOf(current);
for (int i = startIndex; i < resourceConfigList.size(); i++) {
- AbstractResourceConfig abstractRC = (AbstractResourceConfig)
resourceConfigList.get(i);
- if(!(abstractRC instanceof ResourceConfigType)) continue;
+ AbstractResourceConfig abstractRC = (AbstractResourceConfig) resourceConfigList
+ .get(i);
+ if (!(abstractRC instanceof ResourceConfigType))
+ continue;
ResourceConfigType resourceConfig = (ResourceConfigType) abstractRC;
ResourceType resourceType = resourceConfig.getResource();
String selector = resourceConfig.getSelector();
@@ -1197,8 +1254,9 @@
break;
}
String selector1 = rct.getSelector();
- if(selector1 != null) selector1 = selector1.trim();
- if(selector.equals(selector1)){
+ if (selector1 != null)
+ selector1 = selector1.trim();
+ if (selector.equals(selector1)) {
resourceConfig = rct;
break;
}
@@ -1222,8 +1280,7 @@
selector, listType);
if (resourceConfig != null && !resourceConfigIsUsed(resourceConfig)) {
String referenceSelector = resourceConfig.getSelector();
- JavaBeanModel model = findTheChildJavaBeanModel(
- referenceSelector, currentModel);
+ JavaBeanModel model = localJavaBeanModelWithSelector(referenceSelector,
currentModel);
// try to test the selector is can be loaded by classloader??
if (model == null) {
Class clazz = null;
@@ -1261,33 +1318,34 @@
}
} else {
selector = selector.trim();
- String[] properties = selector.split(SPACE_STRING);
- if (properties != null) {
- JavaBeanModel currentParent = currentModel;
- for (int i = 0; i < properties.length; i++) {
- String property = properties[i].trim();
- Class currentClazz = currentParent.getBeanClass();
- if (currentClazz != null
- && property.equals(currentClazz.getName())) {
-
- } else {
- JavaBeanModel pm = findTheChildJavaBeanModel(property,
- currentParent);
- if (pm != null) {
-
- } else {
- pm = new JavaBeanModel(null, property);
- pm.setProperties(new ArrayList());
- pm.setError(Messages
- .getString("JavaBeanAnalyzer.DontExist")); //$NON-NLS-1$
- currentParent.addProperty(pm);
- }
- currentParent = pm;
- }
- }
- } else {
- // if properties is null , how to process?
- }
+ localJavaBeanModelWithSelector(selector, currentModel);
+// String[] properties = selector.split(SPACE_STRING);
+// if (properties != null) {
+// JavaBeanModel currentParent = currentModel;
+// for (int i = 0; i < properties.length; i++) {
+// String property = properties[i].trim();
+// Class currentClazz = currentParent.getBeanClass();
+// if (currentClazz != null
+// && property.equals(currentClazz.getName())) {
+//
+// } else {
+// JavaBeanModel pm = findTheChildJavaBeanModel(property,
+// currentParent);
+// if (pm != null) {
+//
+// } else {
+// pm = new JavaBeanModel(null, property);
+// pm.setProperties(new ArrayList());
+// pm.setError(Messages
+// .getString("JavaBeanAnalyzer.DontExist")); //$NON-NLS-1$
+// currentParent.addProperty(pm);
+// }
+// currentParent = pm;
+// }
+// }
+// } else {
+// // if properties is null , how to process?
+// }
}
}
@@ -1329,7 +1387,7 @@
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
JavaBeanModel child = (JavaBeanModel) iterator.next();
- if (name.equals(child.getName())) {
+ if (name.equals(child.getSelectorString())) {
return child;
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.javabean.commandprocessor;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.command.Command;
@@ -20,10 +21,15 @@
import org.jboss.tools.smooks.ui.gef.commandprocessor.ICommandProcessor;
import org.jboss.tools.smooks.ui.gef.commands.CreateConnectionCommand;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
import org.jboss.tools.smooks.ui.gef.model.IConnectableModel;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
+import org.jboss.tools.smooks.ui.gef.model.TargetModel;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
import org.jboss.tools.smooks.utils.UIUtils;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+import org.jboss.tools.smooks.xml.model.TagList;
/**
* @author Dart Peng
@@ -52,8 +58,11 @@
.getReferenceEntityModel();
Object t = ((AbstractStructuredDataModel) m)
.getReferenceEntityModel();
+ List connections = ((IConnectableModel) m).getModelTargetConnections();
+ if(connections.size() > 0) return false;
if (source instanceof JavaBeanModel
&& t instanceof JavaBeanModel) {
+
JavaBeanModel sourceModel = (JavaBeanModel) source;
JavaBeanModel targetModel = (JavaBeanModel) t;
boolean sis = ((JavaBeanModel) source).isPrimitive();
@@ -61,6 +70,7 @@
if ((sis && !tis) || (!sis && tis)) {
return false;
}
+
Class sourceClass = sourceModel.getBeanClass();
Class targetClass = targetModel.getBeanClass();
boolean isCompositeSource = sourceClass.isArray()
@@ -69,7 +79,8 @@
boolean isCompositeTarget = targetClass.isArray()
|| Collection.class
.isAssignableFrom(targetClass);
- if(isCompositeSource != isCompositeTarget) return false;
+ if (isCompositeSource != isCompositeTarget)
+ return false;
}
}
@@ -106,9 +117,11 @@
.getReferenceEntityModel();
Object t = ((AbstractStructuredDataModel) m)
.getReferenceEntityModel();
+ if (t instanceof JavaBeanModel) {
+ target = (JavaBeanModel) t;
+ }
if (!UIUtils.isInstanceCreatingConnection(source, t)) {
if (t instanceof JavaBeanModel) {
- target = (JavaBeanModel) t;
Class clazz = ((JavaBeanModel) t).getBeanClass();
if (clazz != null && clazz != String.class) {
PropertyModel property = new PropertyModel();
@@ -122,6 +135,10 @@
}
CompoundCommand compoundCommand = new CompoundCommand();
+ CreateConnectionCommand connectRootNodeCommand = connectRootNode(
+ source, target, context);
+ if (connectRootNodeCommand != null)
+ connectRootNodeCommand.execute();
fillCreateParentLinkCommand(compoundCommand, source, target,
context);
if (!compoundCommand.isEmpty()) {
@@ -131,6 +148,76 @@
return true;
}
+ private CreateConnectionCommand connectRootNode(Object source,
+ Object target, SmooksConfigurationFileGenerateContext context) {
+ JavaBeanModel javaBeanTarget = (JavaBeanModel) target;
+ Object sourceModel = source;
+
+ JavaBeanModel targetRoot = javaBeanTarget.getParent();
+ JavaBeanModel tempTargetRoot = targetRoot;
+ while (tempTargetRoot != null) {
+ targetRoot = tempTargetRoot;
+ tempTargetRoot = tempTargetRoot.getParent();
+ }
+ Object sourceRoot = null;
+ if (sourceModel instanceof JavaBeanModel) {
+ sourceRoot = ((JavaBeanModel) sourceModel).getParent();
+ JavaBeanModel sourceTempRoot = (JavaBeanModel) sourceRoot;
+ while (sourceTempRoot != null) {
+ sourceRoot = sourceTempRoot;
+ sourceTempRoot = ((JavaBeanModel) sourceTempRoot).getParent();
+ }
+ }
+
+ if (sourceModel instanceof AbstractXMLObject) {
+ sourceRoot = ((AbstractXMLObject) sourceModel).getParent();
+ AbstractXMLObject tempParent = ((AbstractXMLObject) sourceRoot)
+ .getParent();
+ while (!(tempParent instanceof TagList)) {
+ sourceRoot = tempParent;
+ tempParent = tempParent.getParent();
+ }
+ }
+ GraphRootModel graphRoot = context.getGraphicalRootModel();
+ if (sourceRoot == null || targetRoot == null)
+ return null;
+ AbstractStructuredDataModel graphSourceRoot = UIUtils.findGraphModel(
+ graphRoot, sourceRoot);
+ AbstractStructuredDataModel graphTargetRoot = UIUtils.findGraphModel(
+ graphRoot, targetRoot);
+
+ List<TargetModel> graphTargetList = graphRoot.loadTargetModelList();
+ boolean isConnected = false;
+ for (Iterator iterator = graphTargetList.iterator(); iterator.hasNext();) {
+ TargetModel targetModel = (TargetModel) iterator.next();
+ if (targetModel == graphTargetRoot) {
+ List connections = targetModel.getModelTargetConnections();
+ for (Iterator iterator2 = connections.iterator(); iterator2
+ .hasNext();) {
+ Object object = (Object) iterator2.next();
+ if (object instanceof LineConnectionModel) {
+ Object cs = ((LineConnectionModel) object).getSource();
+ if (cs == graphSourceRoot) {
+ isConnected = true;
+ break;
+ }
+ }
+ }
+ }
+ if (isConnected)
+ break;
+ }
+
+ if (!isConnected) {
+ CreateConnectionCommand connectionCommand = new CreateConnectionCommand();
+ connectionCommand.setSource(graphSourceRoot);
+ connectionCommand.setTarget(graphTargetRoot);
+ return connectionCommand;
+ }
+
+ return null;
+ }
+
private void fillCreateParentLinkCommand(CompoundCommand compoundCommand,
Object source, JavaBeanModel target,
SmooksConfigurationFileGenerateContext context) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -18,6 +18,7 @@
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -221,6 +222,8 @@
public boolean isPrimitive() {
Class beanType = getBeanClass();
+ if (beanType == null)
+ return false;
if (beanType.isPrimitive()
|| JavaBeanModelFactory.isPrimitiveObject(beanType)) {
if (!isArray() && !isList())
@@ -307,7 +310,7 @@
}
}
if (beanType == null)
- return null;
+ return Collections.EMPTY_LIST;
PropertyDescriptor[] pds = JavaPropertyUtils
.getPropertyDescriptor(beanType);
@@ -321,11 +324,11 @@
Type returnType = rmethod.getGenericReturnType();
if (returnType instanceof ParameterizedType) {
Type[] types = ((ParameterizedType) returnType)
- .getActualTypeArguments();
- if(types == null || types.length == 0){
+ .getActualTypeArguments();
+ if (types == null || types.length == 0) {
continue;
}
- }else{
+ } else {
continue;
}
}
@@ -377,6 +380,17 @@
this.error = error;
}
+ public JavaBeanModel getRootParent() {
+ JavaBeanModel parent = this.getParent();
+ if(parent == null) return this;
+ JavaBeanModel temp = parent;
+ while(temp != null){
+ parent = temp;
+ temp = temp.getParent();
+ }
+ return parent;
+ }
+
/*
* (non-Javadoc)
*
@@ -399,6 +413,18 @@
}
return buffer.toString();
}
+
+ public String getSelectorString(){
+ if(parent == null){
+ return getBeanClassString();
+ }
+
+ if(parent.isArray() || parent.isList()){
+ return getBeanClassString();
+ }
+ return getName();
+
+ }
public boolean hasGenericType() {
return hasGenericType;
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanLinePaintLitener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanLinePaintLitener.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanLinePaintLitener.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -0,0 +1,99 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.javabean.ui;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.ui.gef.figures.LinePaintListener;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
+import org.jboss.tools.smooks.ui.gef.model.IConnectableModel;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.model.TreeItemRelationModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class JavaBeanLinePaintLitener extends LinePaintListener {
+
+ @Override
+ public void drawLineAdditions(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+ ((Shape) hostFigure).setLineStyle(Graphics.LINE_SOLID);
+ AbstractStructuredDataModel targetModel = (AbstractStructuredDataModel) model
+ .getTarget();
+ JavaBeanModel targetTransformModel = (JavaBeanModel) targetModel
+ .getReferenceEntityModel();
+ IConnectableModel source = model.getSource();
+ IConnectableModel target = model.getTarget();
+ boolean collapse = false;
+ if (source instanceof TreeItemRelationModel) {
+ if (((TreeItemRelationModel) source).isCollapse()) {
+ collapse = true;
+ }
+ }
+ if (target instanceof TreeItemRelationModel) {
+ if (((TreeItemRelationModel) target).isCollapse()) {
+ collapse = true;
+ }
+ }
+ if (targetTransformModel.isPrimitive()) {
+ graphics.setForegroundColor(ColorConstants.orange);
+ if (collapse) {
+ graphics.setAlpha(100);
+ } else {
+ graphics.setAlpha(255);
+ }
+ }
+ }
+
+ @Override
+ public void drawLineSourceLocator(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+ AbstractStructuredDataModel targetModel = (AbstractStructuredDataModel) model
+ .getTarget();
+ JavaBeanModel targetTransformModel = (JavaBeanModel) targetModel
+ .getReferenceEntityModel();
+ if (targetTransformModel.isPrimitive()) {
+ drawBindingSourceLocator(graphics, hostFigure);
+ return;
+ }
+ super.drawLineSourceLocator(graphics, hostFigure, model);
+ }
+
+ @Override
+ public void drawLineTargetLocator(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+ AbstractStructuredDataModel targetModel = (AbstractStructuredDataModel) model
+ .getTarget();
+ JavaBeanModel targetTransformModel = (JavaBeanModel) targetModel
+ .getReferenceEntityModel();
+ if (targetTransformModel.isPrimitive()) {
+ drawBindingTargetLocator(graphics, hostFigure);
+ return;
+ }
+ super.drawLineTargetLocator(graphics, hostFigure, model);
+ }
+
+ private void drawValueLine(Graphics graphics, IFigure hostFigure) {
+
+ }
+
+ private void drawBindingSourceLocator(Graphics graphics, IFigure hostFigure) {
+ graphics.setBackgroundColor(ColorConstants.gray);
+ Rectangle rect = hostFigure.getBounds();
+ graphics.fillRectangle(rect.x + 2 ,rect.y + 2 ,6,6);
+ }
+
+ private void drawBindingTargetLocator(Graphics graphics, IFigure hostFigure) {
+ graphics.setBackgroundColor(ColorConstants.gray);
+ Rectangle rect = hostFigure.getBounds();
+ graphics.fillRectangle(rect.x + 5 ,rect.y + 2 ,6,6);
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanLinePaintLitener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -591,6 +591,8 @@
if(disableMappingGUI){
analyzeResultList.clear();
updateNotifyMessage();
+ }else{
+ analyzeDesignGraph();
}
}
@@ -626,6 +628,14 @@
mappingGUISection.setEnabled(false);
this.notifyAnalyzeListeners(throwable);
}
+
+ // show/unshow the problem panel
+ if(disableMappingGUI){
+ analyzeResultList.clear();
+ updateNotifyMessage();
+ }else{
+ analyzeDesignGraph();
+ }
}
protected void initMappingGUIStates() {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -203,7 +203,9 @@
if (this.getModelPackage() != null) {
List list = modelPackage.getSmooksResourceList()
.getAbstractResourceConfig();
- fileViewer.setInput(list);
+ if (fileViewer != null) {
+ fileViewer.setInput(list);
+ }
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
Object sr = iterator.next();
if (sr instanceof ResourceConfigType) {
@@ -462,9 +464,9 @@
if (files != null) {
IPath path1 = files[0].getFullPath().removeFirstSegments(1);
String s = path1.toString();
- if(s.startsWith("/") || s.startsWith("\\")){
-
- }else{
+ if (s.startsWith("/") || s.startsWith("\\")) {
+
+ } else {
s = "/" + s;
}
((ImportType) obj).setFile("classpath:" + s);
@@ -492,13 +494,13 @@
IFile[] files = WorkspaceResourceDialog.openFileSelection(getSite()
.getShell(), "Select Files", "", false, null,
Collections.EMPTY_LIST);
- if (files != null) {
+ if (files != null && files.length > 0) {
ImportType fileImport = SmooksFactory.eINSTANCE.createImportType();
IPath path1 = files[0].getFullPath().removeFirstSegments(1);
String s = path1.toString();
- if(s.startsWith("/") || s.startsWith("\\")){
-
- }else{
+ if (s.startsWith("/") || s.startsWith("\\")) {
+
+ } else {
s = "/" + s;
}
fileImport.setFile("classpath:" + s);
@@ -567,11 +569,13 @@
.getMappingResourceConfigList();
// for make sure that the SmooksResourceConfig model was the same :
if (rclist != null) {
- List<ResourceConfigType> renderList =
rclist.getGraphRenderResourceConfigList();
- if(renderList != null && renderList.size() > 0){
+ List<ResourceConfigType> renderList = rclist
+ .getGraphRenderResourceConfigList();
+ if (renderList != null && renderList.size() > 0) {
ResourceConfigType resourceConfig = renderList.get(0);
- SmooksResourceListType rootList = (SmooksResourceListType)
resourceConfig.eContainer();
- if(! (rootList == pa.getSmooksResourceList())){
+ SmooksResourceListType rootList = (SmooksResourceListType) resourceConfig
+ .eContainer();
+ if (!(rootList == pa.getSmooksResourceList())) {
pa.setSmooksResourceList(rootList);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/editparts/StructuredDataConnectionEditPart.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -97,19 +97,17 @@
protected IFigure createFigure() {
CurveLineConnection conn = new CurveLineConnection(this) {
- public void paintClientArea(Graphics graphics) {
-
+
+ public void paintFigure(Graphics graphics) {
String sourceid = getSourceDataTypeID();
String targetid = getTargetDataTypeID();
ILineFigurePaintListener listener = LineFigurePaintListenerManager
.getInstance().getPaintListener(sourceid, targetid);
-// graphics.pushState();
if (listener != null) {
- listener.drawLineAdditions(graphics,this,
+ listener.drawLineAdditions(graphics, this,
(LineConnectionModel) getHostEditPart().getModel());
}
-// graphics.popState();
- super.paintClientArea(graphics);
+ super.paintFigure(graphics);
}
};
// conn.setSmoothness(SmoothPolyLineConnection.SMOOTH_MORE);
@@ -122,19 +120,15 @@
@Override
public void paint(Graphics graphics) {
graphics.pushState();
- graphics.setBackgroundColor(GraphicsConstants.groupHeaderColor);
- Point p = getBounds().getTopLeft();
- Point p2 = getBounds().getBottomLeft();
- Point p3 = getBounds().getTopRight();
- p3 = new Point(p3.x, p3.y + getSize().height / 2);
- PointList pointList = new PointList();
- pointList.addPoint(p);
- pointList.addPoint(p2.x, p2.y - 1);
- pointList.addPoint(p3);
- graphics.fillPolygon(pointList);
- graphics.drawPolygon(pointList);
- graphics.popState();
+ String sourceid = getSourceDataTypeID();
+ String targetid = getTargetDataTypeID();
+ ILineFigurePaintListener listener = LineFigurePaintListenerManager
+ .getInstance().getPaintListener(sourceid, targetid);
+ if (listener != null) {
+ listener.drawLineTargetLocator(graphics, this,(LineConnectionModel) getModel());
+ }
super.paint(graphics);
+ graphics.popState();
}
};
@@ -149,21 +143,15 @@
@Override
public void paint(Graphics graphics) {
graphics.pushState();
- graphics.setForegroundColor(ColorConstants.black);
- graphics
- .setBackgroundColor(GraphicsConstants.elementLabelColor);
- Point p = getBounds().getTopLeft();
- Point p2 = getBounds().getBottomLeft();
- Point p3 = getBounds().getTopRight();
- p3 = new Point(p3.x, p3.y + getSize().height / 2);
- PointList pointList = new PointList();
- pointList.addPoint(p);
- pointList.addPoint(p2.x, p2.y - 1);
- pointList.addPoint(p3);
- graphics.fillPolygon(pointList);
- graphics.drawPolygon(pointList);
- graphics.popState();
+ String sourceid = getSourceDataTypeID();
+ String targetid = getTargetDataTypeID();
+ ILineFigurePaintListener listener = LineFigurePaintListenerManager
+ .getInstance().getPaintListener(sourceid, targetid);
+ if (listener != null) {
+ listener.drawLineSourceLocator(graphics, this,(LineConnectionModel) getModel());
+ }
super.paint(graphics);
+ graphics.popState();
}
};
@@ -195,12 +183,12 @@
}
}
if (collapse) {
-// figure.setForegroundColor(GraphicsConstants.groupBorderColor);
- figure.setForegroundColor(new Color(null,224,224,224));
-// figure.setLineStyle(Graphics.LINE_DOT);
+ // figure.setForegroundColor(GraphicsConstants.groupBorderColor);
+ figure.setForegroundColor(new Color(null, 224, 224, 224));
+ // figure.setLineStyle(Graphics.LINE_DOT);
} else {
figure.setForegroundColor(GraphicsConstants.groupBorderColor);
-// figure.setLineStyle(Graphics.LINE_SOLID);
+ // figure.setLineStyle(Graphics.LINE_SOLID);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/CurveLineConnection.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/CurveLineConnection.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/CurveLineConnection.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -17,7 +17,6 @@
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.jboss.tools.smooks.ui.gef.editparts.StructuredDataConnectionEditPart;
-import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
/**
* @author Dart Peng
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/ILineFigurePaintListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/ILineFigurePaintListener.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/ILineFigurePaintListener.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -13,4 +13,8 @@
*/
public interface ILineFigurePaintListener {
public void drawLineAdditions(Graphics graphics , IFigure hostFigure,
LineConnectionModel model);
+
+ public void drawLineSourceLocator(Graphics graphics , IFigure hostFigure,
LineConnectionModel model);
+
+ public void drawLineTargetLocator(Graphics graphics , IFigure hostFigure,
LineConnectionModel model);
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/LinePaintListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/LinePaintListener.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/LinePaintListener.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -0,0 +1,84 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui.gef.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
+
+/**
+ * @author Dart
+ *
+ */
+public class LinePaintListener implements ILineFigurePaintListener {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.ui.gef.figures.ILineFigurePaintListener#
+ * drawLineAdditions(org.eclipse.draw2d.Graphics,
+ * org.eclipse.draw2d.IFigure,
+ * org.jboss.tools.smooks.ui.gef.model.LineConnectionModel)
+ */
+ public void drawLineAdditions(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.ui.gef.figures.ILineFigurePaintListener#
+ * drawLineSourceLocator(org.eclipse.draw2d.Graphics,
+ * org.eclipse.draw2d.IFigure,
+ * org.jboss.tools.smooks.ui.gef.model.LineConnectionModel)
+ */
+ public void drawLineSourceLocator(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+ graphics.pushState();
+ graphics.setForegroundColor(ColorConstants.black);
+ graphics.setBackgroundColor(GraphicsConstants.elementLabelColor);
+ Point p = hostFigure.getBounds().getTopLeft();
+ Point p2 = hostFigure.getBounds().getBottomLeft();
+ Point p3 = hostFigure.getBounds().getTopRight();
+ p3 = new Point(p3.x, p3.y + hostFigure.getSize().height / 2);
+ PointList pointList = new PointList();
+ pointList.addPoint(p);
+ pointList.addPoint(p2.x, p2.y - 1);
+ pointList.addPoint(p3);
+ graphics.fillPolygon(pointList);
+ graphics.drawPolygon(pointList);
+ graphics.popState();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.ui.gef.figures.ILineFigurePaintListener#
+ * drawLineTargetLocator(org.eclipse.draw2d.Graphics,
+ * org.eclipse.draw2d.IFigure,
+ * org.jboss.tools.smooks.ui.gef.model.LineConnectionModel)
+ */
+ public void drawLineTargetLocator(Graphics graphics, IFigure hostFigure,
+ LineConnectionModel model) {
+ graphics.pushState();
+ graphics.setBackgroundColor(GraphicsConstants.groupHeaderColor);
+ Point p = hostFigure.getBounds().getTopLeft();
+ Point p2 = hostFigure.getBounds().getBottomLeft();
+ Point p3 = hostFigure.getBounds().getTopRight();
+ p3 = new Point(p3.x, p3.y + hostFigure.getSize().height / 2);
+ PointList pointList = new PointList();
+ pointList.addPoint(p);
+ pointList.addPoint(p2.x, p2.y - 1);
+ pointList.addPoint(p3);
+ graphics.fillPolygon(pointList);
+ graphics.drawPolygon(pointList);
+ graphics.popState();
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/LinePaintListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XML2XMLLinePaintListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XML2XMLLinePaintListener.java 2009-01-14
01:47:11 UTC (rev 13024)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XML2XMLLinePaintListener.java 2009-01-14
02:10:34 UTC (rev 13025)
@@ -12,6 +12,7 @@
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
import org.jboss.tools.smooks.ui.gef.figures.ILineFigurePaintListener;
+import org.jboss.tools.smooks.ui.gef.figures.LinePaintListener;
import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
import org.jboss.tools.smooks.xml.XMLImageConstants;
@@ -20,7 +21,7 @@
* @author Dart
*
*/
-public class XML2XMLLinePaintListener implements ILineFigurePaintListener {
+public class XML2XMLLinePaintListener extends LinePaintListener {
/*
* (non-Javadoc)