Author: DartPeng
Date: 2009-06-17 03:16:58 -0400 (Wed, 17 Jun 2009)
New Revision: 16001
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XMLFile.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XSDFile.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/jcu_obj.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/unknown_obj.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizardPage.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
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/SmooksConfigurationFormPage.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/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
Log:
JBIDE-4173
Done
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-06-16
22:17:31 UTC (rev 16000)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-06-17
07:16:58 UTC (rev 16001)
@@ -20,7 +20,11 @@
org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.eclipse.wst.validation,
- org.eclipse.pde.ui
+ org.eclipse.pde.ui,
+ org.eclipse.xsd,
+ org.eclipse.wst.wsdl,
+ org.apache.xerces,
+ javax.wsdl
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XMLFile.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XMLFile.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XSDFile.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/XSDFile.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/jcu_obj.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/jcu_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/unknown_obj.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/unknown_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -67,6 +67,10 @@
reg.put(GraphicsConstants.JAVA_PROPERTY_ICON,
getImageDescriptor(GraphicsConstants.JAVA_PROPERTY_ICON_PATH));
+ reg.put(GraphicsConstants.IMAGE_UNKNOWN_OBJ, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_UNKNOWN_OBJ));
+
+
// regist ovr images
reg.put(GraphicsConstants.IMAGE_OVR_ERROR,
getImageDescriptor(GraphicsConstants.IMAGE_OVR_ERROR));
reg.put(GraphicsConstants.IMAGE_OVR_WARING,
getImageDescriptor(GraphicsConstants.IMAGE_OVR_WARING));
@@ -91,8 +95,18 @@
GraphicsConstants.IMAGE_JAVA_ARRAY));
reg.put(GraphicsConstants.IMAGE_JAVA_COLLECTION, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_JAVA_COLLECTION));
+ reg.put(GraphicsConstants.IMAGE_JAVA_FILE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_JAVA_FILE));
+
// for the xml2xml line
+ reg.put(GraphicsConstants.IMAGE_XML_FILE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_XML_FILE));
+
+ reg.put(GraphicsConstants.IMAGE_XSD_FILE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_XSD_FILE));
+
+
reg.put(GraphicsConstants.IMAGE_BINDING_LINE, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_BINDING_LINE));
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -10,11 +10,15 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks.model.graphics.ext.ParamType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
@@ -38,12 +42,18 @@
case 0:
if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
- GraphicsConstants.IMAGE_JAVA_OBJECT);
+ GraphicsConstants.IMAGE_JAVA_FILE);
}
if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
- GraphicsConstants.IMAGE_XML_ELEMENT);
+ GraphicsConstants.IMAGE_XML_FILE);
}
+ if (SmooksModelUtils.INPUT_TYPE_XSD.equals(type)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_XSD_FILE);
+ }
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_UNKNOWN_OBJ);
}
}
return null;
@@ -61,11 +71,25 @@
String value = SmooksModelUtils.getInputPath((InputType) element);
if (value == null)
value = "";
+ String extValue = "";
+ List<ParamType> paramers = ((InputType) element).getParam();
+ for (Iterator<?> iterator = paramers.iterator(); iterator.hasNext();) {
+ ParamType paramType = (ParamType) iterator.next();
+ if ("path".equals(paramType.getName())) {
+ continue;
+ }
+ extValue += paramType.getName() + "=" + paramType.getValue() +
",";
+ }
+ if (extValue.length() != 0) {
+ extValue = extValue.substring(0, extValue.length() - 1);
+ }
switch (columnIndex) {
case 0:
return ((InputType) element).getType();
case 1:
return value;
+ case 2:
+ return extValue;
}
}
return "";
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/FileSelectionWizardPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -21,7 +21,7 @@
private ProtableFileStringProcessor processor = null;
public FileSelectionWizardPage(String pageName) {
- super(pageName);
+ super(pageName , new String[]{});
processor = new ProtableFileStringProcessor();
setFilePathProcessor(processor);
setTitle("File Selection");
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -47,4 +47,12 @@
public static final String IMAGE_MAPPING_LINE =
"icons/full/obj16/mapping_line.gif";
public static final String IMAGE_BINDING_LINE =
"icons/full/obj16/binding_line.gif";
+
+ public static final String IMAGE_UNKNOWN_OBJ =
"icons/full/obj16/unknown_obj.gif";
+
+ public static final String IMAGE_JAVA_FILE = "icons/full/obj16/jcu_obj.gif";
+
+ public static final String IMAGE_XML_FILE = "icons/full/obj16/XMLFile.gif";
+
+ public static final String IMAGE_XSD_FILE = "icons/full/obj16/XSDFile.gif";
}
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-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -51,7 +51,9 @@
import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
+import org.jboss.tools.smooks.configuration.editors.xml.XSDObjectAnalyzer;
import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks.model.graphics.ext.ParamType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
@@ -69,7 +71,7 @@
private Button fullPathButton;
private SelectorAttributes selectorAttributes = null;
private IEditorPart editorPart = null;
-
+
private FormToolkit toolkit;
public SelectoreSelectionDialog(IShellProvider parentShell) {
@@ -220,7 +222,6 @@
return composite;
}
-
private void handleButtons() {
fullPathButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -236,8 +237,8 @@
}
});
}
-
- public static List<Object> generateInputData(SmooksGraphicsExtType extType){
+
+ public static List<Object> generateInputData(SmooksGraphicsExtType extType) {
List<Object> list = new ArrayList<Object>();
if (extType != null) {
IJavaProject project = SmooksUIUtils.getJavaProject(extType);
@@ -257,13 +258,38 @@
if (model != null) {
list.add(model);
}
- }catch(Throwable t){
+ } catch (Throwable t) {
// ignore
}
}
+ if (SmooksModelUtils.INPUT_TYPE_XSD.equals(type)) {
+ try {
+ path = SmooksUIUtils.parseFilePath(path);
+ String rootElementName = null;
+ List<ParamType> paramers = inputType.getParam();
+ for (Iterator<?> iterator2 = paramers.iterator(); iterator2.hasNext();) {
+ ParamType paramType = (ParamType) iterator2.next();
+ if ("rootElement".equals(paramType.getName())) {
+ rootElementName = paramType.getValue();
+ break;
+ }
+ }
+ if (rootElementName != null) {
+ rootElementName = rootElementName.trim();
+ list.add(new XSDObjectAnalyzer().loadElement(path, rootElementName));
+ }
+ } catch (Throwable tt) {
+ // ingore
+ }
+ }
if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
try {
path = SmooksUIUtils.parseFilePath(path);
+
+ // XMLObjectAnalyzer analyzer = new
+ // XMLObjectAnalyzer();
+ // TagList doc = analyzer.analyze(path, null);
+
AbstractXMLObject model = new XMLObjectAnalyzer().analyze(path, null);
if (model != null) {
if (model instanceof TagList) {
@@ -304,7 +330,7 @@
wizard.setForcePreviousAndNextButtons(true);
StructuredDataSelectionWizardDailog dialog = new
StructuredDataSelectionWizardDailog(this.getShell(), wizard,
this.graphicsExt);
- if(dialog.show() == WizardDialog.OK){
+ if (dialog.show() == WizardDialog.OK) {
List<Object> input = this.generateInputData();
this.viewer.setInput(input);
SmooksUIUtils.expandSelectorViewer(input, viewer);
@@ -322,16 +348,17 @@
return selectorAttributes;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.dialogs.Dialog#close()
*/
@Override
public boolean close() {
- if(toolkit != null){
+ if (toolkit != null) {
toolkit.dispose();
}
return super.close();
}
-
-
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -137,6 +137,12 @@
TableColumn pathColumn = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
pathColumn.setText("Path");
pathColumn.setWidth(300);
+
+ TableColumn extColumn = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
+ extColumn.setText("Extension Paramers");
+ extColumn.setWidth(400);
+
+
inputDataViewer.setContentProvider(new ExtentionInputContentProvider());
inputDataViewer.setLabelProvider(new ExtentionInputLabelProvider());
inputDataViewer.getTable().setHeaderVisible(true);
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-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -144,13 +144,13 @@
TableColumn nameColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
nameColumn.setText("Class");
TableColumn isArrayColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
- isArrayColumn.setText("Array");
- TableColumn isListColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
- isListColumn.setText("List");
+ isArrayColumn.setText("Is Array");
+// TableColumn isListColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
+// isListColumn.setText("List");
nameColumn.setWidth(400);
isArrayColumn.setWidth(60);
- isListColumn.setWidth(60);
+// isListColumn.setWidth(60);
listViewer.getTable().setHeaderVisible(true);
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-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.uitls;
+import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -55,7 +56,6 @@
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalListener;
import org.eclipse.jface.fieldassist.IContentProposalListener2;
-import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -401,6 +401,9 @@
}
public static String parseFilePath(String path) throws InvocationTargetException {
+ if(new File(path).exists()){
+ return path;
+ }
int index = path.indexOf(FILE_PRIX);
if (index != -1) {
path = path.substring(index + FILE_PRIX.length(), path.length());
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -35,6 +35,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
/**
* @author Dart Peng
@@ -60,13 +61,21 @@
GridLayout gridLayout = new GridLayout();
main.setLayout(gridLayout);
- viewer = new TreeViewer(main, SWT.NONE);
+ Label label = new Label(main, SWT.NONE);
+ label.setText("Input Data Type");
+
+ viewer = new TreeViewer(main, SWT.BORDER);
viewer.setContentProvider(new WizardNodeContentProvider());
viewer.setLabelProvider(new WizardNodeLabelProvider());
GridData gd = new GridData(GridData.FILL_BOTH);
viewer.getTree().setLayoutData(gd);
createAllExtentionWizard();
-
+
+ Composite separatorComposite = new Composite(main,SWT.NONE);
+ gd = new GridData();
+ gd.heightHint = 12;
+ separatorComposite.setLayoutData(gd);
+
desLabel = new Label(main, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
desLabel.setLayoutData(gd);
@@ -150,8 +159,8 @@
public TransformDataWizardSelectionPage(String pageName) {
super(pageName);
- setDescription("Selection data type"); //$NON-NLS-1$
- setTitle("Selection data type"); //$NON-NLS-1$
+ setDescription("Choose \"Input Data Type\" to open wizard dialog to
select the input data."); //$NON-NLS-1$
+ setTitle("Input Data Selection"); //$NON-NLS-1$
}
@@ -161,16 +170,17 @@
private class WizardNodeLabelProvider extends LabelProvider {
- private HashMap<Object,Object> map = new HashMap<Object,Object>();
+ private HashMap<Object, Object> map = new HashMap<Object, Object>();
@Override
public Image getImage(Object element) {
if (element instanceof TransformSelectWizardNode) {
String path = ((TransformSelectWizardNode) element).getIconPath();
if (path != null) {
- Image icon = (Image) map.get(path);
+ Image icon =
SmooksConfigurationActivator.getDefault().getImageRegistry().get(path);
if (icon == null) {
-
+ }else{
+ return icon;
}
}
}
@@ -187,6 +197,12 @@
@Override
public void dispose() {
+ if(!map.values().isEmpty()){
+ for (Iterator<?> iterator = map.values().iterator(); iterator.hasNext();) {
+ Image img = (Image) iterator.next();
+ img.dispose();
+ }
+ }
super.dispose();
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -16,12 +16,14 @@
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanContentProvider;
+import
org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
-import
org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
import
org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataContentProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataLabelProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataWizard;
+import org.jboss.tools.smooks.configuration.editors.xml.XSDStructuredDataWizard;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
@@ -127,7 +129,7 @@
// for java
BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
String name = "Java";
- String description = "Browse a Java type";
+ String description = "Select a Java type(class,interface) as the input
data.";
String iconPath = null;
String typeID = SmooksModelUtils.INPUT_TYPE_JAVA;
@@ -138,13 +140,14 @@
javabeanViewerInitor.setLabelProvider(new JavabeanlabelProvider());
javabeanViewerInitor.setTreeContentProvider(new JavabeanContentProvider());
javabeanViewerInitor.setStructuredDataLoadWizard(new JavabeanStrucutredDataWizard());
+ javabeanViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
map.put(typeID, javabeanViewerInitor);
// for XML
BaseViewerInitor xmlViewerInitor = new BaseViewerInitor();
name = "XML";
- description = "Select a xml file ";
+ description = "Select a XML file to be the input data. ";
iconPath = null;
typeID = SmooksModelUtils.INPUT_TYPE_XML;
@@ -155,8 +158,28 @@
xmlViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
xmlViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
xmlViewerInitor.setStructuredDataLoadWizard(new XMLStructuredDataWizard());
+ xmlViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_XML_FILE);
map.put(typeID, xmlViewerInitor);
+ // for XSD
+
+ BaseViewerInitor xsdViewerInitor = new BaseViewerInitor();
+ name = "XSD/WSDL";
+ description = "Select a XSD file to be the input data. Need to figure out a Root
Element. ";
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_XSD;
+
+ xsdViewerInitor.setName(name);
+ xsdViewerInitor.setDescription(description);
+ xsdViewerInitor.setWizardIconPath(iconPath);
+ xsdViewerInitor.setTypeID(typeID);
+ xsdViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+ xsdViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+ xsdViewerInitor.setStructuredDataLoadWizard(new XSDStructuredDataWizard());
+ xsdViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_XSD_FILE);
+ map.put(typeID, xsdViewerInitor);
+
+
return map;
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -3,6 +3,7 @@
*/
package org.jboss.tools.smooks.configuration.editors.xml;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -10,6 +11,7 @@
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
@@ -33,8 +35,7 @@
*
* @author Dart Peng Date : 2008-8-13
*/
-public abstract class AbstractFileSelectionWizardPage extends WizardPage
- implements SelectionListener {
+public abstract class AbstractFileSelectionWizardPage extends WizardPage implements
SelectionListener {
protected IStructuredSelection selection;
protected Object returnObject = null;
protected Text fileText;
@@ -45,27 +46,59 @@
protected Button workspaceBrowseButton;
private String filePath = null;
protected Object[] initSelections;
- protected List<ViewerFilter> filters = null;
- protected boolean multiSelect =false;
-
+ protected List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
+ protected boolean multiSelect = false;
+
private IFilePathProcessor filePathProcessor = null;
-
- public AbstractFileSelectionWizardPage(String pageName,boolean multiSelect , Object[]
initSelections,List<ViewerFilter> filters) {
+
+ private String[] fileExtensionNames;
+
+ public AbstractFileSelectionWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters) {
super(pageName);
this.initSelections = initSelections;
- this.filters = filters;
+ if (filters != null) {
+ this.filters.addAll(filters);
+ }
this.multiSelect = multiSelect;
}
-
- public AbstractFileSelectionWizardPage(String pageName){
- this(pageName,false,null,Collections.EMPTY_LIST);
+
+ public AbstractFileSelectionWizardPage(String pageName, String[] fileExtensionNames) {
+ this(pageName, false, null, Collections.EMPTY_LIST);
+ this.fileExtensionNames = fileExtensionNames;
+ if (this.fileExtensionNames != null) {
+ ViewerFilter extensionNameFilter = new ViewerFilter() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse
+ * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof IFile &&
AbstractFileSelectionWizardPage.this.fileExtensionNames != null) {
+ String extName = ((IFile) element).getFileExtension();
+ for (int i = 0; i <
AbstractFileSelectionWizardPage.this.fileExtensionNames.length; i++) {
+ String name = AbstractFileSelectionWizardPage.this.fileExtensionNames[i];
+ if (name.equalsIgnoreCase(extName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ };
+ this.filters.add(extensionNameFilter);
+ }
}
-
public Object getReturnValue() {
try {
String path = getFilePath();
- if(path == null) return null;
+ if (path == null)
+ return null;
path = SmooksUIUtils.parseFilePath(path);
returnObject = this.loadedTheObject(path);
} catch (Exception e) {
@@ -73,12 +106,11 @@
}
return returnObject;
}
-
- public String getFilePath(){
+
+ public String getFilePath() {
return filePath;
}
-
-
+
public IFilePathProcessor getFilePathProcessor() {
return filePathProcessor;
}
@@ -90,7 +122,9 @@
/*
* (non-Javadoc)
*
- * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
*/
public void createControl(Composite parent) {
@@ -117,8 +151,7 @@
// xsdButton = new Button(mainComposite, SWT.RADIO);
// xsdButton.setText("Select a XSD file");
- Composite xsdComposite = this
- .createFileSelectionComposite(mainComposite);
+ createFileSelectionComposite(mainComposite);
// init the panel status (XSD file selection composite is disabled)
// xsdButton.setSelection(true);
@@ -167,12 +200,10 @@
};
- workspaceBrowseButton
- .addSelectionListener(wbrowseButtonSelectionAdapter);
+ workspaceBrowseButton.addSelectionListener(wbrowseButtonSelectionAdapter);
// xmlFileSystemBrowseButton
// .addSelectionListener(browseButtonSelectionAdapter);
- fileSystemBrowseButton
- .addSelectionListener(browseButtonSelectionAdapter);
+ fileSystemBrowseButton.addSelectionListener(browseButtonSelectionAdapter);
}
protected void openWorkSpaceSelection(Text relationT) {
@@ -185,22 +216,22 @@
relationT.setText(s);
}
}
-
- protected String processFileSystemFilePath(String path){
- if(filePathProcessor != null){
+
+ protected String processFileSystemFilePath(String path) {
+ if (filePathProcessor != null) {
String s = filePathProcessor.processFileSystemPath(path);
- if(s != null){
+ if (s != null) {
return s;
}
}
path = SmooksUIUtils.FILE_PRIX + path;
return path;
}
-
- protected String processWorkSpaceFilePath(IFile file){
- if(filePathProcessor != null){
- String s = filePathProcessor.processWorkBenchPath(file);
- if(s != null){
+
+ protected String processWorkSpaceFilePath(IFile file) {
+ if (filePathProcessor != null) {
+ String s = filePathProcessor.processWorkBenchPath(file);
+ if (s != null) {
return s;
}
}
@@ -209,19 +240,9 @@
return s;
}
- protected Composite createFileSelectionComposite(Composite parent) {
- Composite xsdComposite = new Composite(parent, SWT.NONE);
+ protected Text createFilePathText(Composite parent) {
+ fileTextComposite = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- xsdComposite.setLayoutData(gd);
- GridLayout xsdLayout = new GridLayout();
- xsdLayout.numColumns = 2;
- xsdLayout.marginWidth = 0;
- xsdComposite.setLayout(xsdLayout);
-
- Label nfileLanel = new Label(xsdComposite, SWT.NONE);
- nfileLanel.setText("File : "); //$NON-NLS-1$
- fileTextComposite = new Composite(xsdComposite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
fileTextComposite.setLayoutData(gd);
GridLayout xsdtgl = new GridLayout();
@@ -230,31 +251,62 @@
xsdtgl.numColumns = 1;
fileTextComposite.setLayout(xsdtgl);
- fileText = new Text(fileTextComposite, SWT.BORDER);
+ Text fileText = new Text(fileTextComposite, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
fileText.setLayoutData(gd);
gd.grabExcessHorizontalSpace = true;
-// final Button loadXSDButton = new Button(fileTextComposite, SWT.NONE);
-// loadXSDButton.setText("Load");
-// loadXSDButton.addSelectionListener(new SelectionAdapter() {
-//
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-// super.widgetSelected(e);
-// reasourceLoaded = false;
-// try {
-// returnObject = loadedTheObject(fileText.getText());
-// reasourceLoaded = true;
-// } catch (Throwable e2) {
-// // ignore
-// e2.printStackTrace();
-// }
-// changeWizardPageStatus();
-// }
-//
-// });
+ return fileText;
+ }
+ protected Composite createFileSelectionComposite(Composite parent) {
+ Composite xsdComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ xsdComposite.setLayoutData(gd);
+ GridLayout xsdLayout = new GridLayout();
+ xsdLayout.numColumns = 2;
+ xsdLayout.marginWidth = 0;
+ xsdComposite.setLayout(xsdLayout);
+
+ Label nfileLanel = new Label(xsdComposite, SWT.NONE);
+ nfileLanel.setText("File : "); //$NON-NLS-1$
+ // fileTextComposite = new Composite(xsdComposite, SWT.NONE);
+ // gd = new GridData(GridData.FILL_HORIZONTAL);
+ // gd.grabExcessHorizontalSpace = true;
+ // fileTextComposite.setLayoutData(gd);
+ // GridLayout xsdtgl = new GridLayout();
+ // xsdtgl.marginWidth = 0;
+ // xsdtgl.marginHeight = 0;
+ // xsdtgl.numColumns = 1;
+ // fileTextComposite.setLayout(xsdtgl);
+ //
+ // fileText = new Text(fileTextComposite, SWT.BORDER);
+ // gd = new GridData(GridData.FILL_HORIZONTAL);
+ // fileText.setLayoutData(gd);
+ // gd.grabExcessHorizontalSpace = true;
+
+ fileText = createFilePathText(xsdComposite);
+
+ // final Button loadXSDButton = new Button(fileTextComposite, SWT.NONE);
+ // loadXSDButton.setText("Load");
+ // loadXSDButton.addSelectionListener(new SelectionAdapter() {
+ //
+ // @Override
+ // public void widgetSelected(SelectionEvent e) {
+ // super.widgetSelected(e);
+ // reasourceLoaded = false;
+ // try {
+ // returnObject = loadedTheObject(fileText.getText());
+ // reasourceLoaded = true;
+ // } catch (Throwable e2) {
+ // // ignore
+ // e2.printStackTrace();
+ // }
+ // changeWizardPageStatus();
+ // }
+ //
+ // });
+
Composite browseButtonComposite = new Composite(xsdComposite, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
@@ -287,27 +339,27 @@
abstract protected Object loadedTheObject(String path) throws Exception;
protected void initTableViewer() {
-// tableViewer.addCheckStateListener(new ICheckStateListener() {
-// boolean flag = true;
-//
-// public void checkStateChanged(CheckStateChangedEvent event) {
-// if (flag) {
-// Object checkObject = event.getElement();
-// boolean check = event.getChecked();
-// flag = false;
-// tableViewer.setAllChecked(false);
-// tableViewer.setChecked(checkObject, check);
-// flag = true;
-// changeWizardPageStatus();
-// }
-// }
-// });
-// tableViewer.setContentProvider(new XSDStructuredModelContentProvider());
-// tableViewer.setLabelProvider(new XSDStructuredModelLabelProvider());
+ // tableViewer.addCheckStateListener(new ICheckStateListener() {
+ // boolean flag = true;
+ //
+ // public void checkStateChanged(CheckStateChangedEvent event) {
+ // if (flag) {
+ // Object checkObject = event.getElement();
+ // boolean check = event.getChecked();
+ // flag = false;
+ // tableViewer.setAllChecked(false);
+ // tableViewer.setChecked(checkObject, check);
+ // flag = true;
+ // changeWizardPageStatus();
+ // }
+ // }
+ // });
+ // tableViewer.setContentProvider(new
+ // XSDStructuredModelContentProvider());
+ // tableViewer.setLabelProvider(new XSDStructuredModelLabelProvider());
}
- protected void setCompositeChildrenEnabled(Composite composite,
- boolean enabled) {
+ protected void setCompositeChildrenEnabled(Composite composite, boolean enabled) {
Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++) {
Control child = children[i];
@@ -325,11 +377,22 @@
protected void openFileSelection(Text relationText) {
FileDialog dialog = new FileDialog(this.getShell());
+ if (fileExtensionNames != null) {
+ String s = "";
+ for (int i = 0; i < fileExtensionNames.length; i++) {
+ String exname = fileExtensionNames[i];
+ s += "*." + exname + ";";
+ }
+ if (s.length() != 0) {
+ s = s.substring(0, s.length() - 1);
+ dialog.setFilterExtensions(new String[]{s,"*.*"});
+ }
+ }
String path = dialog.open();
if (path != null) {
path = processFileSystemFilePath(path);
relationText.setText(path);
- }
+ }
}
protected void changeWizardPageStatus() {
@@ -337,15 +400,15 @@
String error = null;
if (text == null || "".equals(text)) //$NON-NLS-1$
error = "File's name can be null"; //$NON-NLS-1$
-
-// File tempFile = new File(text);
-// if(!tempFile.exists()){
-// error = "Can't find the file , please select another one.";
-// }
-
-// if (!reasourceLoaded) {
-// error = "Resource must be loaded";
-// }
+
+ // File tempFile = new File(text);
+ // if(!tempFile.exists()){
+ // error = "Can't find the file , please select another one.";
+ // }
+
+ // if (!reasourceLoaded) {
+ // error = "Resource must be loaded";
+ // }
this.setErrorMessage(error);
this.setPageComplete(error == null);
@@ -398,7 +461,5 @@
public void setMultiSelect(boolean multiSelect) {
this.multiSelect = multiSelect;
}
-
-
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ExtensibilityElement;
+import org.eclipse.wst.wsdl.Types;
+import org.eclipse.wst.wsdl.WSDLFactory;
+import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
+import org.eclipse.wst.wsdl.util.WSDLParser;
+import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDSchema;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class WSDLObjectAnalyzer {
+ private XSDObjectAnalyzer xsdAnalyzer = new XSDObjectAnalyzer();
+
+ public static List<XSDElementDeclaration> loadAllElement(String filePath) throws
InvocationTargetException,
+ IOException, ParserConfigurationException, SAXException {
+
+ List<XSDElementDeclaration> nl = new ArrayList<XSDElementDeclaration>();
+ String file = SmooksUIUtils.parseFilePath(filePath);
+ WSDLParser parser = new WSDLParser();
+ parser.parse(new FileInputStream(file));
+ final Document document = parser.getDocument();
+ final Definition definition = WSDLFactory.eINSTANCE.createDefinition();
+ definition.setDocumentBaseURI(URI.createFileURI(file).toString());
+ definition.setDocument(document);
+ final ResourceSet resourceSet = new ResourceSetImpl();
+ final Resource resource = new WSDLResourceImpl(URI.createFileURI(file));
+ resourceSet.getResources().add(resource);
+ resource.getContents().add(definition);
+
+ resource.setModified(false);
+
+ IRunnableWithProgress setElementOperation = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
+ monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ definition.setElement(document.getDocumentElement());
+ }
+ };
+
+ IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
+ try {
+ progressService.busyCursorWhile(setElementOperation);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ // Resource resource = new WSDLResourceImpl(URI.createFileURI(file));
+ // List<XSDElementDeclaration> list = schema.getElementDeclarations();
+ // for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ // XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)
+ // iterator.next();
+ // if (elementDeclaration.isAbstract())
+ // continue;
+ // nl.add(elementDeclaration);
+ // }
+ Types types = definition.getETypes();
+ if (types != null) {
+ XSDSchemaExtensibilityElement el = null;
+ for (Iterator<?> j = types.getEExtensibilityElements().iterator(); j.hasNext();)
{
+ ExtensibilityElement extensibilityElement = (ExtensibilityElement) j.next();
+ if (!(extensibilityElement instanceof XSDSchemaExtensibilityElement)) {
+ continue;
+ }
+
+ el = (XSDSchemaExtensibilityElement) extensibilityElement;
+ XSDSchema schema = el.getSchema();
+ if (schema != null) {
+ List<XSDElementDeclaration> list = schema.getElementDeclarations();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)
iterator.next();
+ if (elementDeclaration.isAbstract())
+ continue;
+ nl.add(elementDeclaration);
+ }
+ break;
+ }
+ }
+ }
+ return nl;
+ }
+
+ public TagObject loadElement(String path, String rootElementName) throws IOException {
+ WSDLResourceImpl resource = new WSDLResourceImpl(URI.createFileURI(path));
+ resource.load(Collections.emptyMap());
+ if (resource.getContents().isEmpty()) {
+ return null;
+ }
+ Object obj = resource.getContents().get(0);
+ // xsdAnalyzer.loadElement(schema, rootElementName);
+ return null;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -9,7 +9,7 @@
public class XMLStructuredDataWizardPage extends AbstractFileSelectionWizardPage {
public XMLStructuredDataWizardPage(String pageName) {
- super(pageName);
+ super(pageName,new
String[]{"xml","xsd","wsdl","xsl"});
setPageText();
}
@@ -28,8 +28,9 @@
*/
@Override
protected Object loadedTheObject(String path) throws Exception {
- XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
- TagList doc = analyzer.analyze(path, null);
- return doc;
+ return null;
+// XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
+// TagList doc = analyzer.analyze(path, null);
+// return doc;
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java 2009-06-16
22:17:31 UTC (rev 16000)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -10,10 +10,278 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.xml;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xsd.XSDAttributeDeclaration;
+import org.eclipse.xsd.XSDAttributeUse;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDModelGroup;
+import org.eclipse.xsd.XSDParticle;
+import org.eclipse.xsd.XSDParticleContent;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDTypeDefinition;
+import org.eclipse.xsd.util.XSDResourceFactoryImpl;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+
/**
* @author Dart (dpeng(a)redhat.com)
- *
+ *
*/
public class XSDObjectAnalyzer {
+ // private static List<XSDElementDeclaration> findChildrenElement(XSDSchema
+ // schema, XSDElementDeclaration baseElement) {
+ // return findChildrenElement(schema, baseElement.getTypeDefinition());
+ // }
+ private HashMap<Object, Object> tagObjectBuffer = new HashMap<Object,
Object>();
+
+ public static List<XSDElementDeclaration> loadAllElement(String filePath) throws
InvocationTargetException, IOException {
+ List<XSDElementDeclaration> nl = new ArrayList<XSDElementDeclaration>();
+ String file = SmooksUIUtils.parseFilePath(filePath);
+ Resource resource = new
XSDResourceFactoryImpl().createResource(URI.createFileURI(file));
+ resource.load(Collections.EMPTY_MAP);
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ List<XSDElementDeclaration> list = schema.getElementDeclarations();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) iterator.next();
+ if (elementDeclaration.isAbstract())
+ continue;
+ nl.add(elementDeclaration);
+ }
+ return nl;
+ }
+
+ private List<XSDElementDeclaration> findChildrenElement(XSDSchema schema,
XSDTypeDefinition baseTypeDefinition) {
+ List<XSDElementDeclaration> elementList = new
ArrayList<XSDElementDeclaration>();
+ List<XSDElementDeclaration> elements = schema.getElementDeclarations();
+ for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();) {
+ XSDElementDeclaration elementDec = (XSDElementDeclaration) iterator.next();
+ if (elementDec.isAbstract())
+ continue;
+ XSDTypeDefinition td = elementDec.getType();
+ XSDSimpleTypeDefinition st = td.getSimpleType();
+ if (st != null) {
+ continue;
+ }
+ if (td instanceof XSDComplexTypeDefinition) {
+ XSDTypeDefinition tdd = td.getBaseType();
+ if (tdd == baseTypeDefinition) {
+ elementList.add(elementDec);
+ }
+ } else {
+ // XSDSimpleTypeDefinition stype = td.getSimpleType();
+ // System.out.println("Simple Type :" +stype.toString());
+ }
+ }
+ if (elementList.isEmpty())
+ return null;
+ return elementList;
+ }
+
+ public TagObject loadElement(XSDSchema schema, String rootElementName) throws
IOException {
+ List<XSDElementDeclaration> elements = schema.getElementDeclarations();
+ for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();) {
+ XSDElementDeclaration elementDec = (XSDElementDeclaration) iterator.next();
+ if (rootElementName.equals(elementDec.getAliasName())) {
+ tagObjectBuffer.clear();
+ return loadElement(schema, elementDec);
+ }
+ }
+ return null;
+ }
+
+ public TagObject loadElement(String filePath, String rootElementName) throws
InvocationTargetException, IOException {
+ tagObjectBuffer.clear();
+ Resource resource = new
XSDResourceFactoryImpl().createResource(URI.createFileURI(filePath));
+ resource.load(Collections.EMPTY_MAP);
+ if (resource.getContents().isEmpty())
+ return null;
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ return loadElement(schema, rootElementName);
+ }
+
+ public TagObject loadElement(String filePath, XSDElementDeclaration rootElement) throws
InvocationTargetException,
+ IOException {
+ tagObjectBuffer.clear();
+ Resource resource = new
XSDResourceFactoryImpl().createResource(URI.createFileURI(filePath));
+ resource.load(Collections.EMPTY_MAP);
+ if (resource.getContents().isEmpty())
+ return null;
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ return loadElement(schema, rootElement);
+ }
+
+ private TagObject loadElement(XSDSchema schema, XSDElementDeclaration elementDec) {
+ if (elementDec.isAbstract())
+ return null;
+
+ TagObject tag = (TagObject) tagObjectBuffer.get(elementDec);
+ if (tag == null) {
+ tag = new TagObject();
+ tag.setName(elementDec.getAliasName());
+ tag.setNamespaceURL(elementDec.getAliasURI());
+ tagObjectBuffer.put(elementDec, tag);
+ }else{
+ return tag;
+ }
+
+ XSDTypeDefinition td = elementDec.getType();
+ XSDSimpleTypeDefinition st = td.getSimpleType();
+ // XSDComplexTypeDefinition ct = td.getComplexType();
+ if (st != null) {
+ }
+ if (td instanceof XSDComplexTypeDefinition) {
+ XSDComplexTypeDefinition ctype = (XSDComplexTypeDefinition) td;
+ XSDParticle xsdparticle = td.getComplexType();
+ if (xsdparticle != null) {
+ XSDParticleContent term = xsdparticle.getContent();// .getTerm
+ // ();
+ if (term instanceof XSDModelGroup) {
+ List<?> list = ((XSDModelGroup) term).getParticles();
+ for (Iterator<?> iterator2 = list.iterator(); iterator2.hasNext();) {
+ XSDParticle xp = (XSDParticle) iterator2.next();
+ XSDParticleContent content = xp.getContent();
+ if (content instanceof XSDElementDeclaration) {
+ XSDElementDeclaration child = (XSDElementDeclaration) content;
+ List<XSDElementDeclaration> childElement = null;
+ if (child.isElementDeclarationReference()) {
+ child = child.getResolvedElementDeclaration();
+ }
+ XSDTypeDefinition childType = child.getTypeDefinition();
+ if (child.isAbstract()) {
+ childElement = findChildrenElement(schema, childType);
+ if (childElement != null) {
+ for (Iterator<?> iterator3 = childElement.iterator();
iterator3.hasNext();) {
+ XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) iterator3
+ .next();
+ TagObject childTag = loadElement(schema, elementDeclaration);
+ if (childTag != null) {
+ tag.addChildTag(childTag);
+ }
+ }
+ }
+ } else {
+ TagObject childTag = loadElement(schema, child);
+ if (childTag != null) {
+ tag.addChildTag(childTag);
+ }
+ }
+ }
+ }
+ }
+ }
+ List<?> attributeContents = ctype.getAttributeContents();
+ for (Iterator<?> iterator2 = attributeContents.iterator(); iterator2.hasNext();)
{
+ XSDAttributeUse attributeUse = (XSDAttributeUse) iterator2.next();
+ XSDAttributeDeclaration attribute = attributeUse.getAttributeDeclaration();
+ TagPropertyObject tp = new TagPropertyObject();
+ tp.setName(attribute.getAliasName());
+ tp.setNamespaceURL(attribute.getTypeDefinition().getURI());
+ tag.addProperty(tp);
+ }
+ } else {
+ // XSDSimpleTypeDefinition stype = td.getSimpleType();
+ // System.out.println("Simple Type :" +stype.toString());
+ }
+
+ return tag;
+ }
+
+ public static void main(String[] args) throws IOException {
+ Resource resource = new
XSDResourceFactoryImpl().createResource(URI.createFileURI("F:/smooks-1.1.xsd"));
+ resource.load(Collections.EMPTY_MAP);
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ TagObject rootTag = new XSDObjectAnalyzer().loadElement(schema,
"smooks-resource-list");
+ System.out.println(rootTag);
+ // List<XSDElementDeclaration> elements =
+ // schema.getElementDeclarations();
+ // for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();)
+ // {
+ // XSDElementDeclaration elementDec = (XSDElementDeclaration)
+ // iterator.next();
+ // if (elementDec.isAbstract())
+ // continue;
+ // XSDTypeDefinition td = elementDec.getType();
+ // XSDSimpleTypeDefinition st = td.getSimpleType();
+ // System.out.println("Element Name :" + elementDec.getAliasName());
+ // // XSDComplexTypeDefinition ct = td.getComplexType();
+ // if (st != null) {
+ // System.out.println("\tSimple Type :" + st.toString());
+ // }
+ // if (td instanceof XSDComplexTypeDefinition) {
+ // XSDComplexTypeDefinition ctype = (XSDComplexTypeDefinition) td;
+ //
+ // XSDParticle xsdparticle = td.getComplexType();
+ // XSDTypeDefinition tdd = td.getBaseType();
+ // String tds = "";
+ // if (tdd != null) {
+ // tds = tdd.getAliasName();
+ // }
+ // if (xsdparticle != null) {
+ // XSDParticleContent term = xsdparticle.getContent();// .getTerm
+ // // ();
+ // if (term instanceof XSDModelGroup) {
+ // List<?> list = ((XSDModelGroup) term).getParticles();
+ // for (Iterator<?> iterator2 = list.iterator(); iterator2.hasNext();) {
+ // XSDParticle xp = (XSDParticle) iterator2.next();
+ // XSDParticleContent content = xp.getContent();
+ // if (content instanceof XSDElementDeclaration) {
+ // XSDElementDeclaration child = (XSDElementDeclaration) content;
+ // String refStr = "";
+ // List<XSDElementDeclaration> childElement = null;
+ // if (child.isElementDeclarationReference()) {
+ // child = child.getResolvedElementDeclaration();
+ // refStr = "Reference";
+ // }
+ // XSDTypeDefinition childType = child.getTypeDefinition();
+ // if (child.isAbstract()) {
+ // childElement = findChildrenElement(schema, childType);
+ // if(childElement != null){
+ // for (Iterator<?> iterator3 = childElement.iterator();
+ // iterator3.hasNext();) {
+ // XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)
+ // iterator3
+ // .next();
+ // System.out.println("\t" + refStr + "Element Name: " +
+ // elementDeclaration.getAliasName() + " - "
+ // + childType.getAliasName());
+ // }
+ // }
+ // } else {
+ // System.out.println("\t" + refStr + "Element Name: " +
+ // child.getAliasName() + " - "
+ // + childType.getAliasName());
+ // }
+ // }
+ // }
+ // }
+ // }
+ // List<?> attributeContents = ctype.getAttributeContents();
+ // for (Iterator<?> iterator2 = attributeContents.iterator();
+ // iterator2.hasNext();) {
+ // XSDAttributeUse attributeUse = (XSDAttributeUse) iterator2.next();
+ // XSDAttributeDeclaration attribute =
+ // attributeUse.getAttributeDeclaration();
+ // System.out.println("\tAttributes :" + attribute.getAliasName() +
+ // " - "
+ // + attribute.getTypeDefinition().getQName());
+ // }
+ // continue;
+ // } else {
+ // // XSDSimpleTypeDefinition stype = td.getSimpleType();
+ // // System.out.println("Simple Type :" +stype.toString());
+ // }
+ // System.out.println();
+ // }
+ }
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.util.Properties;
+
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class XSDStructuredDataWizard extends AbstractStructuredDdataWizard {
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.xml.AbstractStructuredDdataWizard#createAbstractFileSelectionWizardPage()
+ */
+ @Override
+ protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
+ // TODO Auto-generated method stub
+ return new XSDStructuredDataWizardPage("XSD");
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ return SmooksModelUtils.INPUT_TYPE_XSD;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard#getProperties()
+ */
+ public Properties getProperties() {
+ Properties pro = new Properties();
+ pro.setProperty("rootElement",
((XSDStructuredDataWizardPage)page).getRootElementName());
+ return pro;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizardPage.java 2009-06-17
07:16:58 UTC (rev 16001)
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class XSDStructuredDataWizardPage extends AbstractFileSelectionWizardPage {
+
+ private CheckboxTableViewer tableViewer = null;
+
+ private boolean fireEvent = true;
+
+ private String rootElementName = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public XSDStructuredDataWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName, multiSelect, initSelections, filters);
+ this.setTitle("XSD Input Data Selection");
+ this.setDescription("Select a XSD file to be the input data");
+ }
+
+ public XSDStructuredDataWizardPage(String pageName) {
+ super(pageName, new String[] { "xsd", "wsdl" });
+ this.setTitle("XSD Input Data Selection");
+ this.setDescription("Select a XSD file to be the input data");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage#changeWizardPageStatus()
+ */
+ @Override
+ protected void changeWizardPageStatus() {
+ super.changeWizardPageStatus();
+ String errorMessage = this.getErrorMessage();
+ if (errorMessage == null) {
+ if (reasourceLoaded) {
+ if(tableViewer.getCheckedElements() == null ||
tableViewer.getCheckedElements().length == 0){
+ errorMessage = "Must select a root element.";
+ }
+ } else {
+ errorMessage = "The elements of XSD file should click the 'Load' button
to load.";
+ }
+ setErrorMessage(errorMessage);
+ setPageComplete(errorMessage == null);
+ }
+ }
+
+ /**
+ * @return the rootElementName
+ */
+ public String getRootElementName() {
+ return rootElementName;
+ }
+
+ /**
+ * @param rootElementName
+ * the rootElementName to set
+ */
+ public void setRootElementName(String rootElementName) {
+ this.rootElementName = rootElementName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage
+ * #createFilePathText(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Text createFilePathText(Composite parent) {
+ fileTextComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ fileTextComposite.setLayoutData(gd);
+ GridLayout xsdtgl = new GridLayout();
+ xsdtgl.marginWidth = 0;
+ xsdtgl.marginHeight = 0;
+ xsdtgl.numColumns = 2;
+ fileTextComposite.setLayout(xsdtgl);
+
+ final Text fileText = new Text(fileTextComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ fileText.addModifyListener(new ModifyListener(){
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ reasourceLoaded = false;
+ if(tableViewer != null){
+ tableViewer.setInput(Collections.emptyList());
+ }
+ }
+
+ });
+ gd.grabExcessHorizontalSpace = true;
+
+ final Button loadXSDButton = new Button(fileTextComposite, SWT.NONE);
+ loadXSDButton.setText("Load");
+ loadXSDButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ if(fileText.getText() == null || fileText.getText().length() == 0){
+ changeWizardPageStatus();
+ return;
+ }
+ reasourceLoaded = false;
+ try {
+ List<?> list = loadElement(fileText.getText());
+ tableViewer.setInput(list);
+ reasourceLoaded = true;
+ } catch (Throwable e2) {
+ e2.printStackTrace();
+ }
+ changeWizardPageStatus();
+ }
+
+ });
+ return fileText;
+ }
+
+ private List<XSDElementDeclaration> loadElement(String path) throws
InvocationTargetException, IOException {
+ if (path == null)
+ return null;
+ String pp = path.toLowerCase();
+ if (pp.endsWith(".wsdl")) {
+ try {
+ return WSDLObjectAnalyzer.loadAllElement(path);
+ } catch (ParserConfigurationException e) {
+ throw new InvocationTargetException(e);
+ } catch (SAXException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ return XSDObjectAnalyzer.loadAllElement(path);
+ }
+
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ Composite mainComposite = (Composite) getControl();
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ Label label = new Label(mainComposite, SWT.NONE);
+ label.setLayoutData(gd);
+ label.setText("Select root element");
+ tableViewer = CheckboxTableViewer.newCheckList(mainComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 250;
+ tableViewer.getControl().setLayoutData(gd);
+
+ tableViewer.setContentProvider(new XSDListContentProvider());
+ tableViewer.setLabelProvider(new XSDListLabelProvider());
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
+ * (org.eclipse.jface.viewers.CheckStateChangedEvent)
+ */
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (!fireEvent)
+ return;
+ rootElementName = null;
+ fireEvent = false;
+ tableViewer.setAllChecked(false);
+ if (event.getChecked()) {
+ tableViewer.setChecked(event.getElement(), true);
+ rootElementName = ((XSDElementDeclaration) event.getElement()).getAliasName();
+ }
+ fireEvent = true;
+ changeWizardPageStatus();
+ }
+
+ });
+
+ }
+
+ private class XSDListLabelProvider extends LabelProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if (element instanceof XSDElementDeclaration) {
+ return ((XSDElementDeclaration) element).getAliasName();
+ }
+ return super.getText(element);
+ }
+
+ }
+
+ private class XSDListContentProvider implements IStructuredContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.IStructuredContentProvider#getElements(
+ * java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<?>) inputElement).toArray();
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
+ * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain