Author: DartPeng
Date: 2008-10-30 02:58:14 -0400 (Thu, 30 Oct 2008)
New Revision: 11316
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/ui/JavaBeanPropertiesSection.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/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
Log:
JBIDE-2992
Add type/connections problem check function to Xml2Java analyzer
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-30
02:21:00 UTC (rev 11315)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-10-30
06:58:14 UTC (rev 11316)
@@ -786,10 +786,11 @@
} else {
rootModel = new JavaBeanModel(null, rootClassName);
}
+ rootModel.setBeanClassString(SmooksModelUtils.getParmaText("beanClass",
current));
setSelectorIsUsed(rootClassName);
buildChildrenOfTargetInputModel(listType, rootModel, false,
rootIsError, current, loader);
- List list = new ArrayList();
+ List<JavaBeanModel> list = new ArrayList<JavaBeanModel>();
list.add(rootModel);
return list;
}
@@ -834,6 +835,7 @@
selector = selector.substring(2, selector.length() - 1);
ResourceConfigType resourceConfig = findResourceConfigTypeWithSelector(
selector, listType);
+ model.setBeanClassString(SmooksModelUtils.getParmaText("beanClass",
resourceConfig));
if (resourceConfig != null) {
this.buildChildrenOfTargetInputModel(listType, model, false,
false, resourceConfig, classLoader);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java 2008-10-30
02:21:00 UTC (rev 11315)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanPropertiesSection.java 2008-10-30
06:58:14 UTC (rev 11316)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.javabean.ui;
import org.eclipse.gef.EditPart;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -89,19 +90,21 @@
}
private JavaBeanModel getJavaBeanModel() {
- IStructuredSelection selection = (IStructuredSelection) this
- .getSelection();
- Object obj = selection.getFirstElement();
- if (obj == null)
- return null;
- if (obj instanceof EditPart) {
- Object model = ((EditPart) obj).getModel();
- if (model instanceof LineConnectionModel) {
- AbstractStructuredDataModel target = (AbstractStructuredDataModel)
((LineConnectionModel) model)
- .getTarget();
- Object referenceObj = target.getReferenceEntityModel();
- if (referenceObj instanceof JavaBeanModel) {
- return (JavaBeanModel) referenceObj;
+ ISelection s = (ISelection) this.getSelection();
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection)s;
+ Object obj = selection.getFirstElement();
+ if (obj == null)
+ return null;
+ if (obj instanceof EditPart) {
+ Object model = ((EditPart) obj).getModel();
+ if (model instanceof LineConnectionModel) {
+ AbstractStructuredDataModel target = (AbstractStructuredDataModel)
((LineConnectionModel) model)
+ .getTarget();
+ Object referenceObj = target.getReferenceEntityModel();
+ if (referenceObj instanceof JavaBeanModel) {
+ return (JavaBeanModel) referenceObj;
+ }
}
}
}
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-30
02:21:00 UTC (rev 11315)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-30
06:58:14 UTC (rev 11316)
@@ -135,6 +135,7 @@
import org.jboss.tools.smooks.ui.gef.tools.TargetTreeDropTargetListener;
import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+import org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard;
import org.jboss.tools.smooks.ui.wizards.TransformDataSelectionWizard;
import org.jboss.tools.smooks.utils.SmooksGraphConstants;
import org.jboss.tools.smooks.utils.UIUtils;
@@ -271,8 +272,8 @@
SashForm sashForm = new SashForm(mainComposite, SWT.VERTICAL);
GridData sashFormLd = new GridData(GridData.FILL_BOTH);
sashForm.setLayoutData(sashFormLd);
-// sashForm.
-// sashForm.setSashWidth(1);
+ // sashForm.
+ // sashForm.setSashWidth(1);
designTimeAnalyzeResultRegion = toolkit.createComposite(sashForm);
GridLayout ngl = new GridLayout();
@@ -282,7 +283,7 @@
SashForm mappingMainComposite = new SashForm(sashForm, SWT.NONE);
// under the eclipse3.3
-// mappingMainComposite.setSashWidth(1);
+ // mappingMainComposite.setSashWidth(1);
GridData sgd = new GridData(GridData.FILL_BOTH);
section.setLayoutData(sgd);
{
@@ -649,9 +650,8 @@
/*
* (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) {
@@ -714,13 +714,19 @@
context.setDataMappingRootModel(this.rootModel);
context.setSmooksConfigFile(((IFileEditorInput) getEditorInput())
.getFile());
-
- context.setSourceViewerLabelProvider((LabelProvider)sourceViewer.getLabelProvider());
- context.setSourceViewerContentProvider((ITreeContentProvider)sourceViewer.getContentProvider());
-
- context.setTargetViewerLabelProvider((LabelProvider)targetViewer.getLabelProvider());
- context.setTargetViewerContentProvider((ITreeContentProvider)targetViewer.getContentProvider());
-
+
+ context.setSourceViewerLabelProvider((LabelProvider) sourceViewer
+ .getLabelProvider());
+ context
+ .setSourceViewerContentProvider((ITreeContentProvider) sourceViewer
+ .getContentProvider());
+
+ context.setTargetViewerLabelProvider((LabelProvider) targetViewer
+ .getLabelProvider());
+ context
+ .setTargetViewerContentProvider((ITreeContentProvider) targetViewer
+ .getContentProvider());
+
context.setShell(getSite().getShell());
}
@@ -967,9 +973,8 @@
/*
* (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);
@@ -1001,7 +1006,8 @@
throwable = e;
}
if (throwable != null) {
- ((SmooksFormEditor) getEditor()).setOnlyShowTextEditor(true,throwable);
+ ((SmooksFormEditor) getEditor()).setOnlyShowTextEditor(true,
+ throwable);
}
}
@@ -1053,12 +1059,24 @@
try {
if (viewer == this.sourceViewer) {
this.createSourceGraphModels();
+ this.getSmooksConfigurationFileGenerateContext()
+ .getProperties()
+ .setProperty(
+ SmooksConfigFileNewWizard.PRO_SOURCE_DATA_PATH,
+ cw.getStructuredDataSourcePath());
sourceDataTypeID = typeID;
}
if (viewer == this.targetViewer) {
this.createTargetGraphModels();
targetDataTypeID = typeID;
+ this.getSmooksConfigurationFileGenerateContext()
+ .getProperties()
+ .setProperty(
+ SmooksConfigFileNewWizard.PRO_TARGET_DATA_PATH,
+ cw.getStructuredDataSourcePath());
}
+ commandStackChanged = true;
+ firePropertyChange(PROP_DIRTY);
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), "Error",
"a error occurs during filling Data into the viewer:\n"
@@ -1103,9 +1121,8 @@
/*
* (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);
@@ -1114,9 +1131,8 @@
/*
* (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) {
@@ -1125,9 +1141,8 @@
/*
* (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) {
@@ -1159,9 +1174,8 @@
/*
* (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;
@@ -1194,9 +1208,8 @@
/*
* (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();
@@ -1289,7 +1302,8 @@
SWT.NONE);
Menu menu = new Menu(getSite().getShell(), SWT.POP_UP);
List<ResolveCommand> list = result.getResolveProblem();
- for (Iterator<ResolveCommand> iterator2 = list.iterator();
iterator2.hasNext();) {
+ for (Iterator<ResolveCommand> iterator2 = list.iterator(); iterator2
+ .hasNext();) {
final ResolveCommand resolveCommand = (ResolveCommand) iterator2
.next();
MenuItem item = new MenuItem(menu, SWT.NONE);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-10-30
02:21:00 UTC (rev 11315)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-10-30
06:58:14 UTC (rev 11316)
@@ -10,9 +10,6 @@
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.IWizardNode;
-import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -28,7 +25,6 @@
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.INewWizard;
/**
*
@@ -44,6 +40,7 @@
protected Button fileSystemBrowseButton;
protected boolean reasourceLoaded = false;
private Button workspaceBrowseButton;
+ private String filePath = null;
public AbstractFileSelectionWizardPage(String pageName) {
super(pageName);
@@ -52,7 +49,7 @@
public Object getReturnValue() {
try {
- returnObject = this.loadedTheObject(fileText.getText());
+ returnObject = this.loadedTheObject(filePath);
} catch (Exception e) {
e.printStackTrace();
}
@@ -60,7 +57,7 @@
}
public String getFilePath(){
- return fileText.getText();
+ return filePath;
}
/*
* (non-Javadoc)
@@ -109,6 +106,7 @@
protected void hookFileTextModifyListener() {
final ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ filePath = fileText.getText();
changeWizardPageStatus();
}
};
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-30
02:21:00 UTC (rev 11315)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-30
06:58:14 UTC (rev 11316)
@@ -17,6 +17,8 @@
import javax.swing.text.html.HTMLDocument.HTMLReader.TagAction;
import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.smooks.analyzer.AbstractAnalyzer;
import org.jboss.tools.smooks.analyzer.DesignTimeAnalyzeResult;
import org.jboss.tools.smooks.analyzer.MappingModel;
@@ -395,9 +397,89 @@
}
return null;
}
+
+ private void checkRootNodeConnected(
+ SmooksConfigurationFileGenerateContext context) {
+ GraphRootModel root = context.getGraphicalRootModel();
+ List sourceList = root.loadSourceModelList();
+ List targetList = root.loadTargetModelList();
+ AbstractXMLObject rootSource = null;
+ JavaBeanModel rootTarget = null;
+ boolean needCheck = false;
+
+ for (Iterator iterator = sourceList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel sourcegm = (AbstractStructuredDataModel) iterator
+ .next();
+ if (sourcegm instanceof IConnectableModel) {
+ if (!((IConnectableModel) sourcegm).getModelSourceConnections()
+ .isEmpty()
+ || !((IConnectableModel) sourcegm)
+ .getModelTargetConnections().isEmpty()) {
+ needCheck = true;
+ break;
+ }
+ }
+ }
+
+ if (needCheck) {
+ for (Iterator iterator = sourceList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel sourceGraphModel = (AbstractStructuredDataModel)
iterator
+ .next();
+ AbstractXMLObject source = (AbstractXMLObject) sourceGraphModel
+ .getReferenceEntityModel();
+ if (source.getParent().getClass() == DocumentObject.class ) {
+ rootSource = source;
+ break;
+ }
+ }
+
+ for (Iterator iterator = targetList.iterator(); iterator.hasNext();) {
+ AbstractStructuredDataModel targetGraphModel = (AbstractStructuredDataModel)
iterator
+ .next();
+ JavaBeanModel target = (JavaBeanModel) targetGraphModel
+ .getReferenceEntityModel();
+ if (target.isRoot()) {
+ rootTarget = target;
+ break;
+ }
+ }
+ if (rootSource != null && rootTarget != null) {
+ AbstractStructuredDataModel rootSourceGraphModel = UIUtils
+ .findGraphModel(root, rootSource);
+ AbstractStructuredDataModel rootTargetGraphModel = UIUtils
+ .findGraphModel(root, rootTarget);
+ if (rootSourceGraphModel instanceof IConnectableModel
+ && rootTargetGraphModel instanceof IConnectableModel) {
+ if (((IConnectableModel) rootSourceGraphModel)
+ .isSourceConnectWith((IConnectableModel) rootTargetGraphModel)) {
+ // do nothing
+ } else {
+ // ask user if they want to connect the root model
+ Shell displayParent = context.getShell();
+ boolean connectAuto = MessageDialog
+ .openQuestion(
+ displayParent,
+ "Connection Question",
+ "The root models don't be connected , it will make some errors with
the generation config file contents.\nDo you wan to connect them?");
+ if (connectAuto) {
+ // connect root model
+ LineConnectionModel connectionModel = new LineConnectionModel();
+ connectionModel
+ .setSource((IConnectableModel) rootSourceGraphModel);
+ connectionModel
+ .setTarget((IConnectableModel) rootTargetGraphModel);
+ connectionModel.connect();
+ }
+ }
+ }
+ }
+ }
+ }
+
public DesignTimeAnalyzeResult[] analyzeGraphModel(
SmooksConfigurationFileGenerateContext context) {
+ checkRootNodeConnected(context);
List<DesignTimeAnalyzeResult> typeCheckResults = UIUtils
.checkTargetJavaModelType(context);
List<DesignTimeAnalyzeResult> connectionCheckResults = UIUtils