Author: DartPeng
Date: 2008-10-26 06:12:01 -0400 (Sun, 26 Oct 2008)
New Revision: 11182
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ResolveCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/Java2JavaResolveCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ProblemLabel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResolveCommandPanel.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/util/editparts/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/util/figures/
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DesignTimeAnalyzeResult.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
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/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
Log:
JBIDE-2867
Change the display composite to sashform
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DesignTimeAnalyzeResult.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DesignTimeAnalyzeResult.java 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/DesignTimeAnalyzeResult.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -3,13 +3,17 @@
*/
package org.jboss.tools.smooks.analyzer;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author dart
*
*/
public class DesignTimeAnalyzeResult {
- public String errorMessage;
- public String warningMessage;
+ protected String errorMessage;
+ protected String warningMessage;
+ protected List<ResolveCommand> resolveCommandList = new
ArrayList<ResolveCommand>();
public String getErrorMessage() {
return errorMessage;
}
@@ -23,5 +27,17 @@
this.warningMessage = warningMessage;
}
+ public void addResolveCommand(ResolveCommand command){
+ this.resolveCommandList.add(command);
+ }
+ public void removeResolveCommand(ResolveCommand command){
+ this.resolveCommandList.remove(command);
+ }
+
+ public List<ResolveCommand> getResolveProblem(){
+ return resolveCommandList;
+ }
+
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IMappingAnalyzer.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.smooks.analyzer;
-import java.util.List;
-
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
@@ -20,12 +18,32 @@
*
*/
public interface IMappingAnalyzer {
+ /**
+ * Parse the graphical model and generate the smooks config file model
+ * @param context
+ * @throws SmooksAnalyzerException
+ */
public void analyzeMappingGraphModel(
SmooksConfigurationFileGenerateContext context)
throws SmooksAnalyzerException;
+
+ /**
+ * Parse the smooks config file model what loaded by EMF , and create the relating
graphical model for it.
+ * @param listType
+ * @param sourceObject
+ * @param targetObject
+ * @return
+ */
public MappingResourceConfigList analyzeMappingSmooksModel(
SmooksResourceListType listType,Object sourceObject,Object targetObject);
- public DesignTimeAnalyzeResult analyzeGraphModel(SmooksConfigurationFileGenerateContext
context);
+ /**
+ * Analyze the graphical model to find the incorrect logic model and return the analyze
result.<p>
+ * The graphical editor will display the analyze result.
+ * @param context
+ * @return
+ */
+ public DesignTimeAnalyzeResult[]
analyzeGraphModel(SmooksConfigurationFileGenerateContext context);
}
+
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ResolveCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ResolveCommand.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ResolveCommand.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.analyzer;
+
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+
+/**
+ * @author Dart
+ *
+ */
+public class ResolveCommand {
+ private SmooksConfigurationFileGenerateContext context;
+
+ private String resolveDescription ;
+
+ private Image image;
+
+ public void setResolveDescription(String resolveDescription) {
+ this.resolveDescription = resolveDescription;
+ }
+
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+ public ResolveCommand(SmooksConfigurationFileGenerateContext context){
+ this.context = context;
+ }
+
+ public SmooksConfigurationFileGenerateContext getContext() {
+ return context;
+ }
+
+ public void execute() throws Exception{
+
+ }
+
+ public Image getImage(){
+ return image;
+ }
+
+ public String getResolveDescription(){
+ return resolveDescription;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/ResolveCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -56,7 +56,6 @@
SmooksConfigurationFileGenerateContext context)
throws SmooksAnalyzerException {
// TODO will modify soon
-
if(true){
Shell shell = context.getShell();
MessageDialog.openWarning(shell, "Warning", "The java2xml can't be
generate to config file currently.");
@@ -174,7 +173,7 @@
return "${" + name + "}";
}
- public DesignTimeAnalyzeResult analyzeGraphModel(
+ public DesignTimeAnalyzeResult[] analyzeGraphModel(
SmooksConfigurationFileGenerateContext context) {
// TODO Auto-generated method stub
return null;
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/Java2JavaResolveCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/Java2JavaResolveCommand.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/Java2JavaResolveCommand.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.javabean.analyzer;
+
+import org.jboss.tools.smooks.analyzer.ResolveCommand;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+
+/**
+ * @author Dart
+ *
+ */
+public class Java2JavaResolveCommand extends ResolveCommand {
+
+ private JavaBeanModel sourceModel;
+
+ private JavaBeanModel targetModel;
+
+
+
+ public JavaBeanModel getSourceModel() {
+ return sourceModel;
+ }
+
+ public void setSourceModel(JavaBeanModel sourceModel) {
+ this.sourceModel = sourceModel;
+ }
+
+ public JavaBeanModel getTargetModel() {
+ return targetModel;
+ }
+
+ public void setTargetModel(JavaBeanModel targetModel) {
+ this.targetModel = targetModel;
+ }
+
+ public Java2JavaResolveCommand(
+ SmooksConfigurationFileGenerateContext context) {
+ super(context);
+ }
+
+ @Override
+ public void execute() throws Exception {
+
+ SmooksConfigurationFileGenerateContext context = getContext();
+ if(context == null) throw new RuntimeException("Smooks generated context is
NULL");
+
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/Java2JavaResolveCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -39,8 +39,11 @@
import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
import org.jboss.tools.smooks.analyzer.MappingModel;
import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.ResolveCommand;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
import org.jboss.tools.smooks.javabean.model.JavaBeanModelFactory;
import org.jboss.tools.smooks.model.AbstractResourceConfig;
@@ -76,6 +79,10 @@
public static final String SPACE_STRING = " ";
+ private static final int TARGET_DATA = 1;
+
+ private static final int SOURCE_DATA = 0;
+
private List usedConnectionList = new ArrayList();
private ComposedAdapterFactory adapterFactory;
@@ -350,7 +357,7 @@
AbstractStructuredDataModel sourceModel) {
JavaBeanModel source = (JavaBeanModel) sourceModel
.getReferenceEntityModel();
- if(source.getBeanClass().isArray()){
+ if (source.getBeanClass().isArray()) {
return source.getName();
}
if (Collection.class.isAssignableFrom(source.getBeanClass())) {
@@ -360,12 +367,12 @@
}
- private DesignTimeAnalyzeResult checkOtherNodeConnected(
+ private DesignTimeAnalyzeResult[] checkOtherNodeConnected(
SmooksConfigurationFileGenerateContext context) {
GraphRootModel root = context.getGraphicalRootModel();
List sourceList = root.loadSourceModelList();
List targetList = root.loadTargetModelList();
- StringBuffer buffer = new StringBuffer();
+ List<DesignTimeAnalyzeResult> arList = new
ArrayList<DesignTimeAnalyzeResult>();
for (Iterator iterator = targetList.iterator(); iterator.hasNext();) {
AbstractStructuredDataModel targetm = (AbstractStructuredDataModel) iterator
.next();
@@ -384,24 +391,22 @@
if (pgm != null && pgm instanceof IConnectableModel) {
if (((IConnectableModel) pgm)
.getModelTargetConnections().isEmpty()) {
- buffer
- .append("The parent of Java node \""
- + javaModel.getName()
- + "\" : \""
- + parent.getName()
- + "\" doesn't be connected by any source node!\n");
+ String errorMessage = "The parent of Java node \""
+ + javaModel.getName()
+ + "\" : \""
+ + parent.getName()
+ + "\" doesn't be connected by any source node";
+ DesignTimeAnalyzeResult dr = new DesignTimeAnalyzeResult();
+ dr.setErrorMessage(errorMessage);
+ Java2JavaResolveCommand command = new Java2JavaResolveCommand(context);
+// command.setResolveDescription(resolveDescription);
+ arList.add(dr);
}
}
}
}
}
- String result = buffer.toString();
- if ("".equals(result)) {
- return null;
- }
- DesignTimeAnalyzeResult dr = new DesignTimeAnalyzeResult();
- dr.setErrorMessage(result);
- return dr;
+ return arList.toArray(new DesignTimeAnalyzeResult[0]);
}
/**
@@ -491,7 +496,11 @@
/*
* (non-Javadoc)
*
- * @see
org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ * @see
+ * org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel
+ * (
+ * org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext
+ * )
*/
public void analyzeMappingGraphModel(
SmooksConfigurationFileGenerateContext context)
@@ -541,7 +550,8 @@
}
String beanClass = SmooksModelUtils.getParmaText(
"beanClass", rc);
- if (targetName!=null && targetName.trim().equals(beanClass)) {
+ if (targetName != null
+ && targetName.trim().equals(beanClass)) {
setSelectorIsUsed(sourceName);
// create the first connection
mappingModelList.add(new MappingModel(source, target));
@@ -649,6 +659,27 @@
return null;
}
+ private String getDataSourceClass(GraphInformations info, int dataMode) {
+ String key = "sourceDataPath";
+ if (dataMode == SOURCE_DATA) {
+ key = "sourceDataPath";
+ }
+ if (dataMode == TARGET_DATA) {
+ key = "targetDataPath";
+ }
+
+ Params params = info.getParams();
+ List paramList = params.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ Param param = (Param) iterator.next();
+ if (key.equals(param.getName())) {
+ return param.getValue();
+ }
+ }
+
+ return null;
+ }
+
public Object buildSourceInputObjects(GraphInformations graphInfo,
SmooksResourceListType listType, IFile sourceFile,
ClassLoader classLoader) throws InvocationTargetException {
@@ -673,9 +704,12 @@
}
}
}
-
- if (rootClassName == null)
+ if (rootClassName == null) {
+ rootClassName = this.getDataSourceClass(graphInfo, SOURCE_DATA);
+ }
+ if (rootClassName == null) {
return null;
+ }
boolean isWarning = false;
boolean isError = false;
@@ -756,10 +790,16 @@
}
}
}
- if (current == null)
+ if (current == null) {
+ rootClassName = this.getDataSourceClass(graphInfo, TARGET_DATA);
+ }
+ // if can't load the source from GraphicalInformation , return NULL
+ if (current == null && rootClassName == null)
return null;
Class rootClass = null;
- rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ if (rootClassName == null) {
+ rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ }
if (rootClassName != null && loader != null) {
try {
rootClass = loader.loadClass(rootClassName);
@@ -801,9 +841,6 @@
String selector = SmooksModelUtils
.getAttributeValueFromAnyType(binding,
SmooksModelUtils.ATTRIBUTE_SELECTOR);
- // if(property == null){
- // continue;
- // }
processBindingPropertyFromTargetModel(listType, property,
selector, beanModel, classLoader);
}
@@ -1006,7 +1043,7 @@
return null;
}
- public DesignTimeAnalyzeResult analyzeGraphModel(
+ public DesignTimeAnalyzeResult[] analyzeGraphModel(
SmooksConfigurationFileGenerateContext context) {
checkRootNodeConnected(context);
return checkOtherNodeConnected(context);
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ProblemLabel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ProblemLabel.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ProblemLabel.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui.editors;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * @author Dart
+ * @date 2008.10.24
+ */
+public class ProblemLabel extends Label {
+
+ public ProblemLabel(Composite parent, int style) {
+ super(parent, style);
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ProblemLabel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResolveCommandPanel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResolveCommandPanel.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResolveCommandPanel.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -0,0 +1,140 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui.editors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+import org.jboss.tools.smooks.analyzer.ResolveCommand;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
+import org.jboss.tools.smooks.utils.SmooksGraphConstants;
+import org.jboss.tools.smooks.utils.UIUtils;
+
+/**
+ * @author Dart
+ *
+ */
+public class ResolveCommandPanel extends Composite {
+
+ private static List<Shell> shellList = new ArrayList<Shell>();
+
+ public ResolveCommandPanel(Composite parent, int style) {
+ super(parent, style);
+ // TODO Auto-generated constructor stub
+ }
+
+ public static void open(List<ResolveCommand> list, Shell shell,
+ Point location) {
+ try {
+ closeAll();
+ if (shell == null)
+ return;
+ final Shell newShell = new Shell(shell, SWT.NONE);
+ FillLayout fill = new FillLayout();
+ fill.marginHeight = 0;
+ fill.marginWidth = 0;
+ newShell.setLayout(fill);
+ final ResolveCommandPanel panel = new ResolveCommandPanel(newShell,
+ SWT.NONE);
+ panel.setBackground(ColorConstants.cyan);
+ newShell.addFocusListener(new FocusListener(){
+
+ public void focusGained(FocusEvent arg0) {
+ System.out.println("Gained");
+ }
+
+ public void focusLost(FocusEvent arg0) {
+ if (!newShell.isDisposed()) {
+ newShell.close();
+ }
+ }
+ });
+
+ panel.setBackground(ColorConstants.black);
+ FillLayout layout = new FillLayout();
+ layout.marginHeight = 1;
+ layout.marginWidth = 1;
+ panel.setLayout(layout);
+
+ Composite com = new Composite(panel, SWT.NONE);
+ GridLayout glayout = new GridLayout();
+ com.setLayout(glayout);
+ if (list != null) {
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ final ResolveCommand resolveCommand = (ResolveCommand) iterator
+ .next();
+ ImageHyperlink link = new ImageHyperlink(com, SWT.NONE);
+ link.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkActivated(HyperlinkEvent arg0) {
+ try {
+ newShell.close();
+ resolveCommand.execute();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void linkEntered(HyperlinkEvent arg0) {
+
+ }
+
+ public void linkExited(HyperlinkEvent arg0) {
+
+ }
+
+ });
+ String text = resolveCommand.getResolveDescription();
+ if (text == null)
+ text = "<NULL>";
+ link.setText(text);
+ Image image = resolveCommand.getImage();
+ if (image == null) {
+ image = SmooksUIActivator.getDefault()
+ .getImageRegistry().get(
+ SmooksGraphConstants.IMAGE_EMPTY);
+ }
+ link.setImage(image);
+ }
+ }
+ newShell.setLocation(location);
+ newShell.setSize(new Point(400, 100));
+ shellList.add(newShell);
+
+ newShell.open();
+ newShell.setVisible(false);
+// newShell.setVisible(true);
+ } catch (Throwable e) {
+ UIUtils.showErrorDialog(shell, UIUtils.createErrorStatus(e));
+ }
+ }
+
+ public static void closeAll(){
+ for (Iterator iterator = shellList.iterator(); iterator.hasNext();) {
+ Shell shell = (Shell) iterator.next();
+ if(!shell.isDisposed()) shell.close();
+ }
+
+ shellList.clear();
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResolveCommandPanel.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 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -61,14 +61,20 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -78,6 +84,9 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorInput;
@@ -101,6 +110,7 @@
import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
import org.jboss.tools.smooks.analyzer.MappingModel;
import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.ResolveCommand;
import org.jboss.tools.smooks.analyzer.ResourceConfigEraser;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.analyzer.SmooksFileBuilder;
@@ -117,7 +127,6 @@
import org.jboss.tools.smooks.ui.IViewerInitor;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
import org.jboss.tools.smooks.ui.StructuredDataCreationWizardDailog;
-import org.jboss.tools.smooks.ui.ViewerInitorStore;
import org.jboss.tools.smooks.ui.gef.editparts.SmooksEditPartFactory;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
@@ -141,6 +150,9 @@
public class SmooksGraphicalFormPage extends FormPage implements
ISelectionChangedListener, ISelectionProvider,
org.eclipse.emf.common.command.CommandStackListener {
+
+ private List<DesignTimeAnalyzeResult> analyzeResultList = new
ArrayList<DesignTimeAnalyzeResult>();
+
private static final String REFERENCE_MODEL = "__reference_model";
protected SmooksConfigurationFileGenerateContext
smooksConfigurationFileGenerateContext;
protected IViewerInitor sourceViewerInitor;
@@ -168,10 +180,10 @@
private ISelection selection;
protected MappingResourceConfigList mappingResourceConfigList;
protected AdapterFactoryEditingDomain editingDomain;
- private Label notifyLabel;
private boolean canSaveFile = true;
- private Label imageLabel;
+ private Composite designTimeAnalyzeResultRegion;
+
public ISelection getSelection() {
return selection;
}
@@ -268,37 +280,38 @@
Section.TITLE_BAR | Section.DESCRIPTION,
"Mapping Graph Edit Panel",
"Edit the source and target assosiation");
- Composite mappingMainComposite = toolkit.createComposite(section);
- GridLayout gly = new GridLayout();
- gly.numColumns = 3;
- gly.horizontalSpacing = 0;
- mappingMainComposite.setLayout(gly);
- section.setClient(mappingMainComposite);
- Composite notifyComposite = toolkit
- .createComposite(mappingMainComposite);
- GridData ngd = new GridData(GridData.FILL_HORIZONTAL);
- ngd.horizontalSpan = 3;
+ Composite mainComposite = toolkit.createComposite(section);
+ section.setClient(mainComposite);
+
+ GridLayout mainLayout = new GridLayout();
+ mainComposite.setLayout(mainLayout);
+
+ SashForm sashForm = new SashForm(mainComposite, SWT.VERTICAL);
+ GridData sashFormLd = new GridData(GridData.FILL_BOTH);
+ sashForm.setLayoutData(sashFormLd);
+
+ sashForm.setSashWidth(1);
+
+ designTimeAnalyzeResultRegion = toolkit.createComposite(sashForm);
GridLayout ngl = new GridLayout();
ngl.numColumns = 2;
- notifyComposite.setLayout(ngl);
- notifyComposite.setLayoutData(ngd);
- imageLabel = toolkit.createLabel(notifyComposite, "");
- imageLabel.setImage(SmooksUIActivator.getDefault().getImageRegistry()
- .get(SmooksGraphConstants.IMAGE_EMPTY));
- notifyLabel = toolkit.createLabel(notifyComposite, "" );
- GridData nlgd = new GridData(GridData.FILL_HORIZONTAL);
- notifyLabel.setLayoutData(nlgd);
+ ngl.marginWidth = 0;
+ designTimeAnalyzeResultRegion.setLayout(ngl);
+
+ SashForm mappingMainComposite = new SashForm(sashForm, SWT.NONE);
+ mappingMainComposite.setSashWidth(1);
GridData sgd = new GridData(GridData.FILL_BOTH);
section.setLayoutData(sgd);
{
Composite composite1 = toolkit
.createComposite(mappingMainComposite);
GridLayout layout = new GridLayout();
+ layout.marginWidth = 1;
layout.marginHeight = 1;
- layout.marginWidth = 1;
+ composite1.setLayout(layout);
+
GridData gd = new GridData(GridData.FILL_BOTH);
- composite1.setLayout(layout);
sourceViewer = this.createSourceTreeViewer(composite1);
sourceViewer.getTree().setLayoutData(gd);
sourceViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY
@@ -320,26 +333,16 @@
composite1.setLayoutData(gd);
composite1.setBackground(GraphicsConstants.groupBorderColor);
}
+
{
Composite composite2 = toolkit
.createComposite(mappingMainComposite);
- GridData composite2LData = new GridData();
- composite2LData.grabExcessHorizontalSpace = true;
- composite2LData.grabExcessVerticalSpace = true;
- composite2LData.horizontalAlignment = GridData.FILL;
- composite2LData.verticalAlignment = GridData.FILL;
- composite2.setLayoutData(composite2LData);
composite2.setLayout(new FillLayout());
this.setGraphicalViewer(createGraphicalViewer(composite2));
}
{
Composite composite3 = toolkit
.createComposite(mappingMainComposite);
- GridData composite3LData = new GridData();
- composite3LData.grabExcessHorizontalSpace = true;
- composite3LData.verticalAlignment = GridData.FILL;
- composite3LData.grabExcessVerticalSpace = true;
- composite3LData.horizontalAlignment = GridData.FILL;
GridLayout layout = new GridLayout();
layout.marginWidth = 1;
layout.marginHeight = 1;
@@ -362,8 +365,7 @@
}
{
- Composite underToolPanel = toolkit
- .createComposite(mappingMainComposite);
+ Composite underToolPanel = toolkit.createComposite(mainComposite);
GridData sgd1 = new GridData(GridData.FILL_HORIZONTAL);
GridLayout underLayout = new GridLayout();
underLayout.numColumns = 3;
@@ -416,8 +418,8 @@
// section1.setLayoutData(sgd1);
toolkit.paintBordersFor(rootMainControl);
-
form.pack();
+ sashForm.setWeights(new int[] { 8, 100 });
if (initSourceTreeViewerProviders()) {
initSourceTreeViewer();
expandSourceConnectionModel();
@@ -665,7 +667,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ * @see
+ * org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.
+ * IProgressMonitor)
*/
@Override
public void doSave(IProgressMonitor monitor) {
@@ -674,8 +678,8 @@
.openQuestion(
getSite().getShell(),
"Clean all the errors please",
- "There occurs some errors on the graphical design , please clean all errors
.\n" +
- "Click \"Yes\" to return . If you don't care that , click
\"No\" to save file.");
+ "There occurs some errors on the graphical design , please clean all errors
.\n"
+ + "Click \"Yes\" to return . If you don't care that , click
\"No\" to save file.");
if (cleanError)
return;
}
@@ -975,8 +979,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.ui.forms.editor.FormPage#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
+ * @see
+ * org.eclipse.ui.forms.editor.FormPage#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
*/
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
@@ -1096,7 +1101,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.
+ * eclipse.ui.forms.events.HyperlinkEvent)
*/
public void linkActivated(HyperlinkEvent e) {
showCreationWizard(viewer);
@@ -1105,7 +1112,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent)
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse
+ * .ui.forms.events.HyperlinkEvent)
*/
public void linkEntered(HyperlinkEvent e) {
@@ -1114,7 +1123,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent)
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse
+ * .ui.forms.events.HyperlinkEvent)
*/
public void linkExited(HyperlinkEvent e) {
@@ -1146,7 +1157,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ * @see
+ * org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets
+ * .Event)
*/
public void handleEvent(Event event) {
TreeItem item = (TreeItem) event.item;
@@ -1179,7 +1192,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
+ * @see
+ * org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt
+ * .events.PaintEvent)
*/
public void paintControl(PaintEvent e) {
Tree tree = (Tree) e.getSource();
@@ -1253,27 +1268,57 @@
getManagedForm().dirtyStateChanged();
}
- protected void setErrorMessage(String errorMessage) {
- imageLabel.setImage(SmooksUIActivator.getDefault().getImageRegistry().get(SmooksGraphConstants.IMAGE_EMPTY));
- notifyLabel.setText("");
- canSaveFile = true;
- if (errorMessage != null) {
- imageLabel.setImage(SmooksUIActivator.getDefault()
- .getImageRegistry().get(SmooksGraphConstants.IMAGE_ERROR));
- notifyLabel.setText(errorMessage);
- canSaveFile = false;
+ protected void updateErrorMessage() {
+ for (Iterator<DesignTimeAnalyzeResult> iterator = this.analyzeResultList
+ .iterator(); iterator.hasNext();) {
+ DesignTimeAnalyzeResult result = (DesignTimeAnalyzeResult) iterator
+ .next();
+ if (result.getErrorMessage() != null) {
+ if (canSaveFile)
+ canSaveFile = false;
+ Label imageLabel = new Label(designTimeAnalyzeResultRegion,
+ SWT.NONE);
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ imageLabel.setLayoutData(gd);
+ imageLabel.setImage(SmooksUIActivator.getDefault()
+ .getImageRegistry().get(
+ SmooksGraphConstants.IMAGE_ERROR));
+ Label notifyLabel = new Label(designTimeAnalyzeResultRegion,
+ SWT.NONE);
+ Menu menu = new Menu(getSite().getShell(),SWT.POP_UP);
+ List<ResolveCommand> list = result.getResolveProblem();
+ for (Iterator iterator2 = list.iterator(); iterator2.hasNext();) {
+ final ResolveCommand resolveCommand = (ResolveCommand) iterator2
+ .next();
+ MenuItem item = new MenuItem(menu,SWT.NONE);
+ item.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ widgetSelected(arg0);
+ }
+
+ public void widgetSelected(SelectionEvent arg0) {
+ try {
+ resolveCommand.execute();
+ } catch (Exception e) {
+ }
+ }
+
+ });
+ item.setText(resolveCommand.getResolveDescription());
+ item.setImage(resolveCommand.getImage());
+ }
+ notifyLabel.setMenu(menu);
+ GridData nlgd = new GridData(GridData.FILL_HORIZONTAL);
+ notifyLabel.setLayoutData(nlgd);
+ notifyLabel.setText(result.getErrorMessage());
+
+ }
}
}
- protected void setWarningMessage(String warningMessage) {
- imageLabel.setImage(SmooksUIActivator.getDefault().getImageRegistry().get(SmooksGraphConstants.IMAGE_EMPTY));
- notifyLabel.setText("");
- if (warningMessage != null) {
- imageLabel
- .setImage(SmooksUIActivator.getDefault().getImageRegistry()
- .get(SmooksGraphConstants.IMAGE_WARNING));
- notifyLabel.setText(warningMessage);
- }
+ protected void updateWarningMessage() {
+
}
protected void analyzeDesignGraph() {
@@ -1283,28 +1328,33 @@
SmooksConfigurationFileGenerateContext context = this
.createContext();
this.initSmooksConfigurationFileGenerateContext(context);
- DesignTimeAnalyzeResult result = analyzer
+ DesignTimeAnalyzeResult[] results = analyzer
.analyzeGraphModel(context);
- if (result != null) {
- String errorMessage = result.getErrorMessage();
- String warningMessage = result.getWarningMessage();
-
- if (errorMessage != null) {
- setErrorMessage(errorMessage);
- return;
- }
-
- if (warningMessage != null) {
- setWarningMessage(warningMessage);
- return;
- }
+ analyzeResultList.clear();
+ for (int i = 0; i < results.length; i++) {
+ analyzeResultList.add(results[i]);
}
+ updateNotifyMessage();
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
+ protected void updateNotifyMessage() {
+ canSaveFile = true;
+ Control[] children = designTimeAnalyzeResultRegion.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control c = children[i];
+ c.setVisible(false);
+ c.dispose();
+ c = null;
+ }
+ updateErrorMessage();
+ updateWarningMessage();
+ designTimeAnalyzeResultRegion.layout(true);
+ }
+
/**
* @return the editingDomain
*/
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -58,7 +58,6 @@
public void analyzeMappingGraphModel(
SmooksConfigurationFileGenerateContext context)
throws SmooksAnalyzerException {
-
SmooksResourceListType listType = context.getSmooksResourceListModel();
GraphRootModel rootModel = context.getGraphicalRootModel();
List children = rootModel.getChildren();
@@ -218,6 +217,8 @@
JavaBeanModel sourceTarget = (JavaBeanModel) targetObject;
ResourceConfigType rootResourceConfig = findFirstMappingResourceConfig(listType);
+ // if can't find the root , return null
+ if(rootResourceConfig ==null) return null;
String xmlName = rootResourceConfig.getSelector();
AbstractXMLObject source = findXMLObjectByName(xmlName, sourceRoot);
if (source == null)
@@ -391,7 +392,7 @@
return null;
}
- public DesignTimeAnalyzeResult analyzeGraphModel(
+ public DesignTimeAnalyzeResult[] analyzeGraphModel(
SmooksConfigurationFileGenerateContext context) {
// TODO Auto-generated method stub
return null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2008-10-25
21:57:33 UTC (rev 11181)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2008-10-26
10:12:01 UTC (rev 11182)
@@ -21,24 +21,28 @@
/*
* (non-Javadoc)
*
- * @see
org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ * @see
+ * org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel
+ * (
+ * org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext
+ * )
*/
public void analyzeMappingGraphModel(
SmooksConfigurationFileGenerateContext context)
throws SmooksAnalyzerException {
- if (true) {
- Shell shell = context.getShell();
- MessageDialog.openWarning(shell, "Warning",
- "The xml2xml can't be generate to config file currently.");
- return;
- }
+ Shell shell = context.getShell();
+ MessageDialog.openWarning(shell, "Warning",
+ "The xml2xml can't be generate to config file currently.");
+ return;
}
/*
* (non-Javadoc)
*
- * @see
org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingSmooksModel(org.jboss.tools.smooks.model.SmooksResourceListType,
- * java.lang.Object, java.lang.Object)
+ * @see
+ * org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingSmooksModel
+ * (org.jboss.tools.smooks.model.SmooksResourceListType, java.lang.Object,
+ * java.lang.Object)
*/
public MappingResourceConfigList analyzeMappingSmooksModel(
SmooksResourceListType listType, Object sourceObject,
@@ -46,7 +50,7 @@
return null;
}
- public DesignTimeAnalyzeResult analyzeGraphModel(
+ public DesignTimeAnalyzeResult[] analyzeGraphModel(
SmooksConfigurationFileGenerateContext context) {
// TODO Auto-generated method stub
return null;