Author: DartPeng
Date: 2009-04-12 13:57:11 -0400 (Sun, 12 Apr 2009)
New Revision: 14696
Added:
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/AbstractStructuredDdataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.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/editors/Codegenerator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.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/ViewerInitorStore.java
Log:
Add new feature for smooks-configuration-editor:
1.Add input data path
2.Show editor to select input data and transform the data to "selector"
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-04-12
11:09:30 UTC (rev 14695)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-04-12
17:57:11 UTC (rev 14696)
@@ -22,3 +22,5 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
+Bundle-ClassPath: libs/dom4j-1.6.1.jar,
+ .
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -13,17 +13,18 @@
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
public class Codegenerator {
- String basePath =
"/home/Dart/Works/eclipse_wtp.3.0.4/eclipse/workspace/jbosstools/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/temp/";
+ String basePath =
"/home/DartPeng/Work/eclipse/new-smooks-editor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/temp";
String tempContents = "";
public Codegenerator() {
try {
FileReader reader = new FileReader(
- new File(
- "/home/DartPeng/Work/eclipse/new-smooks-editor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt"));
+ new File(
+ "/home/DartPeng/Work/eclipse/new-smooks-editor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt"));
BufferedReader r = new BufferedReader(reader);
String line = r.readLine();
while (line != null) {
@@ -43,7 +44,7 @@
public static void main(String[] args) {
Codegenerator g = new Codegenerator();
try {
- g.generateCodes(SmooksPackage.eINSTANCE);
+ g.generateCodes(JavabeanPackage.eINSTANCE);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
@@ -53,8 +54,8 @@
}
}
- public void generateCodes(EPackage epackage) throws IllegalArgumentException,
- IllegalAccessException, IOException {
+ public void generateCodes(EPackage epackage) throws IllegalArgumentException,
IllegalAccessException,
+ IOException {
Field[] fields = epackage.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
@@ -66,7 +67,8 @@
continue;
}
File file = new File(basePath + eClass.getName() + "UICreator.java");
- System.out.println("map.put("+eClass.getName()+"Impl.class, new
"+eClass.getName()+"UICreator());");
+ System.out.println("map.put(" + eClass.getName() + "Impl.class, new
" + eClass.getName()
+ + "UICreator());");
if (!file.exists()) {
file.createNewFile();
FileWriter writer = new FileWriter(file);
@@ -83,8 +85,7 @@
String t = tempContents;
if (t.indexOf("${className}") != -1) {
String s = t.substring(0, t.indexOf("${className}"));
- String es = t.substring(t.indexOf("${className}") +
"${className}".length(), t
- .length());
+ String es = t.substring(t.indexOf("${className}") +
"${className}".length(), t.length());
t = s + className + es;
}
String epName = ePackage.getClass().getSimpleName();
@@ -98,9 +99,9 @@
for (Iterator<?> iterator = alist.iterator(); iterator.hasNext();) {
EAttribute attribute = (EAttribute) iterator.next();
String atn = attribute.getName();
- String firstC = new String(new char[]{ atn.toCharArray()[0] });
+ String firstC = new String(new char[] { atn.toCharArray()[0] });
firstC = firstC.toUpperCase();
- atn = firstC + atn.substring(1,atn.length());
+ atn = firstC + atn.substring(1, atn.length());
String n = allepName + "_" + atn + "()";
String cn = "if(feature == " + n + "){}\n";
attributeMethod += cn;
@@ -108,7 +109,7 @@
int index2 = t.indexOf("${attributeMethod}");
if (index2 != -1) {
String am1 = t.substring(0, index2);
- String am2 = t.substring(index2 + "${attributeMethod}".length() ,
t.length());
+ String am2 = t.substring(index2 + "${attributeMethod}".length(),
t.length());
t = am1 + attributeMethod + am2;
}
return t;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -24,16 +24,22 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.custom.CCombo;
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.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModel;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModelFactory;
import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.editors.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.model.graphics.ext.InputType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
@@ -70,10 +76,25 @@
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 400;
- gd.widthHint = 400;
+ gd.heightHint = 500;
+ gd.widthHint = 450;
composite.setLayoutData(gd);
- composite.setLayout(new FillLayout());
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 10;
+ layout.marginWidth = 10;
+ layout.makeColumnsEqualWidth = false;
+ composite.setLayout(layout);
+
+ Label label = new Label(composite,SWT.NONE);
+ label.setText("Sperator Char : ");
+ CCombo speratorCombo = new CCombo(composite,SWT.BORDER);
+ speratorCombo.add(" ");
+ speratorCombo.add("/");
+ speratorCombo.setEditable(false);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ speratorCombo.setLayoutData(gd);
+
viewer = new TreeViewer(composite, SWT.BORDER);
viewer.setContentProvider(new CompoundStructuredDataContentProvider());
viewer.setLabelProvider(new CompoundStructuredDataLabelProvider());
@@ -88,7 +109,33 @@
currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
}
});
- getShell().setText("Input Datas");
+
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ viewer.getTree().setLayoutData(gd);
+
+ Label l = new Label(composite,SWT.NONE);
+ l.setText("Selector generate policy : ");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ l.setLayoutData(gd);
+
+ Composite com = new Composite(composite,SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ com.setLayoutData(gd);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 3;
+ com.setLayout(gl);
+ Button fullPathButton = new Button(com,SWT.RADIO);
+ fullPathButton.setText("Full Path");
+ Button onlyNameButton = new Button(com,SWT.RADIO);
+ onlyNameButton.setText("Only Name");
+ Button containtParentButton = new Button(com,SWT.RADIO);
+ containtParentButton.setText("Containt Parent Name");
+
+ getShell().setText("Selector generate dialog");
return composite;
}
@@ -117,7 +164,24 @@
}
}
if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
+ try {
+ path = SmooksUIUtils.parseFilePath(path);
+ AbstractXMLObject model = new XMLObjectAnalyzer().analyze(path, null);
+ if (model != null) {
+ if (model instanceof TagList) {
+ List<IXMLStructuredObject> children = ((TagList) model).getChildren();
+ for (Iterator<?> iterator2 = children.iterator(); iterator2.hasNext();)
{
+ IXMLStructuredObject structuredObject = (IXMLStructuredObject) iterator2
+ .next();
+ list.add(structuredObject);
+ }
+ } else {
+ list.add(model);
+ }
+ }
+ } finally {
+ }
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -18,6 +18,7 @@
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
/**
@@ -52,10 +53,16 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEdtior) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == JavabeanPackage.eINSTANCE.getBindingsType_Class()) {
return createBeanClassTextWithButton(parent, toolkit, propertyDescriptor, model);
}
+ if(feature == JavabeanPackage.eINSTANCE.getBindingsType_CreateOnElement()){
+ SmooksGraphicsExtType ext = formEditor.getSmooksGraphicsExt();
+ if (ext != null)
+ return SmooksUIUtils.createSelectorFieldEditor(toolkit, parent, propertyDescriptor,
model,
+ ext);
+ }
return null;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -98,7 +98,10 @@
gd.heightHint = 400;
gd.widthHint = 400;
composite.setLayoutData(gd);
- composite.setLayout(new FillLayout());
+ FillLayout fl = new FillLayout();
+ fl.marginHeight = 10;
+ fl.marginWidth = 10;
+ composite.setLayout(fl);
viewer = new TableViewer(composite, SWT.BORDER);
Table table = viewer.getTable();
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -98,7 +98,10 @@
gd.heightHint = 400;
gd.widthHint = 400;
composite.setLayoutData(gd);
- composite.setLayout(new FillLayout());
+ FillLayout fl = new FillLayout();
+ fl.marginHeight = 10;
+ fl.marginWidth = 10;
+ composite.setLayout(fl);
viewer = new TableViewer(composite, SWT.BORDER);
Table table = viewer.getTable();
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -11,6 +11,12 @@
package org.jboss.tools.smooks.configuration.editors.javabean;
import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
@@ -37,4 +43,23 @@
return super.canCreateMethodsSearchFieldEditor(feature);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.javabean.PropertiesAndSetterMethodSearchFieldEditorCreator#createPropertyUI(org.eclipse.ui.forms.widgets.FormToolkit,
org.eclipse.swt.widgets.Composite, org.eclipse.emf.edit.provider.IItemPropertyDescriptor,
java.lang.Object, org.eclipse.emf.ecore.EAttribute,
org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor)
+ */
+ @Override
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
+ if(feature == JavabeanPackage.eINSTANCE.getValueType_Data()){
+ SmooksGraphicsExtType ext = formEditor.getSmooksGraphicsExt();
+ if (ext != null)
+ return SmooksUIUtils.createSelectorFieldEditor(toolkit, parent, propertyDescriptor,
model,
+ ext);
+
+ }
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature,
formEditor);
+ }
+
+
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -47,7 +47,7 @@
return name;
}
- return super.getText(element);
+ return "";
}
@Override
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java 2009-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -102,7 +102,7 @@
URL[] urls = new URL[list.size()];
int index = 0;
- for (Iterator i = list.iterator(); i.hasNext(); index++) {
+ for (Iterator<?> i = list.iterator(); i.hasNext(); index++) {
urls[index] = (URL) i.next();
}
return urls;
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-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.configuration.editors.uitls;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -21,6 +22,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
@@ -34,6 +36,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -68,6 +71,14 @@
*/
public class SmooksUIUtils {
+ public static final String FILE_PRIX = "File:/"; //$NON-NLS-1$
+
+ public static final String WORKSPACE_PRIX = "Workspace:/"; //$NON-NLS-1$
+
+ public static final String RESOURCE = "Resource:/";
+
+ public static final String XSL_NAMESPACE = "
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" ";
+
public static void createTextFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain,
FormToolkit toolkit, Composite parent, Object model) {
toolkit.createLabel(parent, "Value :");
@@ -96,6 +107,28 @@
});
}
+ public static String parseFilePath(String path) throws InvocationTargetException {
+ int index = path.indexOf(FILE_PRIX);
+ if (index != -1) {
+ path = path.substring(index + FILE_PRIX.length(), path.length());
+ } else {
+ index = path.indexOf(WORKSPACE_PRIX);
+ if (index != -1) {
+ path = path.substring(index + WORKSPACE_PRIX.length(), path.length());
+ Path wpath = new Path(path);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(wpath);
+ if (file.exists()) {
+ path = file.getLocation().toOSString();
+ } else {
+ throw new InvocationTargetException(new Exception("File : " + path +
" isn't exsit")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ throw new InvocationTargetException(new Exception("This path is un-support"
+ path + ".")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return path;
+ }
+
public static Composite createSelectorFieldEditor(FormToolkit toolkit, Composite
parent,
final IItemPropertyDescriptor propertyDescriptor, Object model,
final SmooksGraphicsExtType extType) {
@@ -430,4 +463,20 @@
toolkit.paintBordersFor(classTextComposite);
return classTextComposite;
}
+
+ public static void showErrorDialog(Shell shell, Status status) {
+ ErrorDialog.openError(shell, "Error", "error", status);
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static Status createErrorStatus(Throwable throwable, String message) {
+ while (throwable != null && throwable instanceof InvocationTargetException) {
+ throwable = ((InvocationTargetException) throwable).getTargetException();
+ }
+ return new Status(Status.ERROR, SmooksConfigurationActivator.PLUGIN_ID, message,
throwable);
+ }
+
+ public static Status createErrorStatus(Throwable throwable) {
+ return createErrorStatus(throwable, "Error"); //$NON-NLS-1$
+ }
+
}
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-04-12
11:09:30 UTC (rev 14695)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -19,6 +19,9 @@
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanContentProvider;
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.smooks10.model.smooks.util.SmooksModelUtils;
/**
@@ -120,9 +123,11 @@
protected HashMap<String, IViewerInitor> createNewInitorMap() {
HashMap<String, IViewerInitor> map = new HashMap<String, IViewerInitor>();
+
+ // for java
BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
String name = "Java";
- String description = "Java class";
+ String description = "Browse a Java type";
String iconPath = null;
String typeID = SmooksModelUtils.INPUT_TYPE_JAVA;
@@ -134,6 +139,24 @@
javabeanViewerInitor.setTreeContentProvider(new JavabeanContentProvider());
javabeanViewerInitor.setStructuredDataLoadWizard(new JavabeanStrucutredDataWizard());
map.put(typeID, javabeanViewerInitor);
+
+ // for XML
+
+ BaseViewerInitor xmlViewerInitor = new BaseViewerInitor();
+ name = "XML";
+ description = "Select a xml file ";
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_XML;
+
+ xmlViewerInitor.setName(name);
+ xmlViewerInitor.setDescription(description);
+ xmlViewerInitor.setWizardIconPath(iconPath);
+ xmlViewerInitor.setTypeID(typeID);
+ xmlViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+ xmlViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+ xmlViewerInitor.setStructuredDataLoadWizard(new XMLStructuredDataWizard());
+ map.put(typeID, xmlViewerInitor);
+
return map;
}
}
Added:
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
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,331 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+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.WizardPage;
+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.events.SelectionListener;
+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.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+
+/**
+ *
+ * @author Dart Peng Date : 2008-8-13
+ */
+public abstract class AbstractFileSelectionWizardPage extends WizardPage
+ implements SelectionListener {
+ protected IStructuredSelection selection;
+ protected Object returnObject = null;
+ protected Text fileText;
+ protected Composite fileTextComposite;
+ protected CheckboxTableViewer tableViewer = null;
+ protected Button fileSystemBrowseButton;
+ protected boolean reasourceLoaded = false;
+ private Button workspaceBrowseButton;
+ private String filePath = null;
+
+ public AbstractFileSelectionWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Object getReturnValue() {
+ try {
+ String path = getFilePath();
+ if(path == null) return null;
+ path = SmooksUIUtils.parseFilePath(path);
+ returnObject = this.loadedTheObject(path);
+ } catch (Exception e) {
+ SmooksUIUtils.showErrorDialog(getShell(), SmooksUIUtils.createErrorStatus(e));
+ }
+ return returnObject;
+ }
+
+ public String getFilePath(){
+ return filePath;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ mainComposite.setLayout(layout);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ mainComposite.setLayoutData(gd);
+
+ // xmlButton = new Button(mainComposite, SWT.RADIO);
+ // xmlButton.setText("Select a XML file");
+ //
+ // Composite xmlComposite = this
+ // .createXMLFileSelectionComposite(mainComposite);
+ //
+ // Label sp = new Label(mainComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ // gd = new GridData(GridData.FILL_HORIZONTAL);
+ // sp.setLayoutData(gd);
+ //
+ // xsdButton = new Button(mainComposite, SWT.RADIO);
+ // xsdButton.setText("Select a XSD file");
+
+ Composite xsdComposite = this
+ .createFileSelectionComposite(mainComposite);
+
+ // init the panel status (XSD file selection composite is disabled)
+ // xsdButton.setSelection(true);
+ //
+ // setCompositeChildrenEnabled(xmlComposite, false);
+
+ // registe the listener for controls
+ hookBrowseButtonSelectionAdapter();
+ hookFileTextModifyListener();
+ this.setControl(mainComposite);
+ }
+
+ protected void hookFileTextModifyListener() {
+ final ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ filePath = fileText.getText();
+ changeWizardPageStatus();
+ }
+ };
+ // xmlFileText.addModifyListener(modifyListener);
+ fileText.addModifyListener(modifyListener);
+ }
+
+ protected void hookRadioButtonSelectionAdapter() {
+ // xsdButton.addSelectionListener(this);
+ }
+
+ protected void hookBrowseButtonSelectionAdapter() {
+ SelectionAdapter browseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == fileSystemBrowseButton) {
+ relationT = fileText;
+ }
+ openFileSelection(relationT);
+ }
+ };
+ SelectionAdapter wbrowseButtonSelectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == workspaceBrowseButton) {
+ relationT = fileText;
+ }
+ openWorkSpaceSelection(relationT);
+ }
+
+ };
+
+ workspaceBrowseButton
+ .addSelectionListener(wbrowseButtonSelectionAdapter);
+ // xmlFileSystemBrowseButton
+ // .addSelectionListener(browseButtonSelectionAdapter);
+ fileSystemBrowseButton
+ .addSelectionListener(browseButtonSelectionAdapter);
+ }
+
+ protected void openWorkSpaceSelection(Text relationT) {
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(),
+ "Select Files", "", false, null, Collections.EMPTY_LIST);
//$NON-NLS-1$ //$NON-NLS-2$
+ // dialog.setInitialSelections(selectedResources);
+ if (files.length > 0) {
+ IFile file = files[0];
+ String s = file.getFullPath().toPortableString();
+ s = SmooksUIUtils.WORKSPACE_PRIX + s;
+ relationT.setText(s);
+ }
+ }
+
+ 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;
+
+// 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;
+ browseButtonComposite.setLayoutData(gd);
+
+ GridLayout bg = new GridLayout();
+ bg.numColumns = 2;
+ bg.marginHeight = 0;
+ bg.marginWidth = 0;
+ bg.makeColumnsEqualWidth = false;
+ browseButtonComposite.setLayout(bg);
+
+ fileSystemBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ fileSystemBrowseButton.setText("File System"); //$NON-NLS-1$
+
+ workspaceBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ workspaceBrowseButton.setText("Work Space"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ workspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.END;
+ fileSystemBrowseButton.setLayoutData(gd);
+
+ return xsdComposite;
+ }
+
+ 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());
+ }
+
+ protected void setCompositeChildrenEnabled(Composite composite,
+ boolean enabled) {
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof Text) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Button) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Composite) {
+ setCompositeChildrenEnabled((Composite) child, enabled);
+ }
+ }
+ }
+
+ protected void openFileSelection(Text relationText) {
+ FileDialog dialog = new FileDialog(this.getShell());
+ String path = dialog.open();
+ if (path != null) {
+ path = SmooksUIUtils.FILE_PRIX + path;
+ relationText.setText(path);
+ }
+ }
+
+ protected void changeWizardPageStatus() {
+ String text = this.fileText.getText();
+ 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";
+// }
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ changeWizardPageStatus();
+ }
+
+ public CheckboxTableViewer getTableViewer() {
+ return tableViewer;
+ }
+
+ public void setTableViewer(CheckboxTableViewer tableViewer) {
+ this.tableViewer = tableViewer;
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,78 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+
+/**
+ * @author Dart
+ *
+ */
+public abstract class AbstractStructuredDdataWizard extends Wizard implements
+ IStructuredDataSelectionWizard, INewWizard {
+ protected IWorkbench workbench;
+
+ protected IStructuredSelection selection;
+
+ protected AbstractFileSelectionWizardPage page = null;
+ protected Object xsdElement = null;
+ protected IWizardNode strucutredDataCreationWizardNode;
+
+ public AbstractStructuredDdataWizard() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void addPages() {
+ if (page == null) {
+ page = createAbstractFileSelectionWizardPage();
+ page.setSelection(this.selection);
+ }
+ this.addPage(page);
+ }
+
+ abstract protected AbstractFileSelectionWizardPage
createAbstractFileSelectionWizardPage();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ xsdElement = this.page.getReturnValue();
+ return true;
+ }
+
+ public Object getReturnData() {
+ return xsdElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.ui.IStructuredDataCreationWizard#
+ * getStructuredDataSourcePath()
+ */
+ public String getStructuredDataSourcePath() {
+ return page.getFilePath();
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dom4j.Element;
+import org.dom4j.QName;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class AbstractXMLObject implements IXMLStructuredObject{
+
+ protected PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ protected Element referenceElement = null;
+
+ protected boolean canEdit = false;
+
+ public boolean isCanEdit() {
+ return canEdit;
+ }
+
+ public boolean isAttribute(){
+ return false;
+ }
+
+ public void setCanEdit(boolean canEdit) {
+ this.canEdit = canEdit;
+ }
+
+ protected AbstractXMLObject parent;
+
+ protected String name;
+
+ public String getNamespaceURL() {
+ return namespaceURL;
+ }
+
+ public void setNamespaceURL(String namespaceURL) {
+ this.namespaceURL = namespaceURL;
+ }
+
+ protected String namespaceURL = null;
+
+ protected List<AbstractXMLObject> children = new
ArrayList<AbstractXMLObject>();
+
+ public String getName() {
+ return name;
+ }
+
+ public PropertyChangeListener[] getPropertyChangeListeners(){
+ return support.getPropertyChangeListeners();
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ Element element = this.getReferenceElement();
+ if(element != null){
+ element.setQName(new QName(name,element.getNamespace()));
+ }
+ }
+
+ public List<AbstractXMLObject> getXMLNodeChildren() {
+ return children;
+ }
+
+ public void setChildren(List<AbstractXMLObject> children) {
+ this.children = children;
+ }
+
+ public Element getReferenceElement() {
+ return referenceElement;
+ }
+
+ public void setReferenceElement(Element referenceElement) {
+ this.referenceElement = referenceElement;
+ }
+
+ /**
+ * @return the parent
+ */
+ public AbstractXMLObject getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent the parent to set
+ */
+ public void setParent(AbstractXMLObject parent) {
+ this.parent = parent;
+ }
+
+ public void addNodePropetyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void removeNodePropetyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ public void cleanAllNodePropertyChangeListeners() {
+ PropertyChangeListener[] ps = support.getPropertyChangeListeners();
+ for (int i = 0; i < ps.length; i++) {
+ PropertyChangeListener p = ps[i];
+ support.removePropertyChangeListener(p);
+ }
+ }
+
+ public List<IXMLStructuredObject> getChildren() {
+ List children = getXMLNodeChildren();
+ return children;
+ }
+
+ public Object getID() {
+ return getName();
+ }
+
+ public String getNodeName() {
+ return getName();
+ }
+
+ public boolean isRootNode() {
+ return false;
+ }
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 26, 2008
+ */
+public class TagList extends AbstractXMLObject {
+ List<TagObject> rootTagList = new ArrayList<TagObject>();
+
+ private Object id = new Object();
+
+// public TagObject getRootTag() {
+// return rootTag;
+// }
+
+ public List<TagObject> getRootTagList() {
+ return rootTagList;
+ }
+
+
+
+ @Override
+ public List<IXMLStructuredObject> getChildren() {
+ List tags = getRootTagList();
+ return tags;
+ }
+
+
+
+ @Override
+ public Object getID() {
+ return id;
+ }
+
+
+
+ @Override
+ public String getName() {
+ return "";
+ }
+
+
+
+ public void removeRootTag(TagObject rootTag){
+ rootTagList.remove(rootTag);
+ if(rootTag != null) rootTag.setParent(null);
+ }
+
+ public void addRootTag(TagObject rootTag) {
+ rootTagList.add(rootTag);
+ if(rootTag != null) rootTag.setParent(this);
+ }
+
+ public String toString(){
+// if(rootTag != null)
+// return "Document : " + getName() + "\n" +
getRootTag().toString();
+
+ return "Docuement Object : " +getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.xml.model.AbstractXMLObject#getParent()
+ */
+ @Override
+ public AbstractXMLObject getParent() {
+ return null;
+ }
+
+
+
+ @Override
+ public boolean isRootNode() {
+ return true;
+ }
+
+
+
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class TagObject extends AbstractXMLObject {
+ protected List<TagPropertyObject> properties = new
ArrayList<TagPropertyObject>();
+
+ public List<TagPropertyObject> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<TagPropertyObject> properties) {
+ this.properties = properties;
+ }
+
+ public void addProperty(TagPropertyObject pro) {
+ this.getProperties().add(pro);
+ if (pro != null)
+ pro.setParent(this);
+ }
+
+ public void removeProperty(TagPropertyObject pro) {
+ this.getProperties().remove(pro);
+ if (pro != null)
+ pro.setParent(null);
+ }
+
+ public void addChildTag(TagObject tag) {
+ this.getXMLNodeChildren().add(tag);
+ if (tag != null)
+ tag.setParent(this);
+ }
+
+ public void removeChildTag(TagObject tag) {
+ this.getXMLNodeChildren().remove(tag);
+ if (tag != null)
+ tag.setParent(null);
+ }
+
+ @Override
+ public List<IXMLStructuredObject> getChildren() {
+ List all = new ArrayList();
+ List tags = this.getXMLNodeChildren();
+ List properties = this.getProperties();
+ all.addAll(properties);
+ all.addAll(tags);
+ return all;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(getName());
+ buffer.append("\n");
+ for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
+ TagPropertyObject pro = (TagPropertyObject) iterator.next();
+ buffer.append("\t");
+ buffer.append(pro.getName());
+ buffer.append("\n");
+ }
+
+ List l = getXMLNodeChildren();
+ for (Iterator iterator = l.iterator(); iterator.hasNext();) {
+ TagObject tag = (TagObject) iterator.next();
+ buffer.append("\t");
+ buffer.append(tag.toString());
+ buffer.append("\n");
+ }
+ return buffer.toString();
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.Collections;
+import java.util.List;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class TagPropertyObject extends AbstractXMLObject {
+
+ protected String type = "string";
+
+ protected String value = null;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+
+ @Override
+ public boolean isAttribute() {
+ return true;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public Object getID() {
+ return "@" + super.getID();
+ }
+
+ @Override
+ public List<AbstractXMLObject> getXMLNodeChildren() {
+ return Collections.EMPTY_LIST;
+ }
+ @Override
+ public void setChildren(List<AbstractXMLObject> children) {
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * 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.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class XMLObjectAnalyzer {
+ public TagList analyze(String xmlFilePath,String[] ignoreNodeNames)
+ throws FileNotFoundException, DocumentException {
+ FileInputStream stream = new FileInputStream(xmlFilePath);
+ return this.analyze(stream,ignoreNodeNames);
+ }
+
+ public TagList analyze(InputStream stream , String[] ignoreNodeNames) throws
DocumentException {
+ SAXReader reader = new SAXReader();
+ Document doc = reader.read(stream);
+ Element rootElement = doc.getRootElement();
+ TagList dco = new TagList();
+ dco.setName("Docuement");
+ dco.addRootTag( parseElement(rootElement, null , ignoreNodeNames));
+ return dco;
+ }
+
+ public TagObject analyzeFregment(InputStream stream,String[] ignoreNodeNames) throws
DocumentException {
+ SAXReader reader = new SAXReader();
+ Document doc = reader.read(stream);
+ Element rootElement = doc.getRootElement();
+ return parseElement(rootElement, null ,ignoreNodeNames);
+ }
+
+ protected TagObject getChildTagByName(String name, TagObject tag , String[]
ignoreNodeNames) {
+ if(isIgnoreNode(name, ignoreNodeNames)) return null;
+ if (tag == null)
+ return null;
+ List<?> list = tag.getXMLNodeChildren();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ TagObject tagc = (TagObject) iterator.next();
+ if (tagc.getName().equals(name))
+ return tagc;
+ }
+ return null;
+ }
+
+ private boolean isIgnoreNode(Element element , String[] ignoreNodeNames){
+ return isIgnoreNode(element.getName(), ignoreNodeNames);
+ }
+
+// private boolean isIgnoreNode(TagObject element , String[] ignoreNodeNames){
+// return isIgnoreNode(element.getName(), ignoreNodeNames);
+// }
+
+ private boolean isIgnoreNode(String name , String[] ignoreNodeNames){
+ if(ignoreNodeNames == null) return false;
+ for (int i = 0; i < ignoreNodeNames.length; i++) {
+ String ignore = ignoreNodeNames[i];
+ if(ignore.trim().equalsIgnoreCase(name)) return true;
+ }
+ return false;
+ }
+
+ protected TagObject parseElement(Element element, TagObject parentTag , String[]
ignoreNodeNames) {
+
+ if(isIgnoreNode(element, ignoreNodeNames))
+ return null;
+ boolean canAdd = false;
+ TagObject tag = getChildTagByName(element.getName(), parentTag , ignoreNodeNames);
+ if (tag == null) {
+ tag = new TagObject();
+ canAdd = true;
+ }
+ tag.setReferenceElement(element);
+ tag.setName(element.getName());
+ fillProperties(element, tag ,ignoreNodeNames);
+ tag.setNamespaceURL(element.getNamespaceURI());
+ List<?> list = element.elements();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ Element childElement = (Element) iterator.next();
+ TagObject t = parseElement(childElement, tag , ignoreNodeNames);
+ if (t != null){
+ t.setReferenceElement(childElement);
+ tag.addChildTag(t);
+ }
+ }
+ if (canAdd)
+ return tag;
+ else
+ return null;
+ }
+
+ protected boolean hasSameNameProperty(String proName, TagObject tag) {
+ List<TagPropertyObject> pros = tag.getProperties();
+ for (Iterator<TagPropertyObject> iterator = pros.iterator(); iterator.hasNext();)
{
+ TagPropertyObject tp = (TagPropertyObject) iterator.next();
+ if (tp.getName().equals(proName))
+ return true;
+ }
+ return false;
+ }
+
+ protected void fillProperties(Element element, TagObject tag , String[] ignoreNodeNames)
{
+ Iterator<?> it = element.attributeIterator();
+ for (Iterator<?> iterator = it; iterator.hasNext();) {
+ Attribute attr = (Attribute) iterator.next();
+ String attrName = attr.getName();
+ String value = attr.getValue();
+ if(isIgnoreNode(attrName, ignoreNodeNames)) continue;
+ if (hasSameNameProperty(attrName, tag)) {
+ continue;
+ }
+ TagPropertyObject pro = new TagPropertyObject();
+ pro.setName(attr.getName());
+ pro.setValue(value);
+ pro.setNamespaceURL(attr.getNamespaceURI());
+ tag.addProperty(pro);
+ }
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+public class XMLStructuredDataContentProvider implements ITreeContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object obj) {
+ // for AbstractXMLObject (come from xml file fragment)
+ if(obj instanceof TagList){
+ return ((TagList)obj).getRootTagList().toArray();
+ }
+
+ if(obj instanceof TagObject){
+ List c = new ArrayList();
+ List pros = ((TagObject)obj).getProperties();
+ c.addAll(pros);
+ c.addAll(((TagObject)obj).getXMLNodeChildren());
+
+ return c.toArray();
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object )
+ */
+ public Object getParent(Object arg0) {
+ if(arg0 instanceof AbstractXMLObject){
+ return ((AbstractXMLObject)arg0).getParent();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
+ * Object)
+ */
+ public boolean hasChildren(Object obj) {
+
+ // for AbstractXMLObject (come from xml file fragment)
+ if(obj instanceof TagList){
+ return true;
+ }
+ if(obj instanceof TagObject){
+ List pros = ((TagObject)obj).getProperties();
+ List c = (((TagObject)obj).getXMLNodeChildren());
+ return !pros.isEmpty() || !c.isEmpty();
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
+ * .lang.Object)
+ */
+ public Object[] getElements(Object arg0) {
+ if(arg0 instanceof TagList){
+ return ((TagList)arg0).getRootTagList().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 arg0, Object arg1, Object arg2) {
+
+ }
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 18, 2008
+ */
+public class XMLStructuredDataLabelProvider extends LabelProvider {
+
+ public Image getXmlElementImage() {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_XML_ELEMENT);
+
+ }
+
+ public Image getXmlAttributeImage() {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_XML_ATTRIBUTE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof TagObject) {
+ return getXmlElementImage();
+ }
+ if (element instanceof TagPropertyObject) {
+ return getXmlAttributeImage();
+ }
+ return super.getImage(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if (element instanceof TagList) {
+ return "Root";
+ }
+ if (element instanceof AbstractXMLObject) {
+ return ((AbstractXMLObject) element).getName();
+ }
+ return "";
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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 Peng
+ * @Date Aug 18, 2008
+ */
+public class XMLStructuredDataWizard extends AbstractStructuredDdataWizard {
+
+
+ Properties properties = new Properties();
+ String filePath = null;
+
+ public static final String XML_FILE = "xmlFile";
+
+ @Override
+ protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
+ return new XMLStructuredDataWizardPage("XML");
+ }
+
+ public boolean performFinish() {
+ filePath = page.getFilePath();
+// properties.put(XML_FILE, filePath);
+ return super.performFinish();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ return SmooksModelUtils.INPUT_TYPE_XML;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java 2009-04-12
17:57:11 UTC (rev 14696)
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+/**
+ * @author Dart Peng Date : 2008-8-16
+ */
+public class XMLStructuredDataWizardPage extends AbstractFileSelectionWizardPage {
+
+ public XMLStructuredDataWizardPage(String pageName) {
+ super(pageName);
+ setPageText();
+ }
+
+ private void setPageText() {
+ this.setTitle("XML File"); //$NON-NLS-1$
+ this.setDescription("Select XML File"); //$NON-NLS-1$
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.xml.ui.AbstractFileSelectionWizardPage#loadedTheObject
+ * (java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
+ TagList doc = analyzer.analyze(path, null);
+ return doc;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain